mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 00:18:11 +01:00
[haier] climate ID auto generation (#6949)
This commit is contained in:
parent
7ee1406f64
commit
f7af51b92c
10 changed files with 17 additions and 42 deletions
|
@ -56,7 +56,7 @@ SENSOR_TYPES = {
|
|||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
}
|
||||
).extend({cv.Optional(type): schema for type, schema in SENSOR_TYPES.items()})
|
||||
|
||||
|
@ -64,8 +64,8 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
async def to_code(config):
|
||||
paren = await cg.get_variable(config[CONF_HAIER_ID])
|
||||
|
||||
for type, _ in SENSOR_TYPES.items():
|
||||
if conf := config.get(type):
|
||||
for type_ in SENSOR_TYPES:
|
||||
if conf := config.get(type_):
|
||||
sens = await binary_sensor.new_binary_sensor(conf)
|
||||
binary_sensor_type = getattr(BinarySensorTypeEnum, type.upper())
|
||||
binary_sensor_type = getattr(BinarySensorTypeEnum, type_.upper())
|
||||
cg.add(paren.set_sub_binary_sensor(binary_sensor_type, sens))
|
||||
|
|
|
@ -21,7 +21,7 @@ ICON_SPRAY_BOTTLE = "mdi:spray-bottle"
|
|||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
cv.Optional(CONF_SELF_CLEANING): button.button_schema(
|
||||
SelfCleaningButton,
|
||||
icon=ICON_SPRAY_BOTTLE,
|
||||
|
|
|
@ -183,7 +183,6 @@ BASE_CONFIG_SCHEMA = (
|
|||
cv.Optional(
|
||||
CONF_SUPPORTED_SWING_MODES,
|
||||
default=[
|
||||
"OFF",
|
||||
"VERTICAL",
|
||||
"HORIZONTAL",
|
||||
"BOTH",
|
||||
|
@ -211,7 +210,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
): cv.boolean,
|
||||
cv.Optional(
|
||||
CONF_SUPPORTED_PRESETS,
|
||||
default=list(["BOOST", "COMFORT"]), # No AWAY by default
|
||||
default=["BOOST", "COMFORT"], # No AWAY by default
|
||||
): cv.ensure_list(
|
||||
cv.enum(SUPPORTED_CLIMATE_PRESETS_SMARTAIR2_OPTIONS, upper=True)
|
||||
),
|
||||
|
@ -231,7 +230,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
): cv.int_range(min=PROTOCOL_CONTROL_PACKET_SIZE, max=50),
|
||||
cv.Optional(
|
||||
CONF_SUPPORTED_PRESETS,
|
||||
default=list(["BOOST", "ECO", "SLEEP"]), # No AWAY by default
|
||||
default=["BOOST", "ECO", "SLEEP"], # No AWAY by default
|
||||
): cv.ensure_list(
|
||||
cv.enum(SUPPORTED_CLIMATE_PRESETS_HON_OPTIONS, upper=True)
|
||||
),
|
||||
|
@ -427,11 +426,7 @@ def _final_validate(config):
|
|||
"No logger component found, logging for Haier protocol is disabled"
|
||||
)
|
||||
cg.add_build_flag("-DHAIER_LOG_LEVEL=0")
|
||||
if (
|
||||
(CONF_WIFI_SIGNAL in config)
|
||||
and (config[CONF_WIFI_SIGNAL])
|
||||
and CONF_WIFI not in full_config
|
||||
):
|
||||
if config.get(CONF_WIFI_SIGNAL) and CONF_WIFI not in full_config:
|
||||
raise cv.Invalid(
|
||||
f"No WiFi configured, if you want to use haier climate without WiFi add {CONF_WIFI_SIGNAL}: false to climate configuration"
|
||||
)
|
||||
|
|
|
@ -137,16 +137,16 @@ SENSOR_TYPES = {
|
|||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
}
|
||||
).extend({cv.Optional(type): schema for type, schema in SENSOR_TYPES.items()})
|
||||
).extend({cv.Optional(type_): schema for type_, schema in SENSOR_TYPES.items()})
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
paren = await cg.get_variable(config[CONF_HAIER_ID])
|
||||
|
||||
for type, _ in SENSOR_TYPES.items():
|
||||
if conf := config.get(type):
|
||||
for type_ in SENSOR_TYPES:
|
||||
if conf := config.get(type_):
|
||||
sens = await sensor.new_sensor(conf)
|
||||
sensor_type = getattr(SensorTypeEnum, type.upper())
|
||||
sensor_type = getattr(SensorTypeEnum, type_.upper())
|
||||
cg.add(paren.set_sub_sensor(sensor_type, sens))
|
||||
|
|
|
@ -39,7 +39,7 @@ TEXT_SENSOR_TYPES = {
|
|||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate),
|
||||
}
|
||||
).extend({cv.Optional(type): schema for type, schema in TEXT_SENSOR_TYPES.items()})
|
||||
|
||||
|
@ -47,8 +47,8 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
async def to_code(config):
|
||||
paren = await cg.get_variable(config[CONF_HAIER_ID])
|
||||
|
||||
for type, _ in TEXT_SENSOR_TYPES.items():
|
||||
if conf := config.get(type):
|
||||
for type_ in TEXT_SENSOR_TYPES:
|
||||
if conf := config.get(type_):
|
||||
sens = await text_sensor.new_text_sensor(conf)
|
||||
text_sensor_type = getattr(TextSensorTypeEnum, type.upper())
|
||||
text_sensor_type = getattr(TextSensorTypeEnum, type_.upper())
|
||||
cg.add(paren.set_sub_text_sensor(text_sensor_type, sens))
|
||||
|
|
|
@ -54,7 +54,6 @@ climate:
|
|||
|
||||
sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
outdoor_temperature:
|
||||
name: Haier outdoor temperature
|
||||
humidity:
|
||||
|
@ -80,7 +79,6 @@ sensor:
|
|||
|
||||
binary_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
compressor_status:
|
||||
name: Haier Outdoor Compressor Status
|
||||
defrost_status:
|
||||
|
@ -96,7 +94,6 @@ binary_sensor:
|
|||
|
||||
button:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
self_cleaning:
|
||||
name: Haier start self cleaning
|
||||
steri_cleaning:
|
||||
|
@ -104,7 +101,6 @@ button:
|
|||
|
||||
text_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
appliance_name:
|
||||
name: Haier appliance name
|
||||
cleaning_status:
|
||||
|
|
|
@ -54,7 +54,6 @@ climate:
|
|||
|
||||
sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
outdoor_temperature:
|
||||
name: Haier outdoor temperature
|
||||
humidity:
|
||||
|
@ -80,7 +79,6 @@ sensor:
|
|||
|
||||
binary_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
compressor_status:
|
||||
name: Haier Outdoor Compressor Status
|
||||
defrost_status:
|
||||
|
@ -96,7 +94,6 @@ binary_sensor:
|
|||
|
||||
button:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
self_cleaning:
|
||||
name: Haier start self cleaning
|
||||
steri_cleaning:
|
||||
|
@ -104,7 +101,6 @@ button:
|
|||
|
||||
text_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
appliance_name:
|
||||
name: Haier appliance name
|
||||
cleaning_status:
|
||||
|
|
|
@ -54,7 +54,6 @@ climate:
|
|||
|
||||
sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
outdoor_temperature:
|
||||
name: Haier outdoor temperature
|
||||
humidity:
|
||||
|
@ -80,7 +79,6 @@ sensor:
|
|||
|
||||
binary_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
compressor_status:
|
||||
name: Haier Outdoor Compressor Status
|
||||
defrost_status:
|
||||
|
@ -96,7 +94,6 @@ binary_sensor:
|
|||
|
||||
button:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
self_cleaning:
|
||||
name: Haier start self cleaning
|
||||
steri_cleaning:
|
||||
|
@ -104,7 +101,6 @@ button:
|
|||
|
||||
text_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
appliance_name:
|
||||
name: Haier appliance name
|
||||
cleaning_status:
|
||||
|
|
|
@ -54,7 +54,6 @@ climate:
|
|||
|
||||
sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
outdoor_temperature:
|
||||
name: Haier outdoor temperature
|
||||
humidity:
|
||||
|
@ -80,7 +79,6 @@ sensor:
|
|||
|
||||
binary_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
compressor_status:
|
||||
name: Haier Outdoor Compressor Status
|
||||
defrost_status:
|
||||
|
@ -96,7 +94,6 @@ binary_sensor:
|
|||
|
||||
button:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
self_cleaning:
|
||||
name: Haier start self cleaning
|
||||
steri_cleaning:
|
||||
|
@ -104,7 +101,6 @@ button:
|
|||
|
||||
text_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
appliance_name:
|
||||
name: Haier appliance name
|
||||
cleaning_status:
|
||||
|
|
|
@ -54,7 +54,6 @@ climate:
|
|||
|
||||
sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
outdoor_temperature:
|
||||
name: Haier outdoor temperature
|
||||
humidity:
|
||||
|
@ -80,7 +79,6 @@ sensor:
|
|||
|
||||
binary_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
compressor_status:
|
||||
name: Haier Outdoor Compressor Status
|
||||
defrost_status:
|
||||
|
@ -96,7 +94,6 @@ binary_sensor:
|
|||
|
||||
button:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
self_cleaning:
|
||||
name: Haier start self cleaning
|
||||
steri_cleaning:
|
||||
|
@ -104,7 +101,6 @@ button:
|
|||
|
||||
text_sensor:
|
||||
- platform: haier
|
||||
haier_id: haier_ac
|
||||
appliance_name:
|
||||
name: Haier appliance name
|
||||
cleaning_status:
|
||||
|
|
Loading…
Reference in a new issue