jjmkimera
(Jürgen Müller)
January 5, 2019, 12:05am
1
HI
is there any condition to check values in automations
and set the condition uneuqal?
or is not state?
I tried state_not but it always throws me errors!
My Code in automations.yml
Thanks a lot for your help!
- id: '1545492112345'
alias: Dash_Alarm_on
trigger:
- entity_id: input_boolean.alarmanlage_dash
platform: state
from: 'off'
to: 'on'
condition: []
action:
- service: automation.trigger
data:
entity_id: automation.fenstercheck_badezimmer
- condition: numeric_state
entity_id: climate.badezimmer
value_template: '{{ state.attributes.temperature }}'
state_not: '12'
- service: media_player.alexa_tts
data:
entity_id: media_player.kuche
message: Alarmanlage eingeschaltet
You want something like
value_template: '{{ state.attributes.temperature != 12 }}'
The exact syntax might change depending on what data type the sensor is outputting.
1 Like
jjmkimera
(Jürgen Müller)
January 5, 2019, 12:55am
3
Thanks for the fast repsponse! Unfortuantely it still throws me errors.
The sensor will throw a numeric_state the actual temperature which is set in my thermostat
Any ideas?
Can you show the errors please.
When I mentioned data type I was referring to string/integer/float
jjmkimera
(Jürgen Müller)
January 5, 2019, 1:01am
5
Here we go:
Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->action->0->condition. (See /config/configuration.yaml, line 76). Please check the docs at https://home-assistant.io/components/automation/
jjmkimera
(Jürgen Müller)
January 5, 2019, 1:07am
6
My complete Automation:
TEST TEST TEST
- id: '1545123456789'
alias: Testautomatisierung
trigger:
- entity_id: input_boolean.alarmanlage_dash
platform: state
from: 'off'
to: 'on'
condition: []
action:
- condition: numeric_state
entity_id: climate.badezimmer
value_template: '{{ state.attributes.temperature != 12 }}'
- service: media_player.alexa_tts
data:
entity_id: media_player.kuche
message: Fenster offen!
SteveDinn
(Steve Dinn)
January 5, 2019, 2:02am
7
If you’ve changed to use a value_template for the condition, I think you now have a “condition: template” instead of a “condition: numeric_state”, so change that and remove the entity_id to get
action:
- condition: template
value_template: '{{ climate.badezimmer.attributes.temperature != 12 }}'
1 Like
jjmkimera
(Jürgen Müller)
January 5, 2019, 10:11am
8
Hi SteveDinn,
Your proposal seems to be almost there, it doesnt throw any errors any more.
Remark: the “temperature” attribute from “climate.badezimmer” is set to “12” for test reason
Unfortunately this code doesn’t execute the Action (Say on my Echo “Fenster geschlossen”):
action:
- condition: template
value_template: '{{ climate.badezimmer.attributes.temperature != 12 }}'
- service: media_player.alexa_tts
data:
entity_id: media_player.kuche
message: Fenster geschlossen
Whereas this code works and executes the action:
action:
- condition: numeric_state
entity_id: climate.badezimmer
value_template: '{{ state.attributes.temperature }}'
above: 13
below: 30
- service: media_player.alexa_tts
data:
entity_id: media_player.kuche
message: Fenster geschlossen
Any ideas why?
Thanks so much for your help! Really appreciate it
jjmkimera
(Jürgen Müller)
January 5, 2019, 8:02pm
9
Solution FOUND:
The Code looks like this:
action:
- condition: template
value_template: '{{ states.climate.badezimmer.attributes.temperature != 12 }}'
- service: media_player.alexa_tts
data:
entity_id: media_player.kuche
message: Fenster im Wohnzimmer sind noch offen.
We missed a states. in front of the entity id!
SteveDinn
(Steve Dinn)
January 6, 2019, 5:23pm
10
Ah! Should have known that. I was writing on my phone just from memory. That’s what the template dev page is for Glad you got it worked out.
1 Like
jjmkimera
(Jürgen Müller)
January 7, 2019, 11:15am
11
Thanks Steve for your support! Without you I couldnt have figured out the last Mile to the solution! Have a great year!!!