Dim lights at time x

Sounds like we are good to go.

@RemcovanKuilenburg Don’t leave me hanging, I’m dying of suspense, does everything work now?

Sorry, some delay because of reconstruction of my bathroom.

I did try everything and nothing seems to work. When I add the sun part the Home assistant is not starting and with all ways of typing stuff results of crashing GoGoGate.

So what I want to do to make life easy is automate the automate part. Meaning, can I just make an automation that starts the gate part after sunset and switch off the gate part at sun up? That would make for now my life easy but I off course want to find out what is bugging the system.

Are you just using the sun part for just sunrise right, because you do not need it for Sunset.
And, I would try this for Sunrise:

condition:
  platform: numeric_state
  entity_id: sun.sun
  value_template: '{{ state.attributes.elevation }}'
  above: 4.50

Also, if you click on an automation in the frontend you can manually trigger an Automation.

Took some time, first burned Qubino switch and some time for other stuff. But now trying to use this but no succes. The UI is not starting at this moment and get the message can not reach site. After deleting the gate part the UI is starting.

This is the automation part

- id: '1566418818385'
  alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: "closed"
    to: "open"
  condition:
    condition: and
    platform: numeric_state
  entity_id: sun.sun
  value_template: '{{ state.attributes.elevation }}'
  above: 4.50
  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

- id: '1566423130786'
  alias: GoGoGate dicht licht uit
  trigger:
    platform: state
    entity_id: cover.hek
    from: "open"
    to: "closed"
  condition:
    platform: numeric_state
  entity_id: sun.sun
  value_template: '{{ state.attributes.elevation }}'
  above: 4.50  action:
    - service: scene.turn_on
      entity_id: scene.garden_lights_dim
    - delay:
       minutes: 1
    - service: switch.turn_off
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch

Deleted the wrong part I see now.

- id: '1566418818385'
  alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: "closed"
    to: "open"
  condition:
    platform: numeric_state
  entity_id: sun.sun
  value_template: '{{ state.attributes.elevation }}'
  above: 4.50
  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

- id: '1566423130786'
  alias: GoGoGate dicht licht uit
  trigger:
    platform: state
    entity_id: cover.hek
    from: "open"
    to: "closed"
  condition:
    platform: numeric_state
  entity_id: sun.sun
  value_template: '{{ state.attributes.elevation }}'
  above: 4.50  
  action:
    - service: scene.turn_on
      entity_id: scene.garden_lights_dim
    - delay:
       minutes: 1
    - service: switch.turn_off
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch

After the small change the UI starts but I can not see the automation part in the UI and get an error about automation.

Sorry to jump in here but your yaml indentation looks all wrong.
Have you tested this using ‘configuration’ - ‘server control’ - ‘check config’ ???
I don’t think it will pass
The code tinydot gave you was spaced as it was deliberately so that HA knows what belongs to what, which attributes are part of which object etc.

Hi Mutt,

Totally new to this so I’m not sure what to do. I’m using Mac and a terminal server to enter the Raspberry. So lines can be shifted. Do you know a good way to get all in right using a Mac?

Okay, First … (It may sound like I’m treating you as a child, I’m not I just don’t know your level of computer literacy, your experience and how much you have read up) A…N…D… the next person who reads this may know even less than you ! So let’s help as many as we can in one go.

  1. Did you install samba on your HA instance ? (it makes accessing the file sytem a lot easier)
  2. You are using a browser to access your HA ? via (say) 192.168.0.200:8123 or the like ?
  3. the configuration.yaml file (the one I think you’ve been editing is in the config folder, so //192.168.0.200/config if you are using samba
  4. the Mac (i’m told, as I don’t use one and I use notepad++ as an editor) has a perfectly good text editor (TextEdit) but if you want more from an editor then recomendation lean towards 1-Running notepad++ under WINE. 2-Brackets 3-TextMate and 4-Sublime Text
    YMMV
    I would prefer you to get advice from someone who ‘knows’ (i.e. someone who does this on a Mac ALL the time.

With yaml the general rule of things is : - indent 2 spaces each time
I’m going to go out on a limb here and say it’s a bit like html in that respect (you know what html is ?) (but html spacing depth is up to the user) but Indenting IS mandatory.
Do some reading of other code ect. on this forum.
My configuration.yaml is 27 lines long and 2 of them are comments
I use ‘packages’ (there are MANY ways to skin a cat though)
I have (currently) 37 packages (more being added all the time.
A package is a good way to see how different bits of configuration are done (some don’t like it being called code, but it runs on a machine to do things you ask it to do so …)
Generally, if it did something else, then it’s probably your fault (it’s always mine !)
Here is one of my packages with different elements in it. It is NOT 100% mandatory to code exactly like this but I always do for consistency on my system. This package is for Bed Room 4 Lights in my House.

input_boolean:
  ib_light_bed4_timer_enable:
    name: Bed 4 Timer Enable
    #initial: on
    icon: mdi:timer

input_number:
  in_light_bed4_timer:
    name: Bed 4 On Timer (mins)
    #initial: 240
    min: 1
    max: 300
    step: 1
    mode: box
    icon: mdi:alarm

      # - service: input_boolean.toggle
        # entity_id: input_boolean.ib_global_test
automation:
    #name: Light Bed4 Off Delay
  - alias: au_light_bed4_offdelay
    trigger:
      - platform: state
        entity_id: light.fib_fgd212dim2_bed4_level
        from: 'off'
        to: 'on'
    condition:
      - condition: state
        entity_id: input_boolean.ib_light_bed4_timer_enable
        state: 'on'
    action:
      - service: script.turn_off
        entity_id: script.sc_light_bed4_timer
      - service: script.sc_light_bed4_timer
    #name: Switch Bed4 Off Cancels Timer
  - alias: au_switch_bed4_offcancelstimer
    trigger:
      - platform: state
        entity_id: light.fib_fgd212dim2_bed4_level
        to: 'off'
    action:
      - service: script.turn_off
        entity_id: script.sc_light_bed4_timer
    #name: Adjust Brightness On Segment Change
  - alias: au_light_adjust_brightness_bed4
    trigger:
      - platform: state
        entity_id: input_number.in_aalight_bed4_lvl
    condition:
      - condition: state
        entity_id: light.fib_fgd212dim2_bed4_level
        state: 'on'
    action:
      - service: light.turn_on
        data_template:
          entity_id: light.fib_fgd212dim2_bed4_level
          brightness_pct: >
            {{ states('input_number.in_aalight_bed4_lvl') | int }}

script:
  sc_light_bed4_timer:
    alias: Light Bed4 Timer Script
    sequence:
    - delay: "00:{{ states('input_number.in_light_bed4_timer') | int }}:00"
    - service: light.turn_off
      entity_id: light.fib_fgd212dim2_bed4_level

Do you see how all the automations are indented UNDER “automation:” ditto with input_boolean: and script: etc.
Then the are the various automations and each one is indented under it’s - alias: (here you see my bias as the ‘-’ is not always necessary)
My entities are bespoke to the package (so I know where to adjust an element that crops up else where) and named so I can find them easily
au is an automation
light means it’s todo with a light
bed4 specifies which light
Together the last 3 identify the package
Then a meaningful name at the end
This is where notepad++ helps because as you type it tries to autocomplete so you make fewer mistakes (I still make loads)
Anyway look at the form rather than my naming, your code ‘should’ look something like that

1 Like

@RemcovanKuilenburg the post that @Mutt has created has some very good info. I am not sure how you are entering or changing your configs, but using Mutt’s method is what I do works well. Also, before you restart the server you can check your configs to make sure they are correct, at least so the server will restart. You will find this option after you click Configuration from the Left side panel, and then click General or Server Control ( Depends on which version of Homeassistant you are using ). Here you can click on the Check Config to see if you have any problems with your configuration, and it will give you some hints as to what is wrong if there is something wrong.

I have created the config that I think you are going for and I have placed them on my server and Checked Config to make sure there are no errors, so here ya go. If there is something that you do not understand, please ask and I will help understand what we are doing.

- id: '1566418818385'
  alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: "closed"
    to: "open"
  condition:
    - condition: time
      after: '00:00:00'
  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

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

Let us know how things turn out.

@Mutt I’m new to this and not a hard coded programmer. So it is learning for me.
Most of my automation file is programmed trough the UI of Home Assistent and a mess when you look at it. Will clean the code when I’m ready but for now it is just testing. But thanks for the extra info. That helps a lot.

@TinyDoT Will change the code now and see what is going on. This is my total code I will put in now.

- id: '1566298789438'
  alias: Guesthouse dimmen om 0:00
  trigger:
  - at: '0:00'
    platform: time
  condition: []
  action:
  - data:
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2
    entity_id: scene.Guesthouse_Dim
    service: scene.turn_on
- id: '1566303950332'
  alias: Hek dimmen om 0:00
  trigger:
  - at: 0:00
    platform: time
  condition: []
  action:
  - service: scene.turn_on
    entity_id: scene.Hek_Dim
- id: '1566314038315'
  alias: Zon onder
  trigger:
  - event: sunset
    platform: sun
  condition: []
  action:
  - data:
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
    service: switch.turn_on
  - data:
      entity_id: switch.qubino_goap_zmnhdd1_flush_dimmer_switch
    service: switch.turn_on
  - data:
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2
    service: switch.turn_on
  - data:
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_4
    service: switch.turn_on
  - data:
      entity_id: switch.qubino_goap_zmnhdd1_flush_dimmer_switch_2
    service: switch.turn_on
- id: '1566314814044'
  alias: Zon op
  trigger:
  - event: sunrise
    platform: sun
  condition: []
  action:
  - data:
      entity_id: switch.qubino_goap_zmnhdd1_flush_dimmer_switch
    service: switch.turn_off
  - data:
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2
    service: switch.turn_off
  - data:
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_4
    service: switch.turn_off
  - data:
      entity_id: switch.qubino_goap_zmnhdd1_flush_dimmer_switch_2
    service: switch.turn_off
- id: '1566315078053'
  alias: 0:00
  trigger:
  - at: 0:00
    platform: time
  condition: []
  action:
  - data:
      entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
    service: switch.turn_off
- id: '1566418818385'
  alias: GoGoGate open licht aan
  trigger:
    platform: state
    entity_id: cover.hek
    from: "closed"
    to: "open"
  condition:
    - condition: time
      after: '00:00:00'
  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

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

You expanded on elements I had meant to cover but forgot, so thanks for that.
Not sure what you did with the automations, and just in case you did it deliberately I’ll keep schtum.!
There are three other comments I will make however, neither of the first two will affect functionality. Both are just my preferences but I’ll explain why for each.

  1. I like your use of the ‘and’ for the conditions, it is not necessary as the default is a result of sequential yes/no so must be and but your use allows the reminder that or is possible and nesting such expands options further.
  2. I use double quotes " for all outside quote requirements (following petro’s advice) but though this uses two fingers it makes it obvious that they are in place (my exceptions for this are ‘on’ and ‘off’ cos I’m lazy), this means that ALL quotes inside these are single (and just one key) quotes (easy), yours seem to vary quite a bit from case to case.
  3. The last is a question - though the gate displays open and closed are you SURE that they equate to open/closed? e.g. Like device trackers show home and away they actually work on home and not_home (I know you can’t answer this)

Cheers

Yes I understand but this is directly out of the user interface of Home Assist. So I did make this automation trough the UI and gives this as result.

Yes open and close are valid and when I just give a rule after 0:00 it works when opening and closing my gate. But adding the sun rule it brakes the automation.

What I want is to dim the gate lights after 0:00 and also turn the garage lights off. But when I open my gate I want to have the gate lights at 100% and turn on the garage lights. Close the gate again dim the gate lights and with delay turn the garage lights off.

@TinyDoT computer says no.

Error loading /home/homeassistant/.homeassistant/configuration.yaml: while scanning a quoted scalar
in “/home/homeassistant/.homeassistant/automations.yaml”, line 102, column 16
found unexpected end of stream
in “/home/homeassistant/.homeassistant/automations.yaml”, line 110, column 1

Yep, more or less what I expected.
(Love the “Little Britain” quote)
I don’t (and never have) used the web interface of HA to edit files (it only ever seems to like you putting stuff in one place - not where I want it). So I cant help you there. (I started out on this before there was such an interface and have moved (only a little bit) past where it could have helped me.
Don’t take the config warnings TOOOO literally. I’ve had issues 4 lines before the stated line and once 20 lines after. But from what it’s hinting at, it sounds like an indenting problem rather than syntax.
So I’ll just correct that and we’ll work from there.
Top right of the following code box is a little icon that will say “copy to clipboard” when you hover over it. Copy it and paste it over what we are replacing then run your check again.

- id: '1566298789438'
  alias: Guesthouse dimmen om 00:00:00
    trigger:
    - platform: time
      at: "00:00:00"
    action:
      - service: light.turn_on
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2
      - service: scene.turn_on
        entity_id: scene.Guesthouse_Dim
- id: '1566303950332'
  alias: Hek dimmen om 00:00:00
    trigger:
    - platform: time
      at: "00:00:00"
    action:
    - service: scene.turn_on
      entity_id: scene.Hek_Dim
- id: '1566314038315'
  alias: Zon onder
    trigger:
      - platform: sun
        event: sunset
    action:
      - service: switch.turn_on
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
      - service: switch.turn_on  ## should these not be "light"s ?
        entity_id: switch.qubino_goap_zmnhdd1_flush_dimmer_switch  ## should these not be "light"s ?
      - service: switch.turn_on
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2
      - service: switch.turn_on
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_4
      - service: switch.turn_on  ## should these not be "light"s ?
        entity_id: switch.qubino_goap_zmnhdd1_flush_dimmer_switch_2  ## should these not be "light"s ?
- id: '1566314814044'
  alias: Zon op
    trigger:
      - platform: sun
        event: sunrise
    action:
      - service: switch.turn_off
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
      - service: switch.turn_off  ## should these not be "light"s ?
        entity_id: switch.qubino_goap_zmnhdd1_flush_dimmer_switch  ## should these not be "light"s ?
      - service: switch.turn_off
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2
      - service: switch.turn_off
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch_4
      - service: switch.turn_off  ## should these not be "light"s ?
        entity_id: switch.qubino_goap_zmnhdd1_flush_dimmer_switch_2  ## should these not be "light"s ?
- id: '1566315078053'
  alias: na 00:00:00
    trigger:
      - platform: time
        at: "00:00:00"
    action:
      - service: switch.turn_off
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch
- id: '1566418818385'
  alias: GoGoGate open licht aan
    trigger:
      - platform: state
        entity_id: cover.hek
        from: "closed"
        to: "open"
    condition:
      - condition: time
        after: "00:00:00"
    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
- id: '1566423130786'
  alias: GoGoGate dicht licht uit
    trigger:
      - platform: state
        entity_id: cover.hek
        from: "open"
        to: "closed"
    condition:
      - condition: time
        after: "00:00:00"
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon
    action:
      - service: scene.turn_on
        entity_id: scene.garden_lights_dim
      - delay:
        minutes: 1
      - service: switch.turn_off
        entity_id: switch.qubino_goap_zmnhbdx_flush_2_relays_switch

There seems to be dimmers in here and they are usually lights not switches.
This and the fact that some of your elements are out of sequence and/or randomly indented make me think this is a hodge podge of both generated and manually inserted code.

Do you see how much neater and easier to read my code is ?

Mutt

It also looks like you have not configured any entities as you added them, this will make it very difficult for you to tie up what sensor - where for what purpose.
Is this your house or are you pulling this together for the owner ?

@RemcovanKuilenburg, we have to get you to start doing this manually. I have never used it like @Mutt, because I also started before the option was available. I have taken the route to split my config, it makes thing a lot easier to deal with in my opinion.

It seems the web automation directly in Homeassistant is causing quite some confusion, because when you paste back what I have had you copy in it jumble things around, not sure why, but if you look at example in the Homeassistant Docs, none of them have that jumbled order.

When I checked the config I was using version 97.2, so that could make a difference as well. For the record what version are you using of Homeassistant? Hopefully using the code @Mutt has supplied will get the job done.

@Mutt, I hate quotes, I never know which to use, in the very beginning it seems like it really mattered, but now a days it doesn’t seem to matter too much, until it doesn’t work : )

Quotes - Yeah, I agree, then you have to ‘comb’ through to find the error… Which when you find it is so very subtle But the interpreter found it so it knows what it was. But it doesn’t tell you what it was it usually just says "missing scalar’ or some such.
I’m worried here that some devices have been ‘stuffed’ in by hand and he’s assumed they are all switches.
This probably won’t work