diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 7ff66ff..8fee703 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -953,64 +953,16 @@ text_sensor: } if (domain == "climate") id(service_call_climate)->execute(entity.c_str(), key.c_str(), value.c_str(), (embedded==1)); else if (domain == "alarm_control_panel") id(service_call_alarm_control_panel)->execute(entity.c_str(), value.c_str()); - else if (entity != "" and not entity.empty() and entity != "embedded_climate") + else if (domain == "light") id(ha_call_service)->execute("light.turn_on", key.c_str(), value.c_str(), entity.c_str()); + else if (domain == "cover") { - { - if (${verbose_log}) ESP_LOGD("text_sensor.localevent", "Blueprint controlled service"); - auto ha_event = new esphome::api::CustomAPIDevice(); - if (domain == "climate") - { - if (key == "set_temperature") - { - service = "climate.set_temperature"; - key = "temperature"; - value = to_string(stof(value) / 10); - } - else if (key == "hvac_mode") - { - service = "climate.set_hvac_mode"; - } - } - else if (domain == "cover") - { - if (key == "position") - { - service = "cover.set_cover_position"; - } - else - { - service = std::string("cover.") + key.c_str(); - key = ""; - value = ""; - } - } - else if (domain == "fan") - { - if (key == "stop" or value == "0") - { - service = "fan.turn_off"; - key = ""; - value = ""; - } - else - { - service = "fan.turn_on"; - } - } - else if (domain == "light") - { - service = "light.turn_on"; - } - if (${verbose_log}) ESP_LOGD("text_sensor.localevent", "Service=%s", service.c_str()); - if (service != "" and not service.empty()) - ha_event->fire_homeassistant_event("esphome.nspanel_service_call", - { - {"service", service}, - {"entity", entity}, - {"key", key}, - {"value", value} - }); - } + if (key == "position") id(ha_call_service)->execute("cover.set_cover_position", key.c_str(), value.c_str(), entity.c_str()); + else id(ha_call_service)->execute((std::string("cover.") + key.c_str()), "", "", entity.c_str()); + } + else if (domain == "fan") + { + if (key == "stop" or value == "0") id(ha_call_service)->execute("fan.turn_off", "", "", entity.c_str()); + else id(ha_call_service)->execute("fan.turn_on", key.c_str(), value.c_str(), entity.c_str()); } ##### touchevent sensor, Reset the page timeout #####