Need Help! To automate my Garden-Lights

Hallo guys,
I am relatively new with Home Assistant 0.53.1 and I need some help to configure an automation for my Garden Lights. I want to switch both lights On or Off. Lets say every Day at 7pm on and at 11pm off.

What i did is: I installed Mosquitto mqtt server on my Rasperry Pi and I made the follow stuff in the Configuration file.

mqtt:
broker: localhost
port: 1883
client_id: home-assistant-1
keepalive: 60
username: pi
password: My Password
protocol: 3.1.1

switch:

  • platform: mqtt
    name: “Gartenvorn”
    state_topic: “home/garten/1/stat”
    command_topic: “home/garten/1”
    qos: 1
    payload_on: “on”
    payload_off: “off”
    retain: true

  • platform: mqtt
    name: “Gartenhinten”
    state_topic: “home/garten/2/stat”
    command_topic: “home/garten/2”
    qos: 1
    payload_on: “on”
    payload_off: “off”
    retain: true

This works fine. I can swich both Lamps on and off over the Browser.

How can I do it ? and where I have to write it. Mayby some of you can help me.
Thanks in advance
Jürgen

Just create two automation in the configuration file.

automation:
  - alias: "Gartenlicht automatisch einschalten"
    initial_state: True
    trigger:
      - platform: time
        hours: 19
        minutes: 0
        seconds: 1
    action:
      service: switch.turn_on
      entity_id:
        - switch.gartenvorn
        - switch.gartenhinten

  - alias: "Gartenlicht automatisch ausschalten"
    initial_state: True
    trigger:
      - platform: time
        hours: 23
        minutes: 0
        seconds: 1
    action:
      service: switch.turn_off
      entity_id:
        - switch.gartenvorn
        - switch.gartenhinten

Of course after you can add condition and other parameter (for example I use presence detection to only turn some light on when someone is home / connected on the wifi).

Or it could also be on, when nobody is at home from 23h to sunrise.

Another thing you could add as condition is the sunset time, in the summer, it might be wise to turn on the light later than 7pm.

You can learn more about condition here:

Viel Spaß damit :rofl:

And when you post part of a script or some configuration, don’t forget to put 4 spaces in from of each line, so the formating will be kept :slight_smile:

@touliloup

Many thanks for your very quick help. It is always amazing for me, that People spends his free time to help other.
Best Regards

Jürgen

You’re welcome, I’ve received the same treatment when I’ve started with home-assistant, so just trying to give some of the knowledge back :slight_smile: