I have the below automation: a window/door sensor when is triggered (open door) turns on a switch; when I close the door it turns the switch off.
The automation is strangely working:
when I open the door the light turns ON, then OFF and then ON again
when I close the door the lights turns OFF then ON again then OFF
WHy is that?
p.s. the sensor is a xiaomi window/door
; the switch is a broadlink tc2 which receives a signal by a broadlink RMPRO
- alias: "Storageroom light on"
initial_state: 'on'
trigger:
- platform: state
from: 'off'
to: 'on'
entity_id: binary_sensor.door_window_sensor_158d000111a31c
action:
service: switch.turn_on
entity_id: switch.storageroom
- alias: "Storageroom light off"
initial_state: 'on'
trigger:
- platform: state
from: 'on'
to: 'off'
entity_id: binary_sensor.door_window_sensor_158d000111a31c
action:
service: switch.turn_off
entity_id: switch.storageroom
#
Try removing initial_state maybe?
anon35356645:
initial_state: ‘on’
why? I thought that is just the command to have the automation ON when HASS starts
Otherwise when I restart HASS the automation is OFF, and have to remember to put ON.
SHould have an effect on my problem??
Mike_D
(Mike D.)
May 5, 2017, 3:00pm
4
I have a similar automation that works. Hope it helps.
###Pantry Light###
- alias: Turn Pantry Light on
trigger:
platform: state
entity_id: binary_sensor.pantry_door_opened
to: 'on'
action:
service: homeassistant.turn_on
entity_id: light.pantry_light
data:
brightness: 255
- alias: Turn Pantry Light off
trigger:
platform: state
entity_id: binary_sensor.pantry_door_opened
to: 'off'
action:
service: homeassistant.turn_off
entity_id: light.pantry_light
removing the from would affect?
Strange I’ve never put any initial_states in my automations and my automations are always on when I restart HA. As far as I know they default to on, wouldn’t be much good as automations if they defaulted to off
However that aside the only other thing that’s odd with your setup is the entity id being after the from to statements, tho’ I don’t see what difference it would make.
Mike_D
(Mike D.)
May 5, 2017, 3:04pm
7
To be honest i don’t know. From off to On
and to On
I would think would produce the same outcome in theory.
I changed that, and removed the FROM. Let’s see
no nothing also with those two changes, the problem persists
accelle
(accelle)
May 5, 2017, 8:22pm
10
have you checked the xiaomi window sensor logs? It usually triggers twice on mine because of the way I installed it.
ahhh yes mine two, twice.
how did you install it??
How to solve this??
chrio
May 5, 2017, 8:54pm
12
It might be sending two pulses instead of one, in that case you could try adding a minimum time the new state must be active for, like this:
- alias: "Storageroom light on"
initial_state: 'on'
trigger:
- platform: state
from: 'off'
to: 'on'
for:
seconds: 2
entity_id: binary_sensor.door_window_sensor_158d000111a31c
If it works, you get a delay, but it should stop blinking.
accelle
(accelle)
May 5, 2017, 9:15pm
13
It’s installed front facing, top and bottom instead of side to side. It’s not a big deal for me since it’s only triggering a chime and still reporting a correct end state.
1 Like
ahh you mean physical installation.
YES! That is it!