Invalid Config with nested conditions for automation

So I’m getting the generic invalid config. As in HA launches, but says automation config is invalid. Here is the problem code, specifically the conditions section. I can’t work out what is wrong. I should also note that the reason I am anding together two tracker instances is because the wifi range extender gives devices a different virtual mac. So I have to account for both mac addresses, as it changes depending on if it connecting through the extender or not.

- alias: Turn on porch light after sunset when someone isn't home
  hide_entity: True
  trigger:
    platform: sun
    event: sunset
    offset: "+01:00:00"
  condition:
    condition: or
    conditions:
      - condition:
        conditions:
          - condition: state
            entity_id: device_tracker.android834ff41f25fdf60a
            state: 'not_home'
          - condition: state
            entity_id: device_tracker.android834ff41f25fdf60a_2
            state: 'not_home'
      - condition:
        conditions:
          - condition: state
            entity_id: device_tracker.android83ddb64fb1dcbaa3
            state: 'not_home'
          - condition: state
            entity_id: device_tracker.android83ddb64fb1dcbaa3_2
            state: 'not_home'    
  action:
    service: light.turn_on
    entity_id: light.white_light

So essentially, I want it to tun on the light if both instances of either device are ‘not_home’ after sunset.

Can you repost the code using the “preformatted text” button that looks like </> or by putting this character ``` at the beginning and end of your code. It will make checking for spacing errors and formatting easier for the community.

Yeah, I was working that out on the fly. Think I’ve got it now.

Nevermind, I worked it out. I saw someone elsewhere saying that conditions are by default and logic, so you didn’t need the and. But adding it in fixed it.

Can you please post the correct code as a comparison to the original? I’d like to see what changed in the process.

Sure can.

- alias: Turn on porch light after sunset when someone isn't home
  hide_entity: True
  trigger:
    platform: sun
    event: sunset
    offset: "+00:45:00"
  condition:
    condition: or
    conditions:
      - condition: and
        conditions:
          - condition: state
            entity_id: device_tracker.android834ff41f25fdf60a
            state: 'not_home'
          - condition: state
            entity_id: device_tracker.android834ff41f25fdf60a_2
            state: 'not_home'
      - condition: and
        conditions:
          - condition: state
            entity_id: device_tracker.android83ddb64fb1dcbaa3
            state: 'not_home'
          - condition: state
            entity_id: device_tracker.android83ddb64fb1dcbaa3_2
            state: 'not_home'    
  action:
    service: light.turn_on
    entity_id: light.white_light

No invalid configuration, but I’m still not sure if it’s actually doing what I want it to do. It seemed to come on last night when everyone was home, so the conditions should not have been met.

Anything further? Any luck with this automation?

Which device_tracker component are the androids linked to? I’ve had some issues with the nmap component personally. I previously nmap-ped all my devices, but it’ll showed my phone and tablet going home/not-home repeatedly throughout the day, even though I’m not home.

I’ve been away for the weekend, so I haven’t been able to test it further. I’m using the inbuilt netgear tracking. So far, the tracking itself works well. I’ll post back once I’m sure if the automation itself does what I want it to, or not.

So I’ve managed to test it, and it seems to be working as expected.