Not home and not not_home

Hi, so I have an automation that kicks at times if you’re not home but I can’t use ‘not_home’ because of configured zones (I think). In Condition, for ‘state’, can I have state: not home or state: !home instead of state: not_home to catch all cases where presences is not ‘home’?

Thanks

could you post your automation here?

use condition: template instead of state

Here’s one example of such situation:

Basically kids have a webhook to start the heating in advance in their room but if they’re not home 30 minutes after they turned the heat on, it dials it back to 15C.

- id: '1578349139030'
  alias: Timer expiré - Chauffage Catherine
  description: ''
  trigger:
  - event_data:
      entity_id: timer.chauffage_catherine
    event_type: timer.finished
    platform: event
  condition:
  - condition: state
    entity_id: person.catherine
    state: not_home
  action:
  - data:
      temperature: 15
    entity_id: climate.neviweb130_climate_catherine
    service: climate.set_temperature
  - data:
      temperature: 15
    entity_id: climate.neviweb130_climate_cath_toilette
    service: climate.set_temperature

So should it become?

- id: '1578349139030'
  alias: Timer expiré - Chauffage Catherine
  description: ''
  trigger:
  - event_data:
      entity_id: timer.chauffage_catherine
    event_type: timer.finished
    platform: event
  condition:
  - condition: template
    value_template: "{{ not is_state('person.catherine', 'home') }}"
  action:
  - data:
      temperature: 15
    entity_id: climate.neviweb130_climate_catherine
    service: climate.set_temperature
  - data:
      temperature: 15
    entity_id: climate.neviweb130_climate_cath_toilette
    service: climate.set_temperature

Yep. Every other trigger or condition can ultimately be expressed as a template…they’re very flexible.

If you prefer state conditions, you can create a template binary sensor with the same value_template and test its state in condition (should be on).

Ok, thank you both.

Can’t make it work :frowning: This:

binary_sensor:
  - platform: template
    sensors:
      sylvain_away:
        value_template: "{{ not is_state(‘person.sylvain’, ‘home’) }}"

Gives me that when I run check config:

Configuration invalid

Invalid config for [binary_sensor.template]: invalid template (TemplateSyntaxError: unexpected char ‘‘’ at 16) for dictionary value @ data[‘sensors’][‘sylvain_away’][‘value_template’]. Got ‘{{ not is_state(‘person.sylvain’, ‘home’) }}’. (See ?, line ?).

person.sylvain do exists. Don’t know what I’m doing wrong, help?

Thanks

replace these fancy single quotes with proper ones. Or (better) copy my code by clicking on Copy to clipboard sign (top-right corner of code frame)

Thanks! That was quick :slight_smile: