Attempting to use this code to trigger a light on and off depending on the trigger id:, then using the appropriate condition: trigger, but I can’t seem to get it right. Prior to the introduction of condition:trigger in HA I had this broken out into 2 automations, one for turning the light on, another for turning it off.
I looked for an example in the docs, but could not find anything.
Using the automation above, light will be turned ON if light level is below 175. (This will not check the state of the light (ON/OFF) before executing the action.
Another alternative if you want to add condition of the state of light prior to executing the action-
Also these conditions will never allow your automation actions to run. Conditions are AND logic by default. You can not have the light on and off at the same time. You can’t have both triggers being true at the same time either.
condition:
- condition: or
conditions:
- condition: and # porch light on and trigger id off
conditions:
- condition: state
entity_id: light.front_porch
state: 'on'
- condition: trigger
id: 'off'
- condition: and # OR porch light off and trigger id on
conditions:
- condition: state
entity_id: light.front_porch
state: 'off'
- condition: trigger
id: 'on'
If you can’t work out why it won’t work, fair enough post that. But deliberately posting code you know is not correct without fixing it first just wastes everyone’s time.
(and note, I prefer to use room occupancy variables - then multiple things and trigger those on or off, then have automations trigger based on that, rather than having a sensor directly trigger an automation)