YAML automation

I’m trying to add a condition to turn off heating after 2 hours with no motion detected.

Here is what I have:
conditions:
- condition: binary_sensor
entity_id: binary_sensor.hue_motion_sensor_1_motion
state: off
time_since_last: “>= 120”

But Studio Code Server says " Value must be state" on the condition line and Property time_since_last is not allowed on the last line.

Any idea?

Please format your code blocks properly as directed in Questions Guideline #11, so we can tell if the syntax spacing is correct.

That’s not a thing.

Neither is that.

Full list of available conditions.

Direct link to docs for the condition you are probably trying to use.

Notice in all the examples that the values following the state key are surrounded by quotes…

1 Like

Are you just guessing or are you using chatgpt?
Why not use the GUI until you get used to the syntax?

2 Likes

I bet the YAML syntax spacing is off as well.
That’s what this error often actually is…

You got me… not ChatGPT tough.

I’ve installed a local LLM and obviously, it has limitations.

Here is what I’m trying to do.
I already have an automation that starts my heating in the morning at 8:00 and turns it off at 1:00.

I’m trying to include 2hours no motion detected then turn off. Which is why those lines were suggested to be added.

Is it safe to post my automation? Do I have to mask any infos prior to that?

Thanks for the assistance.

Ok, based on the provided link for “conditions”, here is what I’ve updated:

condition: state
entity_id: binary_sensor.hue_motion_sensor_1_motion
state: off
time_since_last: “>= 120”

The first error disappeared.

I’ll try to figure out the 2hours with no motion.

Got it.

How does that look:

conditions:
or:
- condition: state
entity_id: binary_sensor.hue_motion_sensor_1_motion
state: off
for:
minutes: 120
- condition: time
after: “00:59:59”

Please format your code blocks properly as directed in Questions Guideline #11, so we can tell if the syntax is correct.