Conditions and OR statements

Hi

I’m fairly new to Hass.io so bear with :slight_smile:

I have a house full of tradfri lights which I want to come on when the sun sets but only if either I’m home or my partner is home. At the moment, I have an automation which is working if we are both home…but that’s the problem, it requires we are both home. So I need to use a condition as an OR instead of AND but I keep getting configuration file errors. Here is my YAML:

- id: '1554383174732'
  alias: Sunset
  trigger:
  - event: sunset
    platform: sun
condition:
  condition: or
  conditions:
    - condition: state
      entity_id: 'person.jess'
      state: 'home'
    - condition: state
      entity_id: 'person.kieran'
      state: 'home'
#  condition:
#  - condition: state
#    entity_id: person.jessica
#    state: home
#  - condition: state
#    entity_id: person.kieran
#    state: home

But now I get the following when validating the config file:

Error loading /config/configuration.yaml: while parsing a block collection in "/config/automations.yaml", line 1, column 1 expected <block end>, but found '?' in "/config/automations.yaml", line 16, column 1

I’m really not sure where I’m going wrong. You can see my original AND condition has been commented out.

Any help appreciated :slight_smile:

Thanks

It’s an indentation issue, use this; (btw the action is missing, will not work without)

- id: '1554383174732'
  alias: Sunset
  trigger:
  - event: sunset
    platform: sun
  condition:
    condition: or
    conditions:
    - condition: state
      entity_id: 'person.jess'
      state: 'home'
    - condition: state
      entity_id: 'person.kieran'
      state: 'home'
   condition:
   - condition: state
     entity_id: person.jessica
     state: home
   - condition: state
     entity_id: person.kieran
     state: home
1 Like

Thanks Pippyn, that appears to have worked! I didn’t realise indentation was so important so will read up on it.

My config file is checking out okay now! :slight_smile:

Just need to wait a few hours now :rofl:

Another issues I’m having (don’t want to put up a seperate post) is that I have a set of 4 kitchen lights which I have grouped in Hass.io as group.kitchen. I have set up the Alexa integration via Home Assistant Cloud but when I ask Alexa to “set the kitchen lights” to say 80%, she will reply saying “kitchen lights doesn’t support this”… any way around this?

Thanks again for the help :slight_smile:

Here’s my working YAML for anybody who might benefit from it:

- id: '1554380284572'
  alias: Sunrise
  trigger:
  - event: sunrise
    platform: sun
  condition: []
  action:
  - data:
      entity_id: group.all_lights
    service: light.turn_off
- id: '1554383174732'
  alias: Sunset
  trigger:
  - event: sunset
    platform: sun
  condition:
    condition: or
    conditions: #only triggers is either me and jess are home - NOT AN AND CONDITION
    - condition: state
      entity_id: 'person.jess'
      state: 'home'
    - condition: state
      entity_id: 'person.kieran'
      state: 'home'
  action:
  - data:
      brightness: '10'
      entity_id: group.chill
    service: light.turn_on
  - data:
      entity_id: group.vvchill
    service: light.turn_off

Nice!

Sorry i don’t know, I don’t use Alexa… Only Siri

No worries, thanks again :grinning:

No problem. :wink:
I would recommend to search the forum and if that doesn’t work make another tread with your issue.

For your Alexa problem, I dont have Alexa either, but I think the reason it is not working, is because you have grouped the lights, through the groups.yaml. You have to group the lights from the lights.yaml file. That means you have to do it like this:

lights.yaml

- platform: group
  name: Ledstrips
  entities:
    - light.entrance_ledstrip
    - light.living_room_ledstrip
    - light.kitchen_ledstrip

I hope this works for you.

You can read more about it here: