Ok, I need help

So, I appreciate that this place isnt for tutorials - but gosh do i need need help - im talking of hte “explain it to me like im an 8 year old variant!”

So Ive moved over to HA from sharptools and I’m realy struggling.

At the moment I am just trying to create some simple automations.

Ive already set up a helper group of 3 lights to turn on at sunset

I simply juset want them to dim by 50% at 9pm

This was really easy in sharptools

i cant for the life of me figure out how to do this

the yaml flow of the current turning lights on at sunset is

alias: New Automation
description: “”
trigger:

  • platform: sun
    event: sunset
    offset: 0
  • platform: state
    entity_id:
    • light.sunset_lights_on
      condition:
      action:
  • service: light.turn_on
    metadata: {}
    data: {}
    target:
    entity_id: light.sunset_lights_on
    mode: single

and this works

how do I get them to reduce by 50% at 9?

Firstly please format your post correctly: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Create a second automation to dim your light using a time trigger:

In the actions use the light.turn_on service to dim the lights to 50%.

Putting all that together:

trigger:
  - platform: time
    at: "21:00:00"
action:
  - service: light.turn_on
    target:
      entity_id: light.sunset_lights_on
    data:
      brightness_pct: 50

Follow tom_l’s instructions to create a separate automation with a Time Trigger.

For future reference, Home Assistant offers two ways to specify brightness for light.turn_on, either via the brightness option using a value between 0 and 255 (128 represents 50%) or via the brightness_pct option using a value between 0 and 100.


If you’re interested, it’s possible to turn on the lights at sunset and also set them to 50% at 9:00 PM using a single automation.

alias: Control Sunset Lights
trigger:
  - platform: sun
    event: sunset
  - platform: time
    at: "21:00:00"
action:
  - service: light.turn_on
    target:
      entity_id: light.sunset_lights_on
    data:
      brightness_pct: "{{ iif(trigger.platform == 'sun', 100, 50) }}"
mode: single
2 Likes

Many thanks to you both, what a quick response!

I did notice the way I put the code in was different to other posts, sorry about that I’m very “green” at this

I will try what you said tomorrow

Feeling very deflated at the moment

So far, Spent money on the pi4, a nice case and all I’ve done is invest many hours making a dash board that looks worse than my Sharp tools one and also not be able to re make the automations that ran fine haha

Just had to disable the sunset lights on one as when I went to turn them all off they just came bk on again - doh

1 Like

Where the heck did you guys learn all this…just tried the both and they work!

I’m in awe

Like anything worth doing it takes time to learn how to do properly. Both Taras and I have been using Home Assistant for years.

Learning where the info you need in the documentation is and how to read the info it provides is a good start. Spend some time reading a bit of it each day. Doesn’t have to be hours. Here are a few good ones to get you going but following from here is also good.

Integrations, there are generic pages like “light” or “media player” that have service info and integration/device specific pages as well:

Automation triggers:

Automation and script conditions:

Script syntax (also applies to automation actions):

1 Like

did you use the homeassistant ui to build your automation? or did you jump into yaml?

the ui for this use case will almost completely guide you through it and i think it would have put the actions in the right spot.

when you’re just starting out, i’d personally encourage you to really work w/in the ui flow first… then look at the yaml it generates, and just tweak the yaml… for things like when you need to use templates. do the fancy stuff later. let the ui guide you first.

the ui has come an amazingly long ways since just a couple years ago. you can do so much there w/o creating yaml from scratch now!

1 Like

One thing, as it is not completely clear when creating an automation. Automation triggers are or based, eg. Any trigger that is true will start the automation. Automation conditions are and based, eg. All conditions must be true for the automation to continue.

That’s not entirely true.

It is correct that conditions are ‘and’ by default but they can be made to be ‘or’ based as well. Or ‘not’ based. Etc…

Should have added the word default to my post. Thanks for clarification. Most people are not technical enough to understand why things run the way they do when they create an automation and try to solve every possible combination with one automation and don’t consider that they can have multiple simpler automations. Your link is helpful.

1 Like
target:
  entity_id: light.sunset_lights_on
data:
  brightness_pct: "{{ iif(trigger.platform == 'sun', 100, 50) }}" ```

I used this code soneone , kindly provided to me - ive been doing some reading - is it possible to get the lights to dim more gradually - like a transition - at the moment the just jumo from 100 - 50.

if i put 100,70,50 in the code would they dim more gradually or would it need another line of code?

Transition has to be supported by the hardware. Assuming your hardware supports it you can try:

target:
  entity_id: light.sunset_lights_on
data:
  brightness_pct: "{{ iif(trigger.platform == 'sun', 100, 50) }}" ```
  transition: 5 # this is in seconds, chgange it to what you want. Do not put stupidly long times.

You can not put any more values in that particular code. iff() only accepts two options (values for the template resolving to true or false).

If you want longer times than 20 seconds or so you are going to need a different approach.

Genius! I did try that but think I messed up the spacing

Thank you