It might be a trivial mistake, but I cannot figure this out.
I want this automation NOT to trigger if the group livingroomlights is already on (the lights might be already on with a different setting than the scene this automation turns on)
I tried both with a normal state condition and the template condition below (which renders fine in the template area, showing True when off).
The condition tests true in every case, regardless of the state of the group, and the lights go on (the other group condition works fine).
Does anybody see an obvious mistake here?
- alias: PreSundown
trigger:
platform: sun
event: sunset
offset: '-00:25:00'
condition:
condition: and
conditions:
- condition: state
entity_id: group.all_devices
state: home
- condition: template
value_template: {{ is_state("group.livingroomlights", "off") }}
action:
- service: scene.turn_on
entity_id: scene.full_bright
I do use a scene in the action. I simply do not want to apply the full_bright scene if any of the lights in that group are already on, potentially in the âwrongâ state.
I tried the solution you proposed, and it did not work. Thatâs why I resorted to the template condition, with no joy either
Remember that if you use the condition on the entire group (group.livingroomlights), It will only have state âoffâ if every entity (including switches) in that group is switched off. Perhaps itâs better to use 1 seperate entity_id which is often on (I use this myself as well).
Yep, thatâs going to be my next test as a fallback. But I am aware of the way group worksâŚI specifically want the automation to stop if any member of the group is not off. But even if I verify that the group is âonâ, the action executes.
Hence my cry for help it simply does not make any sense and the problem must lie in something else that I cannot think of
.
Now, trying to revert back to the state condition, my config is invalid, unless i use âoffâ in quotes.
And in that case, it executes the action even if the group is âonâ.
The worst thing is that this is an invalid config (see below), while âoffâ is accepted (but does not work)
2017-11-11 17:59:52 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: extra keys not allowed @ data[âconditionâ][0][âstateâ]. Got None
not a valid value for dictionary value @ data[âconditionâ][0][âconditionâ]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 131). Please check the docs at Automation - Home Assistant
Youâre rght about the quotes, I made a mistake. my apologiesâŚ
Which Hass version are you usinng?
This has been working fine for me (currently on 0.57.1):
- alias: 'Lights on when entering after sunset'
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d000120dcd4
to: 'on'
condition:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: state
entity_id: light.hall_way
state: 'off'
action:
service: scene.turn_on
entity_id: scene.evening
I am on 0.55 (updates entail a lot of recompiling of some dependencies, so sometimes I lag behind), but in the release notes of 56 and 57 I saw nothing that looked like a bugfix for this.
Anyway, I will upgrade now.
Thereâs no reason the way you have it shouldnât work. Itâs hard to tell for sure but in your first post it looks like the indentation is off under the conditions: part, looks like a single space instead of 2. That could be causing the conditions to be ignored?
I believe that as long as the list is indented, itâs fine. I tried with two spaces though, still no joy.
Also updated to 57.2, no joy.
With the code below, and the group âonâ, verified in âdev-statesâ, triggering the automation executes the action, despite the âandâ condition should evaluate false.
Iâm scratching my head here⌠It cannot be a bug, it would be too big for not having been caught before.
- alias: PreSundown
trigger:
platform: sun
event: sunset
offset: '-00:25:00'
condition:
condition: and
conditions:
- condition: state
entity_id: group.all_devices
state: home
- condition: state
entity_id: group.livingroomlights
state: 'off'
action:
- service: scene.turn_on
entity_id: scene.full_bright
I tried changing the othe condition to ânot_homeâ and it still runs the action, despite me being home.
I checked the syntax for the condition several times⌠I literally copy pasted it from another double state end that worksâŚ
I tried quoting the entities names as well (the automation documentation examples have quotes for all now, not sure if it was like that in the past, those are the oldest automations that I have) but it still behaves exactly in the same way.
But⌠I just realized one thing.
I triggered another known-working automation, with a condition on my presence that - since I am home - should be NOT met, and it runs the action.
Specifically, this one, runs even if I am at home (but not when it actually triggers naturally and I am at home)
- alias: Vero Arrives
hide_entity: False
trigger:
platform: state
entity_id: device_tracker.vero
to: home
condition:
- condition: state
entity_id: device_tracker.mike
state: not_home
action:
- service: notify.jarvismike
data:
message: 'Vero is now home, sir.'
And in the following, the action does not run even if I trigger it manually (itâs not one of the listed day - ignore the fact that is an âorâ with a single condition. It works, itâs a leftover when I had another condition)
- alias: RoombaTueThuSat
hide_entity: False
trigger:
platform: state
entity_id: group.all_devices
to: not_home
action:
- condition: or
conditions:
- condition: time
# At least one of the following is required.
after: '08:00:00'
before: '16:00:00'
weekday:
- tue
- thu
- sat
- service: script.turn_on
entity_id: script.run_roomba
- service: notify.jarvismike
data:
message: 'Roomba started'
Could it be that when triggering an automation manually for testing, some of the conditions are not evaluated correctly?
I will probably post an issue on github for this, just in case.
All states have to be quoted I would say after taking a look al all my automations with use of a state. Entity idâs wihout quotes.
How about you try changing the entity id in a single device instead of a whole group (for testing purposes, just to make sure the problem is not in the group).
Youâre very welcome, I know how frustrating it can be when âsimpleâ things just will not work as expected.
AhhâŚyea force triggering an automation ignores conditions. Has been like that for a while now, I believe itâs intentional. I didnât realize thatâs what you were doingâŚ