Automation help needed please 🙏

I will be greatful if someone csn please tell and help me in identifying what I am doing wrong

Inam trying to keep the bathroom light on during a shower which disables the auto off automation

However, i keep getting this message

Message malformed: invalid template (TemplateSyntaxError: unexpected ‘}’) for dictionary value @ data[‘conditions’][1][‘value_template’]

alias: Bathroom Light on During Shower
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.bathroom_temperature_and_humidity_sensor_humidity
conditions:
  - condition: template
    value_template: >-
      {{ state('sensor.bathroom_temperature_and_humidity_sensor_humidity') |
      float >
      (state('sensor.my_bedroom_temperature_and_humidity_sensor_humidity') |
      float + 5) }}
  - condition: template
    value_template: >-
      {{ states('sensor.bathroom_temperature_and_humidity_sensor_humidity') |
      float >
      (states('sensor.my_bedroom_temperature_and_humidity_sensor_humidity') |
      float + 15) }
actions:
  - action: script.turn_off_lights_delayed
    data:
      delay: 90
  - action: script.disable_auto_off_lights
    data: {}
mode: single

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Why do you have two identical triggers?

This is the condition throwing the error:

You are missing a } at the end. As the error says:

It expected two.

I have added the 2nd }
I have also removed the 2nd trigger

It’s saying both conditions did not pass

This is what i am trying to do.

timeout if the bathroom humidity is more than 5% above my Bedroom humidity, and lights won’t automatically turn off at all if the bathroom humidity is >15% above the bedroom.

Post it as code, read the link posted before.

alias: Bathroom Light on During Shower
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.bathroom_temperature_and_humidity_sensor_humidity
conditions:
  - condition: template
    value_template: >-
      {{ state('sensor.bathroom_temperature_and_humidity_sensor_humidity') |
      float >
      (state('sensor.my_bedroom_temperature_and_humidity_sensor_humidity') |
      float + 5) }}
  - condition: template
    value_template: >-
      {{ states('sensor.bathroom_temperature_and_humidity_sensor_humidity') |
      float >
      (states('sensor.my_bedroom_temperature_and_humidity_sensor_humidity') |
      float + 15) }
actions:
  - action: script.turn_off_lights_delayed
    data:
      delay: 90
  - action: script.disable_auto_off_lights
    data: {}
mode: single

There is still one } missing.

Why do you have one condition with +5 and one with +15 ?

This is the reason i above

There are multiple times where you are using state() instead of the correct function states().

But I think there’s a bigger issue in terms of understanding what your automation is doing…

As shown in Post #9 the automation works as follows:

  1. The trigger fires when any attribute or the state of the bathroom...humidity sensor changes.

  2. The conditions check if bathroom...humidity is both 5% and 15% greater than my_bathroom...humidity. This is redundant because anything that is 15% greater is always going to pass the 5% test too but not everything that passes the 5% test will pass the 15% test…

  3. Both scripts are activated.

It seems likely that what you actually want is two triggers and a branching action like If/Then or Choose.

And that reason makes no sense.

Ok. Thanks for your imput. Forgive me for wasting your time. Hopefully I’ll see of there is someone i can pay to help me understand better and possibly not put me in this position again.

You don’t need to pay anyone, we just need a clear picture of the goals before we can give you specific help to reach them.

Is you goal for this automation:

  1. That the “delay” script is only fired when the the difference in humidity is more than 5 percentage points
  2. That the “disable” script is only fired when the the difference in humidity is more than 15 percentage points.

If that is what you want, you will need to branch the actions using an If/Then or Choose action.

No worries. Thanks for reaching out again.
Someone has offered to sort it out.

I am a novice and won’t pretend to be as clever as you.

If future, i may seek help again if i need. I am greatful

Unbelievable…