I am trying to create an automation with a computed offset from the trigger, the trigger being sunset and the offset changes by month of the year. After failing to get it working I simplified it to the configuration below in attempt to understand it but I can’t even get this to work. The config below produces the error “extra keys not allowed @ data[‘turn_on_at’]” which doesn’t help me at all.
To help you in the future, “extra keys are not allowed” means you put something in there that isn’t in the spec. It then tells you which extra thing you added (“@ data[‘turn_on_at’]”).
As for the problem you are working on now, if you’re trying to account for the varying lengths of dusk/dawn throughout the year, the Home Assistant docs (see the note in the Sun Trigger section on this page) recommend using sun elevation triggers, not sunrise/sunset with offsets for reasons it seems like you’ve already figured out.
@dh-1 : key learning from this is that ChatGPT just doesn’t work for HA. Please don’t use it then come here asking for help fixing it, as it often contains subtle errors that take more time and effort to track down than solving the problem from scratch.
If you are going to use it, please at least let us know up front so we can ignore it.
The sun trigger already provides an optional offset for adding the 30 minutes that you are trying to: see here.
alias: Test automation
description: ""
trigger:
- platform: sun
event: sunset
offset: "00:30:00"
action:
- service: switch.turn_on
target:
entity_id: switch.sitting_room_table_lamp_local_switch
mode: single
The configuration I posted was not the original (I know I should have been more careful), the variable month had been used originally as a modifer in generating an offset from the trigger (sunset).
light.turn_on was from GPT, again I didn’t look carefully enough.
I used GPT later in the diagnostic process, turn_on_at came from a google search although I can’t find again.
The information: “extra keys are not allowed” means you put something in there that isn’t in the spec, was the most helpful comment, thankyou for that. Oh and I will look at Sun Elevation Trigger as an alternative to what I was trying to do.
I suspect I’m just not up to configuring Home Assistant, a lesson I’m beginning to realise too.
Eh, using ChatGPT for HA is almost always a bust… BUT, that doesn’t mean you’re not up to making HA what you want and need it to be. A lot of us have been using HA for YEARS and, at least for me, I still learn new things about it almost daily. There’s tons of resources available and lots of experts to lean on.
Basically, don’t throw the towel in over one failed automation. Take what you’ve learned and keep experimenting. Oh, and make sure you keep LOTS of backups to rollback to. (I honestly cannot tell you how many times I’ve had to restore my config yaml files because of stupid mistakes I made lol).
Don’t give up. I have been using HA for five years, and I’m still learning. I have an immense bookmark list from this forum with items that might come in useful one day.
Don’t put yourself down. It’s a steep learning curve, but once you get your head around the concepts and actually understand what you’re doing, it’s not that hard.