It’s weird. Could you check the light’s state in Developer Tool
in Home Assistant when it happens?
The trace info you posted showed the light.switch_kitchen_0x00158d00054408ee
is already on
Thanks. You were right. The problem was not in automation or blueprint, it was in switch hardware. I reset the switch and it started working.
PROBLEM / BUG: Optional condition is not re-evaluated
Situation:
I have a trigger entity (presence sensor) and an illuminance sensor.
Problem:
automation is triggered on every trigger entity state change (good), BUT the illuminance sensor value is not re-evaluated anymore:
In detail:
- It’s dark. I enter the room, light (target entity) is being turned on. Good.
- Now after some time while still in the room and constantly triggering the automation (presence sensor/trigger entity) it’s getting bright so we jump over the illuminance sensor threshold.
- BUT the light is still and stays on!
- I need to either manually turn it off once or leave the room until the light gets turned off automatically (timeout).
- After that, on next automation trigger the illuminance sensor value is correctly re-evaluated and light stays off.
So it looks like only the trigger entity is monitored OR the illuminance sensor is only used ONCE (on first automation trigger).
We could have a deeper look at this by diving into the automation trace logs but hopefully you can confirm and fix this without more data.
@kevinxw: Let me know if you need more information, consider this as a bug you can confirm or maybe something with my automation configuration is totally wrong.
This behavior is exactly what I expected. It make no sense to me that if a people enter a room when it’s dark, then the light got turned on so it’s no longer dark enough, and the light got turned off… you will find yourself in a loop of the “light on → light off → light on” situation.
This blueprint is great! Only thing I’d love to add, is being able to send data to the turn_on service. Specifically, I’d love to be able to set the brightness of the lights to a number which is derived from a calculation based off of my light sensor. So that when it’s very dark (middle of the night), it sets brightness to 10%, but when it’s just slightly dark, set it to 30%.
Something like (sensor.light_sensor.state / 10) * 3
OK. When I enter the room and it’s dark, light turns on. But NOW I
a) open the blinds or
b) switch on another light manually or
c) …
and it’s not dark anymore, but light is still on.
It also depends where you locate the illuminance sensor.
While I understand the basic deadlock situation, on the other hand there are use cases where it is annoying. Therefore I propose to add a „take optional brightness sensor into account“ option, turned off by default. If activated, entity is used together with trigger entity to decide if target entity will be changed.
Is it possible to implement this please @kevinxw ?
Better use integrations like „Adaptive Lighting“ for this.
Cool, thanks - I’ll look into it.
This sounds like a great feature as I have dimmable lights. I will add it when I have time.
It makes sense in your case. I will implement a toggle later.
Great to hear! Thank you very much. I´m pleased to help by testing a new version.
This is a bit more complicated than I expected. It will not be a simple flag to tell the automation to always respect the illuminance sensor. If I do this, then the moment the light is turned on, illuminance sensor will return a value above the threshold, then the light will be off immediately. You will see the light flashing in this case. I need to think about some sort of timeout in this case, which means more conditions to consider.
Hello,
I’m quite new to HA and really appreciate the blueprints, what a great idea to be able to share automations! I’m hoping you might be able to help me as I try to figure out where I’m going wrong with the automation.
What I’d like to do is turn on a light switch when a contact sensor is open and then turn the switch off when the sensor is closed. If I’m understanding the automation correctly this should be able to be done inside of the single automation and I shouldn’t need to create a second “off” automation.
Share my yaml file that was created from the automation
alias: Late Night Snack Lights
description: ''
use_blueprint:
path: kevinxw/state_based_entity_control.yaml
input:
trigger_entity: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
trigger_entity_state: 'On'
target_entity: light.living_room_lamp
trigger_timeout: '00:05:00'
target_entity_state: none
target_entity_action_on: homeassistant.turn_on
target_entity_action_off: homeassistant.turn_off
trigger_entity_state_off: 'Off'
target_entity_off: light.living_room_lamp
Appreciate any help/guidance you might be able to offer, thank you!
Hi James,
I believe you only need the following
alias: Late Night Snack Lights
description: ''
use_blueprint:
path: kevinxw/state_based_entity_control.yaml
input:
trigger_entity: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
target_entity: light.living_room_lamp
trigger_timeout: '00:05:00'
This will turn off your light 5 minutes after your door is closed. Let me know if it works.
Thanks for the advise, Kevin. I think what I was looking for was a way to turn off the light when the sensor is closed rather than a timeout, would that still be possible with this blueprint?
Yes. Just put 0 to the timeout.
Hi - I’m facing issues using entities in the automation but direct values work.
I’m trying to use ‘Illuminance Below’ with input_number however the automation fails conditions. If I replace the entity with a value it works.
I’m getting a similar error using an input_number for trigger timeout. The automation complains it’s not in the correct format, e.g. ‘HH:MM’ but it is. If I use ‘10’ in the automation it works, but ‘00:10’ in the input_number complains:
Error: offset input_text.motion_attic_timer should be format 'HH:MM', 'HH:MM:SS' or 'HH:MM:SS.F'
Are input_number’s supported in the automation or do I need to use values? Was hoping to create a dashboard to easily change the values.
Thanks for any help - awesome blueprint by the way
Hi kevinxw
I have 2 Motion Sensor for the Balcony’s door and lamp.
I set
1.Motion Sensor2 for cat.When Sensor2 detected a motion the door will open 10%.
2.Motion Sensor1 for human.When Motion Sensor1&2 detected a motion the door will open 60% and turn on light.
But now when Sensor2 or Sensor1 detected a motion the door alway open 10%.How to except Automation 1 when Automation 2 action?
Hi,
I am not sure why Illuminance Below doesn’t work. Do you see any error when you use the input_number?
For trigger timeout, it should be input_text as the error states. It’s not an input number.
I think your requirement is not related to this blueprint. But you can create such an automation from scratch:
- Create a blank automation;
- Put both sensor1 and sensor2 as two separate entity triggers, leave the entity state as blank;
- Put the rest of the logic in your action using “choose”. You will have something like this:
alias: Door Automation
description: ''
mode: restart
trigger:
- platform: state
entity_id: sensor1
- platform: state
entity_id: sensor2
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: sensor1
state: 'on'
sequence:
- service: open_door_60%
- conditions:
- condition: state
entity_id: sensor2
state: 'on'
sequence:
- service: open_door_10%
default:
- service: close_door