Help with mixed condition (I'm going crazy)

I’m trying tro write an automation to do the following:

if the camera sensor is above a certain value (trigger), the sun is down AND the led is off, AND me OR my so are home, turn on the led.

this is what i have in my automations.yaml:

- alias: 'Nightlights'
  trigger:
  - above: '100'
    entity_id: sensor.desirecam_motion
    platform: numeric_state
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: 'light.led_strip'
        state: off
      - condition: state
        entity_id: 'sun.sun'
        state: 'below_horizon'
      - condition: or
        conditions:
          - condition: state
            entity_id: 'device_tracker.lorenzo'
            state: 'home'
          - condition: state
            entity_id: 'device_tracker.ilaria'
            state: 'home'
  action:
  - data:
      entity_id: light.led_strip
    service: light.turn_on  
  id: '7515205246030'

But i keep getting errors, no matter what i change. if i remove the conditions completely it seems to work, so there may be something wrong with that…

2018-02-10 14:19:35 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: extra keys not allowed @ data['condition'][0]['conditions'][0]['state']. Got None
not a valid value for dictionary value @ data['condition'][0]['conditions'][0]['condition']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 126). Please check the docs at https://home-assistant.io/components/automation/

I’m following the docs here: https://home-assistant.io/docs/scripts/conditions/

try:

condition:
  condition: template
  value_template: >
    {% if  is_state('light.led_strip','on') and is_state('sun.sun', 'below_horizon') %}
      {% if is_state('device_tracker.lorenzo', 'home') or is_state('device_tracker.ilaria', 'home') %}
        True
      {% else %}
        False
      {% endif %}
    {% else %}
       False
    {% endif %}

Easier to read if you code… Should work for what you want.

1 Like

i love you