From 270ed5a1ea70fc00f3e56f4f0a3378d648840d27 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 14 Oct 2019 18:16:31 +0200 Subject: [PATCH] update shower MQTT for HA --- doc/home assistant/automation.yaml | 14 +------------- doc/home assistant/sensor.yaml | 2 +- src/ems-esp.cpp | 15 +++++---------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/doc/home assistant/automation.yaml b/doc/home assistant/automation.yaml index f277824f8..f896a69ce 100644 --- a/doc/home assistant/automation.yaml +++ b/doc/home assistant/automation.yaml @@ -7,19 +7,7 @@ - service: notify.general_notify data_template: title: "Shower finished at {{states.sensor.time.state}}" - message: '{{trigger.payload}}' - -- id: boiler_shower_alarm - alias: Alert shower too long - trigger: - platform: mqtt - topic: home/ems-esp/command - payload: 'shower_alarm' - action: - - service: notify.admin_notify - data_template: - title: "Shower Alert!" - message: "Shower time exceeded limit" + message: "{{ trigger.payload_json['duration'] }}" # when ems-esp starts send boottime - id: boiler_restart diff --git a/doc/home assistant/sensor.yaml b/doc/home assistant/sensor.yaml index e9f7efcfd..c88224f1c 100644 --- a/doc/home assistant/sensor.yaml +++ b/doc/home assistant/sensor.yaml @@ -140,7 +140,7 @@ - platform: template sensors: showertime_time: - value_template: '{{ as_timestamp(states.sensor.last_shower_duration.last_updated) | int | timestamp_custom("%-I:%M %P on %a %-d %b") }}' + value_template: '{{ as_timestamp(states.sensor.last_shower_duration.last_updated) | int | timestamp_custom("%-I:%M on %a %-d %b") }}' boiler_updated: value_template: '{{ as_timestamp(states.sensor.boiler_temperature.last_updated) | timestamp_custom("%H:%M on %d/%b") }}' diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index d8fb1eab3..c08f284ba 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -1060,6 +1060,7 @@ bool do_publishShowerData() { rootShower[TOPIC_SHOWER_TIMER] = EMSESP_Settings.shower_timer ? "1" : "0"; rootShower[TOPIC_SHOWER_ALERT] = EMSESP_Settings.shower_alert ? "1" : "0"; + // only publish shower duration if there is a value char s[50] = {0}; if (EMSESP_Shower.duration > SHOWER_MIN_DURATION) { char buffer[16] = {0}; @@ -1067,10 +1068,8 @@ bool do_publishShowerData() { strlcat(s, " minutes and ", sizeof(s)); strlcat(s, itoa((uint8_t)((EMSESP_Shower.duration / 1000) % 60), buffer, 10), sizeof(s)); strlcat(s, " seconds", sizeof(s)); - } else { - strlcpy(s, "n/a", sizeof(s)); + rootShower[TOPIC_SHOWER_DURATION] = s; } - rootShower[TOPIC_SHOWER_DURATION] = s; char data[300] = {0}; serializeJson(doc, data, sizeof(data)); @@ -1939,13 +1938,9 @@ void showerCheck() { // SETUP // void setup() { - // LA trigger create a small puls to show setup is starting... - INIT_MARKERS(0); - LA_PULSE(50); - - // GPIO15 has a pull down, so we must set it to HIGH - pinMode(15, OUTPUT); - digitalWrite(15, 1); + // GPIO15/D8 has a pull down, so we must set it to HIGH so it doesn't bring the whole EMS bus down + pinMode(D8, OUTPUT); + digitalWrite(D8, 1); // init our own parameters initEMSESP();