TCoker
(Smooth OP)
November 30, 2024, 6:03am
1
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
tom_l
November 30, 2024, 6:20am
3
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:
TCoker:
unexpected ‘}’
It expected two.
TCoker
(Smooth OP)
November 30, 2024, 7:03am
4
I have added the 2nd }
I have also removed the 2nd trigger
It’s saying both conditions did not pass
TCoker
(Smooth OP)
November 30, 2024, 7:06am
5
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.
Hellis81
(Hellis81)
November 30, 2024, 7:22am
6
Post it as code, read the link posted before.
TCoker
(Smooth OP)
November 30, 2024, 7:51am
9
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
Hellis81
(Hellis81)
November 30, 2024, 11:22am
10
There is still one }
missing.
Why do you have one condition with +5
and one with +15
?
TCoker
(Smooth OP)
November 30, 2024, 12:23pm
11
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:
The trigger fires when any attribute or the state of the bathroom...humidity
sensor changes.
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…
Both scripts are activated.
It seems likely that what you actually want is two triggers and a branching action like If/Then or Choose .
Hellis81
(Hellis81)
November 30, 2024, 5:14pm
13
And that reason makes no sense.
TCoker
(Smooth OP)
November 30, 2024, 5:26pm
14
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:
That the “delay” script is only fired when the the difference in humidity is more than 5 percentage points
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.
TCoker
(Smooth OP)
November 30, 2024, 6:12pm
16
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