Hi,
I am struggling to get my automation to work. I would like to to turn off the plug on the microwave when:
- The microwave has been on for 2 minutes and no power has been detected (wattage has been below 2w)… in other words, it’s been turned on but not used.
- The energy has been below 2 for 30 seconds. The plug will stay active until it detects wattage has fallen to 2w or below and turn off. In other words, after the microwave has finished, it will wait 30 seconds then turn off.
Here is what I currently have but it just turns off after 2 minutes regardless if power has been detected or not.
- id: '1591551546746'
alias: Turn off microwave
description: ''
trigger:
- device_id: a130587565f7488886c73b6aa437fd27
domain: switch
entity_id: switch.kitchen_microwave_power
for:
hours: 0
minutes: 2
seconds: 0
platform: device
type: turned_on
- below: 2
device_id: a130587565f7488886c73b6aa437fd27
domain: sensor
entity_id: sensor.kitchen_microwave_daily_energy
for:
hours: 0
minutes: 0
seconds: 30
platform: device
type: value
condition: []
action:
- device_id: a130587565f7488886c73b6aa437fd27
domain: switch
entity_id: switch.kitchen_microwave_power
type: turn_off
You probably need to use two different automations, since the triggers require different conditions.
I’m not as familiar with the new, fancy “device” triggers, but this should do what you want:
- trigger:
- platform: state
entity_id: switch.kitchen_microwave_power
to: 'on'
for:
minutes: 2
condition:
- condition: numeric_state
entity_id: sensor.kitchen_microwave_daily_energy
below: 2
action:
- service: switch.turn_off
entity_id: switch.kitchen_microwave_power
- trigger:
- platform: numeric_state
entity_id: sensor.kitchen_microwave_daily_energy
below: 2
for:
seconds: 30
action:
- service: switch.turn_off
entity_id: switch.kitchen_microwave_power
The first automation will turn the switch off when it has been on for 2 minutes, if at that time (i.e., 2 minutes after the switch goes on) the energy is currently below 2. If you only want the switch to be turned off if the energy was below 2 for the whole 2 minutes, then add the following to the condition:
for:
minutes: 2
The second automation will turn the switch off when the energy has been below 2 for 30 seconds (after it had been 2 or above.)
Thanks so much for your reply, I really appreciate that.
Sorry, I should have wrote an update that I think I was able to get his to work after playing around with it most of the day. It’s under one automation but I haven’t fully tested it yet, I am hoping it works. Do you see any issues?
- id: '1591619920715'
alias: Turn off Microwave
description: 'Turn off microwave if it has been turned on and not used for 3 mins.
AND turn it off after it has been used ONLY when power is below 25w after 1.5
mins. '
trigger:
- device_id: a130587565f7488886c73b6aa437fd27
domain: switch
entity_id: switch.kitchen_microwave_power
for:
hours: 0
minutes: 3
seconds: 0
platform: device
type: turned_on
- below: 25
device_id: a130587565f7488886c73b6aa437fd27
domain: sensor
entity_id: sensor.kitchen_microwave_wattage
for:
hours: 0
minutes: 1
seconds: 30
platform: device
type: value
condition:
- below: 25
condition: device
device_id: a130587565f7488886c73b6aa437fd27
domain: sensor
entity_id: sensor.kitchen_microwave_wattage
type: is_value
action:
- device_id: a130587565f7488886c73b6aa437fd27
domain: switch
entity_id: switch.kitchen_microwave_power
type: turn_off