State_not in conditions?

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

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

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/

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!

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

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

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!

Ah! Should have known that. I was writing on my phone just from memory. That’s what the template dev page is for :slight_smile: Glad you got it worked out.

1 Like

Thanks Steve for your support! Without you I couldnt have figured out the last Mile to the solution! Have a great year!!!