mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
update shower MQTT for HA
This commit is contained in:
@@ -7,19 +7,7 @@
|
|||||||
- service: notify.general_notify
|
- service: notify.general_notify
|
||||||
data_template:
|
data_template:
|
||||||
title: "Shower finished at {{states.sensor.time.state}}"
|
title: "Shower finished at {{states.sensor.time.state}}"
|
||||||
message: '{{trigger.payload}}'
|
message: "{{ trigger.payload_json['duration'] }}"
|
||||||
|
|
||||||
- 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"
|
|
||||||
|
|
||||||
# when ems-esp starts send boottime
|
# when ems-esp starts send boottime
|
||||||
- id: boiler_restart
|
- id: boiler_restart
|
||||||
|
|||||||
@@ -140,7 +140,7 @@
|
|||||||
- platform: template
|
- platform: template
|
||||||
sensors:
|
sensors:
|
||||||
showertime_time:
|
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:
|
boiler_updated:
|
||||||
value_template: '{{ as_timestamp(states.sensor.boiler_temperature.last_updated) | timestamp_custom("%H:%M on %d/%b") }}'
|
value_template: '{{ as_timestamp(states.sensor.boiler_temperature.last_updated) | timestamp_custom("%H:%M on %d/%b") }}'
|
||||||
|
|||||||
@@ -1060,6 +1060,7 @@ bool do_publishShowerData() {
|
|||||||
rootShower[TOPIC_SHOWER_TIMER] = EMSESP_Settings.shower_timer ? "1" : "0";
|
rootShower[TOPIC_SHOWER_TIMER] = EMSESP_Settings.shower_timer ? "1" : "0";
|
||||||
rootShower[TOPIC_SHOWER_ALERT] = EMSESP_Settings.shower_alert ? "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};
|
char s[50] = {0};
|
||||||
if (EMSESP_Shower.duration > SHOWER_MIN_DURATION) {
|
if (EMSESP_Shower.duration > SHOWER_MIN_DURATION) {
|
||||||
char buffer[16] = {0};
|
char buffer[16] = {0};
|
||||||
@@ -1067,10 +1068,8 @@ bool do_publishShowerData() {
|
|||||||
strlcat(s, " minutes and ", sizeof(s));
|
strlcat(s, " minutes and ", sizeof(s));
|
||||||
strlcat(s, itoa((uint8_t)((EMSESP_Shower.duration / 1000) % 60), buffer, 10), sizeof(s));
|
strlcat(s, itoa((uint8_t)((EMSESP_Shower.duration / 1000) % 60), buffer, 10), sizeof(s));
|
||||||
strlcat(s, " seconds", sizeof(s));
|
strlcat(s, " seconds", sizeof(s));
|
||||||
} else {
|
rootShower[TOPIC_SHOWER_DURATION] = s;
|
||||||
strlcpy(s, "n/a", sizeof(s));
|
|
||||||
}
|
}
|
||||||
rootShower[TOPIC_SHOWER_DURATION] = s;
|
|
||||||
|
|
||||||
char data[300] = {0};
|
char data[300] = {0};
|
||||||
serializeJson(doc, data, sizeof(data));
|
serializeJson(doc, data, sizeof(data));
|
||||||
@@ -1939,13 +1938,9 @@ void showerCheck() {
|
|||||||
// SETUP
|
// SETUP
|
||||||
//
|
//
|
||||||
void setup() {
|
void setup() {
|
||||||
// LA trigger create a small puls to show setup is starting...
|
// GPIO15/D8 has a pull down, so we must set it to HIGH so it doesn't bring the whole EMS bus down
|
||||||
INIT_MARKERS(0);
|
pinMode(D8, OUTPUT);
|
||||||
LA_PULSE(50);
|
digitalWrite(D8, 1);
|
||||||
|
|
||||||
// GPIO15 has a pull down, so we must set it to HIGH
|
|
||||||
pinMode(15, OUTPUT);
|
|
||||||
digitalWrite(15, 1);
|
|
||||||
|
|
||||||
// init our own parameters
|
// init our own parameters
|
||||||
initEMSESP();
|
initEMSESP();
|
||||||
|
|||||||
Reference in New Issue
Block a user