I have this automation, but it doesn’t work. I don’t know why. Both conditions are true at my tests. This means, it was 21:30 o’clock and the switch was “on”.
What’s strange: If I programm these two conditions without “and” it seems to work.
So my question is, what is the difference between two conditions which stands one after another and two conditions combined with “and”?
The second question is, what can I do to make my automation runable?
I’m sorry but if you have an example in front of you and cannot spot the error, you probably should not write code manually and stick to the automation editor.
Just remove “-” from “- condition: and” but make sure its indentation remains the same as conditions.
Answering your question
could you post the whole condition bit that “seems to work”?
The answer is already in the docs - if you use proper syntax, there is no difference.
However, if you don, the result can be anything.
Ok, I saw I had made another “and” condition with the automation editor and there it worked. There is also a “-” in the line with “condition: and” and it works!
Here is the code from these other automation:
- id: '1581087409087'
alias: Keller Flur Licht An Nacht
description: ''
trigger:
- entity_id: binary_sensor.bewegungsmelder_keller_flur
platform: state
to: 'on'
condition:
- condition: and
conditions:
- after: '20:00:00'
before: 06:00:00
condition: time
- condition: state
entity_id: input_boolean.dummy_switch_keller_flur
state: 'on'
action:
- brightness_pct: 30
device_id: 81cdf359082e4a3fa678df8cf3cc9fcf
domain: light
entity_id: light.licht_keller_flur
type: turn_on
And that is the code from the first automation that seems to work without “and”:
well, to me the main source of HA knologe is the official documentation.
and yes, there are bugs and limitations in UI editors, that’s probably why I don’t use them
So are you saying that automation “Nachtlicht EG Flur” doesn’t work and “Keller Flur Licht An Nacht” does? By “doesn’t work” you mean you can see no action performed?
Could you create the same automation as “Nachtlicht EG Flur” but with action from “Keller Flur Licht An Nacht”? For testing purposes you can set a different after time.
yeah, that’s exactly what the docs say - if you need to “and” several conditions, just put them next to each other
If I understand you correctly, for me I can work without “and” condition. I would only need it, if I would use “and” and “or” conditions at the same time.
that’s correct.
There are several reasons why you can see no actions performed. One is wrong condition. Another is issues in action.
To debug it, make your automation as simple as possible and get it work. Then gradually add conditions and keep on checking.
I think I have found the problem. The lights I control are both installed on one Homematic IP switch and normally I turn them off with this switch.
Only if I want to have a night light then I turn off one with zigbee and the other stay on with low brightness.
@Ahmad: I tested what you asked for. If I switched on the lights with the homeatic IP switch manually, it doesn’t work. If I swithched on the EG Flur 2 light manually with zigbee command (before the Homematic switch was switched to on and the lights became “off” command over zigbee protocol)
it worked.
Therefore I use the Homematic IP switch as trigger and not the zigbee light. Now it works.
Why have the ‘and’ in there? Conditions are ‘and’ by default so there is no need to put it in there in your simple automation. You would only need to use the ‘and’ condition when creating more complex automation conditions with combinations of ‘and’ and ‘or’.