Automate automation

Perhaps a strange question. But i’m still finding a way to get the GoGoGate working on switching on and off lights during the night. We have worked out last time but now things are not working. The conditions are to complicated and not working. This because the automation has to work after 23.00 and before sunrise. Time is working but after adding the sunrise condition the automation is not working.

So I was thinking. Can I automate the automation. So after sunrise switch off the automation GoGoGate open and GoGoGate close. And sunset switch on the automation GoGoGate.

Should be possible.

Names of the automations

GoGoGate dicht licht uit
GoGoGate open licht aan

You could do that, but this is exactly what conditions are for, what’s wrong with this…

condition:
  condition: or
  conditions:
    - condition: time
      after: '23:00:00'
    - condition: sun 
      before: sunrise

?

Yes this is what I did but is not working.

#Hek open licht aan
- alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: closed
    to: open
  condition:
    condition: and
    conditions:
    - condition: time
      after: '23:00:00'
    - condition: state
      entity_id: sun.sun
      state: below_horizon
  action:
  - service: scene.turn_on
    entity_id: scene.garden_lights_bright
  - service: switch.turn_on
    entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch

You’re using an and condition. It cannot be both after 11pm AND before sunrise in the same day. You need an or condition as I put in my post.

In fact, you’ve used the below horizon as your second one so that should work, what do the logs say?

Did not check the logs but seen that it never had been triggered. When I delete the sun part it is working.

Now changed into

# GoGoGate open
- alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: closed
    to: open
  condition:
  condition: or
  conditions:
    - condition: time
      after: '23:00:00'
    - condition: sun
      before: sunrise
  action:
  - service: scene.turn_on
    entity_id: scene.garden_lights_bright
  - service: switch.turn_on
    entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switc

h

Got an error now

Invalid config for [automation]: expected a dictionary @ data[‘condition’][0]. Got None extra keys not allowed @ data[‘conditions’]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 115). Please check the docs at Automation - Home Assistant Invalid config for [automation]: expected a dictionary @ data[‘condition’][0]. Got None extra keys not allowed @ data[‘conditions’]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 115). Please check the docs at Automation - Home Assistant

That is the reason to keep it simple. Just use condition time and made an automation to switch on and off the automation of the GoGoGate.

You have an indentation issue on your conditions, see my example above for how it should look.

I’m not sure I agree that your solution could be described as “simple”.

Instead of having one automation do what you want it to do you will now have three different automations to do the same thing. That’s not “simple”.

It would be simpler to actually follow the advice given above and correct your mistakes to make the current automation work correctly.

Going down the path you have chosen because you don’t want to learn the correct syntax means you will end up with a bunch of unnecessary code for every automation where this type of condition is going to be necessary.

2 Likes

Deleted my whole automation and added the following.

#GoGoGate open licht aan
- alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: closed
    to: open
  condition:
  condition: or
  conditions:
    - condition: time
      after: '23:00:00'
    - condition: sun
      before: sunrise
  action:
  - service: scene.turn_on
    entity_id: scene.garden_lights_bright
  - service: switch.turn_on
    entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch

That gives me

Invalid config for [automation]: expected a dictionary @ data[‘condition’][0]. Got None
extra keys not allowed @ data[‘conditions’]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 97). Please check the docs at Automation - Home Assistant

And line 97 is

group: !include groups.yaml

When I open the groups.yaml file that one is empty. I’m lost. When I delete the above automation and write my old one no errors.

This is my configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Sensors
sensor:
  - platform: buienradar
    monitored_conditions:
      - symbol
      - humidity
      - temperature
      - windspeed
      - pressure

# Maan
sensor:
  - platform: moon

# Weather prediction
  - platform: yr

# Text to speech
tts:
  - platform: google_translate

# buienradar info
weather:
  - platform: buienradar

# Buienradar camera
camera:
  - platform: buienradar

# GoGoGate
cover:
  - platform: gogogate2
    username: HomeAs
    password: F********
    ip_address: 192.168.1.9

#speedtest
speedtestdotnet:
  scan_interval:
    minutes: 30
  monitored_conditions:
    - ping
    - download
    - upload

# Philips TV
media_player:
  - platform: philips_js
    host: 192.168.1.23

#Scenes
scene:
  - name: Hek Dim
    entities:
        light.qubino_goap_zmnhdd1_flush_dimmer_level:
            state: on
            transition: 2
            brightness_pct: 3
  - name: Guesthouse Dim
    entities:
        light.qubino_goap_zmnhdd1_flush_dimmer_level_2:
            state: on
            transition: 2
            brightness_pct: 10
  - name: Garden Lights Bright
    entities:
        light.qubino_goap_zmnhdd1_flush_dimmer_level:
            state: on
            transition: 2
            brightness_pct: 100
  - name: Garden Lights Dim
    entities:
        light.qubino_goap_zmnhdd1_flush_dimmer_level:
            state: on
            transition: 2
            brightness_pct: 3

#Lichtsensor
binary_sensor:
  - platform: threshold
    name: "Low LUX"
    lower: 50
    entity_id: sensor.steinel_is140_2_luminance

  - platform: threshold
    name: "High LUX"
    upper: 60
    entity_id: sensor.steinel_is140_2_luminance

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

Please indent your conditions correctly, as per my advice above, and the example that preceded it. I really can’t help much more than that :man_shrugging:

1 Like

Dude…

you haven’t even looked at what @anon43302295 posted in the reply above that told you how to fix it.

I’ll be more explicit:

here is what he posted:

condition:
  condition: or
  conditions:
    - condition: time
      after: '23:00:00'
    - condition: sun 
      before: sunrise

this is what you have:

condition:
condition: or
conditions:
  - condition: time
    after: '23:00:00'
  - condition: sun
    before: sunrise

please look again and see the difference.

Yes I did and changed some lines. I see now a typo I did not copy right.

I changed now

    - condition: state
      entity_id: sun.sun
      state: below_horizon

into

  condition:
    condition: and
    conditions:
    - condition: time
      after: '23:00:00'
    - condition: sun  
      before: sunrise

So the whole automation of the gate looks like this.

#GoGoGate open licht aan
- alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: closed
    to: open
  condition:
    condition: and
    conditions:
    - condition: time
      after: '23:00:00'
    - condition: sun
      before: sunrise
  action:
  - service: scene.turn_on
    entity_id: scene.hek_vol
  - service: switch.turn_on
    entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
  - service: switch.turn_on
    entity_id: switch.steinel_is140_2_switch

# GoGoGate dicht
- alias: GoGoGate dicht licht uit
  trigger:
    platform: state
    entity_id: cover.hek
    from: open
    to: closed
  condition:
    condition: and
    conditions:
    - condition: time
      after: '23:00:00'
    - condition: sun  
      before: sunrise
  action:
  - service: scene.turn_on
    entity_id: scene.hek_dim
  - delay:
      minutes: 1
  - service: switch.turn_off
    entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
  - service: switch.turn_off
    entity_id: switch.steinel_is140_2_switch

When I trigger the automation manual the setup works but in a view minutes I can check.

And above is not working.

When I delete the

    - condition: sun
      before: sunrise

part the automation is working.

I changed the lines now into

    - condition: state
      entity_id: sun.sun
      state: below_horizon

And it is working.

Whole setup for the ones who are interested.

#GoGoGate open licht aan
- alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: closed
    to: open
  condition:
    condition: and
    conditions:
    - condition: time
      after: '23:00:00'
    - condition: state
      entity_id: sun.sun
      state: below_horizon
  action:
  - service: scene.turn_on
    entity_id: scene.hek_vol
  - service: switch.turn_on
    entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
  - service: switch.turn_on
    entity_id: switch.steinel_is140_2_switch

# GoGoGate dicht
- alias: GoGoGate dicht licht uit
  trigger:
    platform: state
    entity_id: cover.hek
    from: open
    to: closed
  condition:
    condition: and
    conditions:
    - condition: time
      after: '23:00:00'
    - condition: state
      entity_id: sun.sun
      state: below_horizon
  action:
  - service: scene.turn_on
    entity_id: scene.hek_dim
  - delay:
      minutes: 1
  - service: switch.turn_off
    entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
  - service: switch.turn_off
    entity_id: switch.steinel_is140_2_switch

That’s because you didn’t use the OR condition I told you you needed to use in my very first reply.

It’s really hard to help people who don’t listen to the help they’re given.

Glad you got sorted.

Let’s put it this way. I’m not a programmer and trying to understand. For me it is abracadabra so a little patiente is help full.

So why it was working before 0:00:00 and now it is as dead as it can be?

When I used your post

This gives errors because it should be

  condition:
    condition: or
    conditions:
      - condition: time
        after: '23:00:00'
      - condition: sun 
        before: sunrise

And this is working.

So to keep it short. Your first reply was wrong witch backfired in the whole conversation.

Of course… it’s @anon43302295’s fault… :roll_eyes:

we were being patient until we kept telling you how to do it and you didn’t follow the directions.

and I’m still not even sure you are even now…

These look exactly the same to me:

In both code blocks you used the following:

condition:
  condition: or
  conditions:
    - condition: time
      after: '23:00:00'
    - condition: sun 
      before: sunrise

They aren’t different so one can’t error and the other work because they are the same. Unless I’m missing something…?

the reason it caused errors is because you didn’t copy/paste the code correctly. The indentation was wrong in every one of your posts until the last one which you then said was working. Of course it will work because you fixed the indentation mistakes.

If you look back at post #2 by @anon43302295 you should see that the code he gave you there is exactly like the code that you say is now working.

Because after midnight it is no longer after 23:00 any more. Because the “after” only goes from that time until 00:00. After that it is then before 23:00 of the next day.

The same goes for before sunrise. the only time it is “before sunrise” is from 00:00 until sunrise.

That is why you need the two conditions to be an “or”. Because then you will test for the conditions from between 23:00 and midnight or between midnight and sunrise.

If you you use an “and” condition that is after 23:00 and the sun is below the horizon (as you had in your last “working” automation above that really wasn’t) as soon as it turns into midnight then it is no longer after 23:00 so the “and” conditions are no longer true. So it doesn’t work.

Please don’t blame others who are trying to help you when you are the one failing to follow the instructions given.

1 Like