Newbee trying first automation

This is my first attempt with home assistant (Please be gentle) I have it running on a dedicated server. It has picked up many of my devices on the home network and appears functional. I have the the latest update:
Installation method
Home Assistant OS
Core
2025.12.3
Supervisor
2025.12.3
Operating System
16.3
Frontend
20251203.2

I am trying to automate a couple of KAUF smart plugs for some outdoor Christmas lights and my tree they are connected to my network and seen by HA. I can manually turn them on and off in the interface. I have created 2 automations one from sunrise to sunset and another 7:00am to 11:00pm

screen print
It looks like they are triggering (one 5 hours ago and one 15 hours ago) but the switches didn’t respond


As a new user I can only upload one photo at a time. to I’ll add additional posts with screen shots

This is the detail for the outdoor lights sunup to sunset

this is for the tree 7:am-11:0pm everyday


It looks’ easy but its not working does anyone know what I’m doing wrong?

It’s easier for us to diagnose issues if you don’t share screenshots. Instead, follow Community Questions Guideline #14 by posting the, properly formatted, YAML configuration for the automation. This can be found by clicking the breadcrumb menu (3 dots) at the top right and selecting “Edit in YAML”. Copy that and paste it, using 3-ticks ``` on the line above and the line below the configuration code.

Based on what is in the screenshots you have posted, your actions currently turn the lights on and then immediately turn them off.

If that is not your goal, you have two options:

  1. Use separate automations for turning on and turning off the targeted entities.
  2. Use an If/Then or Choose action so that a specific trigger causes a specific action. One way to do this is to use Trigger IDs.

I have a lot to learn I start by figuring out what a YAML is :grimacing:

OK I I like the YAML views much easer to see what’s going on (once I figure out the syntax)! I have created 2 separate automations here are the YAML files:

alias: Christmas Tree On
description: ""
triggers:
  - trigger: time
    at: "07:00:00"
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - sat
      - fri
conditions: []
actions:
  - action: switch.turn_on
    metadata: {}
    target:
      entity_id: switch.kauf_plug_christmas_tree_kauf_plug
    data: {}
mode: single

alias: Christmas Tree Off
description: ""
triggers:
  - trigger: time
    at: "23:00:00"
    weekday:
      - thu
      - wed
      - tue
      - mon
      - sun
      - fri
      - sat
conditions: []
actions:
  - type: turn_off
    device_id: 90322ce08e1838d28ce8ac145e71c0ce
    entity_id: e9f1955950cbb0ff32ada27aaba40903
    domain: switch
mode: single

I used the UI to create these I wonder why the entity ID’s are different shouldent they both say entity_id: switch.kauf_plug_christmas_tree_kauf_plug
and why does one have a device id
Looking more closely there are a lot of differences

What you shared now is two different automations, one for turning on in the morning, one for turning off in the evening. On your screenshots you had different thing, one automation that would trigger twice a day and then turn on and immediately turn off lights each time.

What your shared now should in general work.

The reason it looks different is that one uses entity as a target and there other one uses device as target. In HA device is just of a container for entities, usually it equals to the actual physical device. While entities are different parts of that device, usually one used for the main function (in this case it’s the switch that can switch the plug on or off) and often plenty others, for example to provide some data (like power or energy values).

Anyway, both targeting entity and device work, yes just that there device method uses this long ugly id of the device and is in general not recommended here on the forum for various reasons.

Those automations should work.
If you instead want one automation to do both then this is also possible.

alias: Christmas Tree On and Off
description: ""
triggers:
  - trigger: time
    at: "07:00:00"
    id: on
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - sat
      - fri
  - trigger: time
    at: "23:00:00"
    id: off
    weekday:
      - thu
      - wed
      - tue
      - mon
      - sun
      - fri
      - sat
conditions: []
actions:
  - action: "switch.turn_{{ trigger.id }}"
    metadata: {}
    target:
      entity_id: switch.kauf_plug_christmas_tree_kauf_plug
    data: {}
mode: single

This uses a variable called id which is something you can edit in the ui.
And all we do is say at 7 the id should be on, and therefor the action is turn_on.
The weekdays can actually be omitted (deleted) since you have all days listed.

wow thanks for the replies so late in the evening

It’s not late in the evening everywhere :wink:

BTW if you want the automation to trigger on all days, you don’t need to select the weekdays.

Here’s another example how to do it in one automation, but without the need for templates

alias: Christmas Tree On and Off
triggers:
  - trigger: time
    at: "07:00:00"
    id: turn_on
  - trigger: time
    at: "23:00:00"
    id: turn_off
actions:
  - if:
      - condition: trigger
        id: turn_on
    then:
      - action: switch.turn_on
        target:
          entity_id: switch.kauf_plug_christmas_tree_kauf_plugmode: single
    else:
      - action: switch.turn_off
        target:
          entity_id: switch.kauf_plug_christmas_tree_kauf_plugmode: single

@Hellis81 you’re automation won’t work you need to put the trigger id’s between quotes if you use on and off as they are boolean values in YAML

1 Like

The UI doesn’t add quotes to the trigger variables, so there must be a major bug in HA :wink: