From fea4d3ec93eb1cbdf65efd96efa88a0862815338 Mon Sep 17 00:00:00 2001 From: halfbakery Date: Wed, 12 Jan 2022 22:50:27 +0100 Subject: [PATCH 1/3] the cover state topic was useless and caused parsing errors in Home Assistant --- tasmota/xdrv_12_home_assistant.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index e1cdc5179..ba8cf7fd6 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -1030,8 +1030,7 @@ void HAssAnnounceShutters(void) } else { snprintf_P(stemp1, sizeof(stemp1), PSTR("%s"), SettingsText(SET_FRIENDLYNAME1 + i)); } - GetTopic_P(stemp2, TELE, TasmotaGlobal.mqtt_topic, D_RSLT_STATE); - Response_P(HASS_DISCOVER_BASE, stemp1, stemp2); + Response_P(PSTR("{\"name\":\"%s\""), stemp1); GetTopic_P(stemp1, TELE, TasmotaGlobal.mqtt_topic, S_LWT); TryResponseAppend_P(HASS_DISCOVER_SENSOR_LWT, stemp1); From 17066e404c2b15076116d2115280ccea14ca2359 Mon Sep 17 00:00:00 2001 From: halfbakery Date: Wed, 12 Jan 2022 22:54:49 +0100 Subject: [PATCH 2/3] skip shutter tilt discovery if tilting is unconfigured --- tasmota/xdrv_12_home_assistant.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index ba8cf7fd6..080d6cc5f 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -1042,8 +1042,10 @@ void HAssAnnounceShutters(void) GetTopic_P(stemp2, CMND, TasmotaGlobal.mqtt_topic, PSTR("ShutterPosition")); TryResponseAppend_P(HASS_DISCOVER_SHUTTER_POS, stemp1, i + 1, stemp2, i + 1); - GetTopic_P(stemp1, CMND, TasmotaGlobal.mqtt_topic, PSTR("ShutterTilt")); - TryResponseAppend_P(HASS_DISCOVER_SHUTTER_TILT, stemp1, i + 1, Settings->shutter_tilt_config[3][i], Settings->shutter_tilt_config[4][i]); + if (Settings->shutter_tilt_config[3][i] != Settings->shutter_tilt_config[4][i]) { + GetTopic_P(stemp1, CMND, TasmotaGlobal.mqtt_topic, PSTR("ShutterTilt")); + TryResponseAppend_P(HASS_DISCOVER_SHUTTER_TILT, stemp1, i + 1, Settings->shutter_tilt_config[3][i], Settings->shutter_tilt_config[4][i]); + } TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId()); TryResponseAppend_P(PSTR("}")); From d881e1f8645c460e06c52e83e1184b209fcc1295 Mon Sep 17 00:00:00 2001 From: halfbakery Date: Wed, 12 Jan 2022 23:04:47 +0100 Subject: [PATCH 3/3] add state_class to energy totals to support Home Assistant long term statistics --- tasmota/xdrv_12_home_assistant.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index 080d6cc5f..0aa67c753 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -39,7 +39,7 @@ const char kHAssJsonSensorDevCla[] PROGMEM = "dev_cla\":\"power|dev_cla\":\"battery|dev_cla\":\"current|ic\":\"mdi:leak|ic\":\"mdi:current-ac|dev_cla\":\"humidity|dev_cla\":\"illuminance|" "ic\":\"mdi:cup-water|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|" "dev_cla\":\"pm1|dev_cla\":\"pm25|dev_cla\":\"pm10|dev_cla\":\"power_factor|dev_cla\":\"power|ic\":\"mdi:progress-clock|" - "dev_cla\":\"power|dev_cla\":\"energy|dev_cla\":\"energy|dev_cla\":\"voltage|ic\":\"mdi:scale|dev_cla\":\"energy|" + "dev_cla\":\"power|dev_cla\":\"energy|dev_cla\":\"energy\",\"stat_cla\":\"total_increasing|dev_cla\":\"voltage|ic\":\"mdi:scale|dev_cla\":\"energy|" "dev_cla\":\"carbon_dioxide|dev_cla\":\"carbon_dioxide|dev_class\":\"volatile_organic_compounds|" "ic\":\"mdi:palette|ic\":\"mdi:palette|ic\":\"mdi:palette|ic\":\"mdi:temperature-kelvin|ic\":\"mdi:ruler|dev_cla\":\"illuminance|";