For now I have 6 different automations for bathroom light, they are working fine. Now I want to cover one more scenario. Here is automation which I want to make better:
- id: '1538321511928'
alias: Bath off on door motion and light
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001e5d691
platform: state
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.motion_sensor_158d000224aa83
state: 'on'
- condition: state
entity_id: switch.wall_switch_right_158d000245c5ca
state: 'on'
action:
- delay: 0:0:1
- data:
entity_id: switch.wall_switch_right_158d000245c5ca
service: switch.turn_off
I want to use humidity sensor and turn off the light not in 1 second if there is hi humidity but in a couple of minutes. I do not want to make two automations, it seems to me that templates can help here.
Like if humidity is hi - then delay 180 sec
else delay 1 sec
Should I look for template in ‘action’ or in condition? In documentation i found only notification examples, so it did not help me.
Thank you, it worked. But if I leave it with 3 minutes and then again open the door (trigger that automation again) lights go off immediately
As I understand, if i trigger the automation second time - delay is just skipped, so I can not use it in this situation. Is there another option for delay?
Invalid config for [automation]: Entity ID {{ script.1540143367881 if states('sensor.humidity_158d00022833b3')|float > 60 else script.1542453568731 }} is an invalid entity id for dictionary value @ data['action'][0]['entity_id']. Got None. (See /config/configuration.yaml, line 118). Please check the docs at https://home-assistant.io/components/automation/
In general you want to avoid the situation where an automation might trigger while the actions are still running from a previous trigger. The usual way I handle that is to move the actions into a script. Then, in the automation action you first cancel the script (in case it’s still running from a previous invocation), and then start it. So, automation:
- id: '1538321511928'
alias: Bath off on door motion and light
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001e5d691
platform: state
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.motion_sensor_158d000224aa83
state: 'on'
- condition: state
entity_id: switch.wall_switch_right_158d000245c5ca
state: 'on'
action:
- service: script.turn_off
entity_id: script.turn_off_light
- service: script.turn_off_light
Hey man, a lot of things I learn from you. Thank you again, I did not think about stopping and then triggering the script. Tried it out - worked just how it should.
Yes, but you have a couple of errors in the template as you wrote it.
You either need to use states('sensor.humidity_158d0002279c7d'), which is preferred, or states.sensor.humidity_158d0002279c7d.states. The way you wrote it you were trying to convert an entire State Object to float, which would not work. Also, you have a stray % character. Lastly, you might want to include a timeout. So:
Note that in recent HA versions the default for a wait_template with a timeout is to continue the script if the timeout is exceeded. (It used to abort if that happened.)
Sorry for annoying. I still can not figure out how to prevent scenario when script is on (waiting for lower humidity) and then I go to bath again, then humidity gets lower then 60% and lights turn off while I am there
I would use condition (if there is no motion) but then script does not work when humidity is ok and lights should be turned off in 1 second.
Maybe I could count how long script is on and if more than 2 minutes (xiaomi morion sensor is on for 2 minutes after actual motion) then check the motion sensor. If less than two minutes - wait until 2 minutes are gone and then check motion sensor.
Say if I want too much from this automation. Unfortunately, I can not use recent one because my father or mother would be really confused going bathroom after someone.
This would wait until the humidity is less than 60%, and it’s been at least two minutes since the automation was triggered, and the motion sensor has stopped indicating motion. But if that doesn’t happen within 30 minutes of the automation being triggered, then the light would be turned off anyway.
Sorry, I was not clear
Firstly - our bathroom light is responsible for working fan too (I have no idea how to translate it, but it makes bathroom less wet. So main point - if humidity is hi - I need the lights to be on)
Secondly, I don’t want lights to turn off while someone is in bathroom and humidity gets from 65 to 55%.
With this code HA always will wait at least two minutes after me going away from bathroom. Here is what I would like to achieve:
I open the door (door sensor)
If humidity is less than 60% - turn light off in 1 second
If humidity is higher than 60% - wait for humidity sensor to get less than 60, BUT I do not want to come back in 5 minutes, when humidity is 65% and then be confused when lights get off. I just can not yet come up with solution.
Maybe I can use door sensor to abort the script, which is waiting for humidity to get less than 60%? So If I will go to bathroom while script is waiting, I will break it and light will not turn off while I am in bathroom even if humidity will get less than 60%
If not - that is fine. I will think couple of days on the algorithm.
And sorry for being not really clear - English is not my native language.
If door is opened (i.e., you’re leaving the bathroom), and the humidity is below 60%, then turn off the light and connected fan in one second.
If the humidity goes from 60% or above to below 60%, and the door is open (i.e., nobody is in the bathroom), then turn off the light and connected fan.
Do you think that would work for you? (Note, I don’t see where the motion sensor even has to be involved.)
If so, then:
- alias: Turn off light/fan when leaving non-humid bathroom
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d0001e5d691
to: 'on'
condition:
condition: numeric_state
entity_id: sensor.humidity_158d0002279c7d
below: 60
action:
- delay: 1
- service: switch.turn_off
entity_id: switch.wall_switch_right_158d000245c5ca
- alias: Turn off light/fan when humidity drops and nobody in bathroom
trigger:
platform: numeric_state
entity_id: sensor.humidity_158d0002279c7d
below: 60
condition:
condition: state
entity_id: binary_sensor.door_window_sensor_158d0001e5d691
state: 'on'
action:
service: switch.turn_off
entity_id: switch.wall_switch_right_158d000245c5ca
I have a few cameras running on a Blue Iris Server that feeds Home Assistant via a MQTT feed for the motion sensors.
3 Fire Tablets throughout the house running Fully Kiosk Browser on Fire Tablets.
Currently I have automation and scripts setup to go to full screen of that camera for 3 minutes on each of the Fire Tablets and then return to the base home assistant start page after 3 minutes. This is a static automation without conditions.
Please if I could receive assistance on:
Motion --> Full screen video pops up on Fully Kiosk Browser, need assistance with conditional statement/timer that keeps that full screen up if there is continued motion triggered (Currently it is set after 3 minutes to return back to the home screen regardless of future events)
Motion --> Full screen video pops up on Fully Kiosk, need assistance with a conditional statement that if there is any other motion triggered within 3 minutes of each other to bring up a different video url that includes all the cameras: http://192.168.87.66:81/mjpg/index/video.mjpeg. In addition, if there is persisted motion on any of the cameras to extend the video on the tablets rather than returning to the home screen.
Example: Front Door Motion, Full Screen Front Door Camera Video URL comes on Fire Tablets via Fully, 1 minute passes, Motion at Driveway --> I want at this point for a different URL to be sent to Fully Kiosk Browser that includes all the cameras (listed above).
Lastly, I have 2 of the Fire Tablets that go dim/screen off after no motion for 30 seconds or so. display.turn_on via Fully does turn on the screens. I’d like to be able to integrate display.turn_on throughout the video sequences above and not have them go dark.
Example of Current Automations/Scripts:
Front Door Motion Triggered – Scripts to pull up video on Kiosk Tablets
- alias: FD Motion
trigger:
platform: state
entity_id: binary_sensor.mqtt_front_door_motion
to: 'on'
action:
- service: homeassistant.turn_on
entity_id: script.fdimage
- service: homeassistant.turn_on
entity_id: script.motion_fd_alexa
- service: homeassistant.turn_on
entity_id: script.fdmotionlr
- service: homeassistant.turn_on
entity_id: script.fdmotionbr
- service: homeassistant.turn_on
entity_id: script.fdmotionmini
id: 86d5f5ca35c94f40a2f97e281e42e0d0
Script Example:
fdmotionlr:
sequence:
- service: display.turn_on
entity_id: display.living_room_tablet
- delay:
seconds: .3
- service: fully_kiosk.screensaver_stop
entity_id: display.living_room_tablet
- delay:
seconds: .3
- service: display.load_url
entity_id: display.living_room_tablet
data:
url: http://192.168.87.66:81/mjpg/FD/video.mjpeg
- delay:
minutes: 3
- service: display.load_url
entity_id: display.living_room_tablet
data:
url: http://192.168.87.68:8123/lovelace/Tablet
Any help is very much appreciated, thank you!