Hi all,
I’ve been racking my brains and Google to come up with an automation to limit the time in the shower.
We have a power shower that senses water flow and turns the electric pump on accordingly.
Is there a way I could limit the time to a set period and then “blink” the pump a couple of times then allow another minute of normal use before turning if off completely?
This probably makes me sound quite Scrooge like but our hot water cylinder is limited in capacity and we can’t always get 4 showers out of it.
Any ideas?
Cheers
Mark
I have plenty of Sonoff’s but I have never used a POW.
Perhaps something like below might work?
switch:
- platform: mqtt
name: "Shower"
state_topic: "stat/pow1/POWER"
command_topic: "cmnd/pow1/POWER"
availability_topic: "tele/pow1/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
automation:
- alias: Scrooge
trigger:
- platform: mqtt
state_topic: "tele/pow1/SENSOR"
value_template: '{{ value_json["ENERGY"]["Power"] }}'
# The above 20 should be the watts where the pump kicks in. Or atleast above the stand by watts
above: 20
for:
hours: 0
minutes: 5
seconds: 0
action:
- service: switch.turn_off
entity_id: switch.Shower
- delay: '00:00:01'
- service: switch.turn_on
entity_id: switch.Shower
- delay: '00:01:00'
- service: switch.turn_off
entity_id: switch.Shower
Brilliant! That’s very decent of you. I’ll give it a try out in the morning
After your own shower of course
Ha! Very true. Actually, it is the other way around as I am waiting to have my shower so I can test out this “quick” automation I am putting together. Which, so far, is taking me all morning.
There is something wrong with the Automation as I get the below error
Invalid config for [automation]: [state_topic] is an invalid option for [automation]. Check: automation->trigger->0->state_topic.
I have the sensors working OK and can see them in the Overview but the automation isn’t loading.
Any ideas?
You could try (I am guessing sorry as never used the POW)
automation:
- alias: Scrooge
trigger:
- platform: mqtt
topic: "tele/pow1/SENSOR"
condition:
condition: template
value_template: '{{ value_json["ENERGY"]["Power"] >20 }}'
action:
- delay: '00:05:00'
- service: switch.turn_off
entity_id: switch.Shower
- delay: '00:00:01'
- service: switch.turn_on
entity_id: switch.Shower
- delay: '00:01:00'
- service: switch.turn_off
entity_id: switch.Shower
If that doesn’t work could you take a screen shot of the console window with the shower running.
I am after something like that bottom line where it is reading out the sensor information.
Or copy an paste that line for me.
Hi Will,
I didn’t have a lot of luck with the automation above. It actually stopped the unit from rebooting.
Anyway, I think the below are the relevant lines from the console. If you can see any clues from this I would be grateful.
00:44:55 MQT: stat/pow1/STATUS = {“Status”:{“Module”:43,“FriendlyName”:[“Pow1”],“Topic”:“pow1”,“ButtonTopic”:“0”,“Power”:1,“PowerOnState”:3,“LedState”:1,“SaveData”:1,“SaveState”:1,“SwitchTopic”:“0”,“SwitchMode”:[0,0,0,0,0,0,0,0],“ButtonRetain”:0,“SwitchRetain”:0,“SensorRetain”:0,“PowerRetain”:0}}
00:44:55 MQT: stat/pow1/STATUS1 = {“StatusPRM”:{“Baudrate”:4800,“GroupTopic”:“sonoffs”,“OtaUrl”:“http://thehackbox.org/tasmota/release/sonoff.bin",“RestartReason”:"Software/System restart”,“Uptime”:“0T00:07:00”,“StartupUTC”:“2018-12-28T23:37:55”,“Sleep”:50,“BootCount”:15,“SaveCount”:33,“SaveAddress”:“FA000”}}
00:44:56 MQT: stat/pow1/STATUS2 = {“StatusFWR”:{“Version”:“6.4.1(sonoff)”,“BuildDateTime”:“2018-12-24T14:41:00”,“Boot”:31,“Core”:“2_4_2”,“SDK”:“2.2.1(cfd48f3)”}}
00:44:56 MQT: stat/pow1/STATUS3 = {“StatusLOG”:{“SerialLog”:2,“WebLog”:2,“SysLog”:0,“LogHost”:"",“LogPort”:514,“SSId”:[“MarkMills”,""],“TelePeriod”:300,“SetOption”:[“00008009”,“558180C0”,“00000000”]}}
00:44:56 MQT: stat/pow1/STATUS4 = {“StatusMEM”:{“ProgramSize”:521,“Free”:480,“Heap”:18,“ProgramFlashSize”:1024,“FlashSize”:4096,“FlashChipId”:“1640EF”,“FlashMode”:3,“Features”:[“00000809”,“0FDAE794”,“000383A0”,“23B617CE”,“00003BC0”]}}
00:44:57 MQT: stat/pow1/STATUS5 = {“StatusNET”:{“Hostname”:“pow1-4745”,“IPAddress”:“192.168.0.187”,“Gateway”:“192.168.0.1”,“Subnetmask”:“255.255.255.0”,“DNSServer”:“192.168.0.241”,“Mac”:“80:7D:3A:32:32:89”,“Webserver”:2,“WifiConfig”:5}}
00:44:58 MQT: stat/pow1/STATUS6 = {“StatusMQT”:{“MqttHost”:“192.168.0.246”,“MqttPort”:1883,“MqttClientMask”:“DVES_%06X”,“MqttClient”:“DVES_323289”,“MqttUser”:“mark”,“MqttType”:1,“MAX_PACKET_SIZE”:1000,“KEEPALIVE”:15}}
00:44:58 MQT: stat/pow1/STATUS7 = {“StatusTIM”:{“UTC”:“Fri Dec 28 23:44:58 2018”,“Local”:“Sat Dec 29 00:44:58 2018”,“StartDST”:“Sun Mar 25 02:00:00 2018”,“EndDST”:“Sun Oct 28 03:00:00 2018”,“Timezone”:"+01:00",“Sunrise”:“08:43”,“Sunset”:“17:00”}}
00:44:59 MQT: stat/pow1/STATUS9 = {“StatusPTH”:{“PowerDelta”:80,“PowerLow”:0,“PowerHigh”:0,“VoltageLow”:0,“VoltageHigh”:0,“CurrentLow”:0,“CurrentHigh”:0}}
00:44:59 MQT: stat/pow1/STATUS10 = {“StatusSNS”:{“Time”:“2018-12-29T00:44:59”,“ENERGY”:{“TotalStartTime”:“2018-12-29T00:23:46”,“Total”:0.111,“Yesterday”:0.000,“Today”:0.111,“Power”:29,“ApparentPower”:30,“ReactivePower”:8,“Factor”:0.96,“Voltage”:246,“Current”:0.123}}}
00:45:00 MQT: stat/pow1/STATUS11 = {“StatusSTS”:{“Time”:“2018-12-29T00:44:59”,“Uptime”:“0T00:07:04”,“Vcc”:3.471,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“MarkMills”,“BSSId”:“BC:30:D9:05:8D:3D”,“Channel”:6,“RSSI”:98}}}
00:45:04 MQT: stat/pow1/STATUS = {“Status”:{“Module”:43,“FriendlyName”:[“Pow1”],“Topic”:“pow1”,“ButtonTopic”:“0”,“Power”:1,“PowerOnState”:3,“LedState”:1,“SaveData”:1,“SaveState”:1,“SwitchTopic”:“0”,“SwitchMode”:[0,0,0,0,0,0,0,0],“ButtonRetain”:0,“SwitchRetain”:0,“SensorRetain”:0,“PowerRetain”:0}}
00:45:04 MQT: stat/pow1/STATUS1 = {“StatusPRM”:{“Baudrate”:4800,“GroupTopic”:“sonoffs”,“OtaUrl”:“http://thehackbox.org/tasmota/release/sonoff.bin",“RestartReason”:"Software/System restart”,“Uptime”:“0T00:07:09”,“StartupUTC”:“2018-12-28T23:37:55”,“Sleep”:50,“BootCount”:15,“SaveCount”:33,“SaveAddress”:“FA000”}}
00:45:05 MQT: stat/pow1/STATUS2 = {“StatusFWR”:{“Version”:“6.4.1(sonoff)”,“BuildDateTime”:“2018-12-24T14:41:00”,“Boot”:31,“Core”:“2_4_2”,“SDK”:“2.2.1(cfd48f3)”}}
Thanks again,
Mark
That should read the Power value now.
Depending on how you shower you may never trigger that 5 min timer.
If it becomes a pain trying to turn the pump on and off do you have a WiFi or an Ikea type bulb in the bathroom? It might be easier to flash that instead?
Also I don’t know how many Watts the pump uses so I just picked 20.
automation:
- alias: Scrooge
trigger:
- platform: mqtt
topic: "stat/pow1/STATUS"
condition:
condition: template
value_template: '{{ trigger.payload_json.Status.Power => "20" }}'
action:
- delay: '00:05:00'
- service: switch.turn_off
entity_id: switch.Shower
- delay: '00:00:01'
- service: switch.turn_on
entity_id: switch.Shower
- delay: '00:01:00'
- service: switch.turn_off
entity_id: switch.Shower
# Delay to put power back on ready for next shower
- delay: '00:02:00'
- service: switch.turn_on
entity_id: switch.Shower
Hi Will,
Thanks for persevering with me through this. And I think I am making progress.
I got the automation to the point where it doesn’t cause errors. I had to remove the “=>” and change to “>” and also remove the quotes from 20.
But, the automation doesn’t work yet still though. I’ve been trying to debug it and I think something has changes in the Console output. I am now seeing data as per below.
15:26:51 MQT: tele/pow1/STATE = {“Time”:“2018-12-29T15:26:51”,“Uptime”:“0T00:00:19”,“Vcc”:3.488,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“MarkMills”,“BSSId”:“BC:30:D9:05:8D:3D”,“Channel”:6,“RSSI”:100}}
15:26:51 MQT: tele/pow1/SENSOR = {“Time”:“2018-12-29T15:26:51”,“ENERGY”:{“TotalStartTime”:“2018-12-29T00:23:46”,“Total”:0.127,“Yesterday”:0.000,“Today”:0.127,“Period”:0,“Power”:29,“ApparentPower”:30,“ReactivePower”:8,“Factor”:0.97,“Voltage”:246,“Current”:0.122}}
15:31:52 MQT: tele/pow1/STATE = {“Time”:“2018-12-29T15:31:52”,“Uptime”:“0T00:05:20”,“Vcc”:3.471,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“MarkMills”,“BSSId”:“BC:30:D9:05:8D:3D”,“Channel”:6,“RSSI”:98}}
15:31:52 MQT: tele/pow1/SENSOR = {“Time”:“2018-12-29T15:31:52”,“ENERGY”:{“TotalStartTime”:“2018-12-29T00:23:46”,“Total”:0.129,“Yesterday”:0.000,“Today”:0.129,“Period”:2,“Power”:29,“ApparentPower”:31,“ReactivePower”:9,“Factor”:0.96,“Voltage”:246,“Current”:0.124}}
15:33:44 MQT: tele/pow1/SENSOR = {“Time”:“2018-12-29T15:33:44”,“ENERGY”:{“TotalStartTime”:“2018-12-29T00:23:46”,“Total”:0.130,“Yesterday”:0.000,“Today”:0.130,“Power”:10,“ApparentPower”:10,“ReactivePower”:0,“Factor”:1.00,“Voltage”:247,“Current”:0.041}}
15:33:49 MQT: tele/pow1/SENSOR = {“Time”:“2018-12-29T15:33:49”,“ENERGY”:{“TotalStartTime”:“2018-12-29T00:23:46”,“Total”:0.130,“Yesterday”:0.000,“Today”:0.130,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:247,“Current”:0.000}}
15:34:15 MQT: tele/pow1/SENSOR = {“Time”:“2018-12-29T15:34:15”,“ENERGY”:{“TotalStartTime”:“2018-12-29T00:23:46”,“Total”:0.130,“Yesterday”:0.000,“Today”:0.130,“Power”:29,“ApparentPower”:30,“ReactivePower”:6,“Factor”:0.98,“Voltage”:247,“Current”:0.121}}
So, I changed the line
From:
state_topic: “stat/pow1/STATUS10”
To:
state_topic: “tele/pow1/SENSOR”
Was that correct? I suspect it wasn’t as the Automation still doesn’t work.
Thanks as always
Mark
Ok you have different data in this log compared to the previous, looks more promising with data of the pump working.
I have changed the 20 to an 8 as it looks like your pump sometimes runs at 10w sometimes and 29 other times if not put it back to 20
Try:
automation:
- alias: Scrooge
trigger:
- platform: mqtt
topic: "tele/pow1/SENSOR"
condition:
condition: template
value_template: '{{ trigger.payload_json.ENERGY.Power > 8 }}'
What you could also do to help test is add an input_boolean so when it senses power it turns on the input_boolean as a flag to say it’s reacted to the power. I have also removed some spaces from the code.
input_boolean:
shower_test:
icon: mdi:shower-head
automation:
- alias: Scrooge
trigger:
platform: mqtt
topic: "tele/pow1/SENSOR"
condition:
condition: template
value_template: '{{ trigger.payload_json.ENERGY.Power > 8 }}'
action:
service: input_boolean.turn_on
entity_id: input_boolean.shower_test
Good idea. That makes it easier to see.
It looks like it is not triggering as the boolean never turns on.
(For testing I’m using a desk light as a load and reduced the ON time to 30 seconds)
The Current, Voltage and Power sensors are working OK with the below example syntax in the Sensor.yaml file
state_topic: "tele/pow1/SENSOR"
value_template: '{{ value_json["ENERGY"]["Power"] }}'
Which looks more complicated than the one I have in the Automation. Does that offer any clues?
Cheers
Mark
Does it trigger with out the ON time?
Bit of a stab in the dark, leave the ON time bit out for now.
How about the following:
input_boolean:
shower_test:
icon: mdi:shower-head
automation:
- alias: Scrooge
trigger:
platform: mqtt
topic: "tele/pow1/SENSOR"
condition:
condition: template
value_template: '{{ value_json["ENERGY"]["Power"] }}'
above: 20
action:
service: input_boolean.turn_on
entity_id: input_boolean.shower_test
No, sadly that didn’t work. The automation failed and wouldn’t load. It’s a tricky one!
When you tried the previous example did you have it exactly how I wrote it or did you still have delays in the automation?
As far as I can see I have exactly that in my Automations
- id: ‘1543524529’
alias: Scrooge3
trigger:
platform: mqtt
topic: “tele/pow1/SENSOR”
condition:
condition: template
value_template: ‘{{ value_json[“ENERGY”][“Power”] }}’
above: 20
action:
service: input_boolean.turn_on
entity_id: input_boolean.shower_test
But ‘Scrooge 3’ doesn’t appear in the list of automations in the Overview. And I get the error below
Invalid config for [automation]: not a valid value for dictionary value @ data[‘condition’][0][‘condition’]. Got None
If I comment Scrooge 3 out there are no errors.
- id: '1543524529'
alias: Scrooge3
trigger:
platform: mqtt
topic: "tele/pow1/SENSOR"
condition:
condition: template
value_template: '{{ value_json["ENERGY"]["Power"] }}'
above: 20
action:
service: input_boolean.turn_on
entity_id: input_boolean.shower_test
And now with better formatting
Looks like you may have lost some formatting?
Got to my GitHub
Got into experimental folder
Click on turn_pump_on_off…yaml
Click on Raw
Copy and paste that text into your config.
Edit:
Looks like you have fixed your formatting as I posted.
This one must have the syntax correct.
value_template: '{{ trigger.payload_json.ENERGY.Power > "8" }}'
Whereas this one causes errors
value_template: ‘{{ value_json[“ENERGY”][“Power”] }}’
above: 20
Does it trigger the input_boolean ok then, when a lamp is plugged in?