Weekly Schedule for my Lights

Hello to the community!

I am new here so please be patient with me!
I have set up Docker on my Synology NAS and I am currently running MQTT broker and Home Assistant on it, perfectly fine.
I have a Shelly 2.5 device as a relay switch, which currently works as expected through Home Assistant (lights turn off and on).

I want to automate this procedure however as below:

From 19:00 in the evening till 07:00 in the morning of the next day: all lights to turn on
From 07:00 in the morning till 19:00 in the evening: all lights to be off

I can not figure out how to format my autmations.yaml file exactly.
Can I have some help please?

Here is my configuration.yaml file, if it may be of any help.

# 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

# Text to speech
tts:
  - platform: google_translate

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

light:
  - platform: mqtt
    name: "Shelly Road Bulb"
    state_topic: "shellies/shellyswitch25-BA7396/relay/0"
    command_topic: "shellies/shellyswitch25-BA7396/relay/0/command"
    payload_on: "on"
    payload_off: "off"
    retain: true
  - platform: mqtt
    name: "Shelly Road LEDS"
    state_topic: "shellies/shellyswitch25-BA7396/relay/1"
    command_topic: "shellies/shellyswitch25-BA7396/relay/1/command"
    payload_on: "on"
    payload_off: "off"
    retain: true

sensor:
  - platform: mqtt
    name: "Shelly Road Bulb Power"
    state_topic: "shellies/shellyswitch25-BA7396/relay/0/power"
    unit_of_measurement: "Watts"
  - platform: mqtt
    name: "Shelly Road LEDS Power"
    state_topic: "shellies/shellyswitch25-BA7396/relay/1/power"
    unit_of_measurement: "Watts"
  - platform: mqtt
    name: "Shelly2 Road Bulb Energy"
    state_topic: "shellies/shellyswitch25-BA7396/relay/0/energy" 
    unit_of_measurement: "kWh"
  - platform: mqtt
    name: "Shelly2 Road LEDS Energy"
    state_topic: "shellies/shellyswitch25-BA7396/relay/1/energy" 
    unit_of_measurement: "kWh"

Where have you looked for instructions or examples? At least have a look at the docs for automations.

Have you tried anything at all so far?

Generally the gist of what you want is to start out with two automations…one to turn the lights on at the correct time & then another to turn the lights off.

you will use a time trigger to start the automation and then in the action turn the lights either on or off depending on which automation you are coding.

give the docs a look and try to get something working. If you can’t then come back and post what you have tried and we can help from there.

1 Like

If you’re struggling where to begin, this should help you get started.

  1. Paste the two automations shown below into your automations.yaml file and save the file.
  2. Go to Configuration > Server Control
  3. Click Config Check and confirm there are no errors.
  4. Assuming there are no errors, click Reload Automations.
- alias: 'Light ON'
  trigger:
    platform: time
    at: '19:00:00'
  action:
    service: light.turn_on
    entity_id: light.shelly_road_bulb

- alias: 'Light OFF'
  trigger:
    platform: time
    at: '07:00:00'
  action:
    service: light.turn_off
    entity_id: light.shelly_road_bulb
1 Like

Hey, no fair! You made it way too easy.

I was trying the old “if you teach a man to fish…” routine. :wink:

1 Like

Thank you for your reply.
I found it yesterday that the simplest thing to do is to actually create two automation for on and off.

Here they are, since they work as I want.

- id: '1571528153673'
  alias: Lights ON
  trigger:
  - at: '19:20:00'
    platform: time
  condition: []
  action:
  - alias: ''
    data: {}
    service: light.turn_on
- id: '1571529220769'
  alias: Lights OFF
  trigger:
  - at: 07:20:00
    platform: time
  condition: []
  action:
  - service: light.turn_off

Honestly though, I was thinking a little more complicated since I was going for one automation, to rule them all. I do not know if something like this is possible but it would be interesting.

Thank you for your reply!
I believe my automations file is pretty much the same with yours.

Except for the fact they overlook to specify a light to turn on.

1 Like

Its more a metaphor for a light, than an actual light.
Why get bogged down with facts and real world concepts ? :rofl:

And I agree with @finity , cruel to be kind, valuable life lessons

1 Like

Hi,
I would suggest using Nodered with module/palette node-red-contrib-light-scheduler that is quite easy to use, through MQTT broker.
Hope this helps :slight_smile: