This error message: "Message malformed: required key not provided @ data['at']:

Sorry to create a new topic, but I’ll explain here.
OK, I’m new to Home Assistant. I’m fairly logical in my thinking, or at least I used to think so. Anyway, I’m just trying to start out basic writing yaml code, and go from there.
[My installation: I’m running a NUC with Ubuntu desktop 20.04, then installed HA in docker containers using Docker-Compose. (The reason I chose that route, instead of HAOS, is because I didn’t want to be limited by the choice of “add-ons.”) But none of that should matter here, everything seems to operate normally. I say “normal” meaning the software, UI, etc. seem to be as expected.]
However, every time I try to configure something, I keep running into the same error code on everything I do, sometimes it’s a subtle variation of that error. I tried googling it, and also searching on this form, but every time I found a link, the people were trying to do things much more complicated than what I’m trying to do.
(I do know that sometimes I overthink things, maybe that’s part of it.) If I could understand what the error code is telling me, I think I could figure out how to fix it.
I understand the importance of formatting, and I know that often times what seems like a “complicated error code” just comes down to a missing indent or a forgotten bracket (or semicolon, like in Pascal). As far as I can tell, that doesn’t seem to be the problem here.
I really though I had it this time, I’m just trying to turn off 3 lights for bedtime. The times are for weekdays vs weekends. I used the UI for most of the script, then I “opened in yaml editor.” I added 2 templates that I got from a post on this forum that are supposed to work. (In fact, my first attempt was to copy-paste the entire code, then I just changed the times, maybe a name–but got the same error when I tried to save it–even though the OP said it worked!
If someone can help me get this working…and more importantly show me how to figure out what the error message is trying to tell me, that would be MUCH appreciated! (Thanks in advance!)

Again, I created this code in the UI, starting with the switched receptacle, then clicked on “Create Automation” and added the Lights as targets. The only things I’ve done in the “yaml Editor” was to add the 2 templates (5 lines, starting with “conditions:”) and commented out a couple things I didn’t think were needed (they’re indicated with my comments).
Here’s the code:

description: "LR Lights off for bedtime"
mode: single
trigger:
  - platform: time
  # Do I need a helper or something to determine the time? (I first created 2 that I didn't use.)  In the UI I didn't set a time.
  # I'm thinking these templates should take care of of it:
condition: ["or"]  # I added the "or" but the empty brackets were already there from the UI.
    conditions:   # this is the start of the pasted in code, total of 5 lines.
      - condition: template
        value_template: ''{{ now().strftime('%H:%M') == '22:30' and now().weekday() < 5 }}''
      - condition: template
        value_template: ''{{ now().strftime('%H:%M') == '23:30' and now().weekday() > 4 }}''
action:
  - type: turn_off
    device_id: 7d6c642989cdd7c6f41097d87f103b74
    entity_id: switch.tpl_outlet_frog_string_lights
    domain: switch
#  - choose:   # The UI put these 3 lines in (this + next 2), I don't think I need them so I commented them out.
   #   - conditions: [] # I think above replaces this, where I put the templates.
   #     sequence: []  # I don't need this, or maybe "immediately"
  - type: turn_off
    device_id: d08fe8466e05f9279698661d901d37bc
    entity_id: light.tpl_light_lr_window1
    domain: light
  - type: turn_off
    device_id: 4c65874152b90a814c78b14e38edfce9
    entity_id: light.tpl_light_lr_stairs1
    domain: light

Amongst other things, your automation’s Time Trigger is incomplete. The error message is telling you that the Time Trigger is missing its at option. It’s required to tell the Time Trigger at what time to trigger.

Reference: Time Trigger

alias: example 
description: "LR Lights off for bedtime"
mode: single
trigger:
  - platform: time
    at:
      - '22:30:00'
      - '23:30:00'
condition:
  - condition: template
    value_template: >
      {{ (now().hour == 22 and now().weekday() < 5) or
         (now().hour == 23 and now().weekday() > 4) }}
action:
  - service: homeassistant.turn_off
    target:
      entity_id:
        - switch.tpl_outlet_frog_string_lights
        - light.tpl_light_lr_window1
        - light.tpl_light_lr_stairs1


EDIT

Correction. Removed trailing single quote.

You’ve got a vestigial ':slight_smile:

1 Like

i know @123 is the better one, but this is also completely doable in GUI:

description: ""
trigger:
  - platform: time
    at: "22:30:00"
    id: weekday
  - platform: time
    at: "23:30:00"
    id: weekend
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: weekend
          - condition: time
            after: "23:00:00"
            weekday:
              - sun
              - sat
        sequence:
          - service: homeassistant.turn_off
            target:
              entity_id:
                - switch.tpl_outlet_frog_string_lights
                - light.tpl_light_lr_window1
                - light.tpl_light_lr_stairs1
      - conditions:
          - condition: trigger
            id: weekday
          - condition: time
            after: "22:00:00"
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
        sequence:
          - service: homeassistant.turn_off
            target:
              entity_id:
                - switch.tpl_outlet_frog_string_lights
                - light.tpl_light_lr_window1
                - light.tpl_light_lr_stairs1
mode: single

I wondered about that, because in the UI, I was supposed to set the time, but I left it at 00:00:00. I was hoping if I did that, it would default to something else, like a helper or a template.
So…how do I fix that? The templates were supposed to do that.
In the yaml that the OP had posted (where I got the template), I started out just copying that, but got the same error when I tried to save it.
I first created 2 “helpers” that were made from “schedules” (Calendars). Two of them are intended turn lights on, the other is to turn them all off. But I have no clue how to use them. There seems to be all manner of documentation, but all the examples are really complicated. I wanted to start with something easy, while learning–but I can’t find anything!
(As an aside, from my searches it seems like many times when someone gets that error, it an indentation problem? I thought maybe that was the case here, but I don’t see it.)
Maybe someone can tell me how to use the “helper” functions? Or help me to fix this one with the templates?
(Thanks again in advance!)

If you did that, the example you posted above would have contained
at: '00:00:00'
but it doesn’t.

It doesn’t; it includes only what you specify. What led you to believe it would automatically enter a helper or template? How could it know what to provide?

If you believe that then you should review how an automation works.

Reference: Understanding Automation

There’s an example of a Calendar Trigger in the documentation.

Not sure why you would believe that given that the error message clearly tells you that a required key, namely the at key, wasn’t provided (i.e. it’s missing).

Message malformed: required key not provided @data{‘at’]

Did you see the corrected example I posted above?

ok, sorry for the delay in responding. I actually figured out how to help myself with a lot of this stuff, by using the logs and the developer tools. Awesome that they put those in this software!
Anyway, I tried creating an automation in a different place, and it seemed a LOT more straight forward, just finding the device (in Settings->Devices) and then creating an automation from there.
I don’t remember where I learned how to include the Schedule (Helper) I created for my lights, but it turns out I didn’t create it correctly. It’s easy enough to click on a time and have a box show up that fills a 30-minute slot, I started out clicking in one place to turn on, and another time to turn off. But there wasn’t anywhere to attach any properties (like “on” or “off”). So in the automation, I tried just having a state change in the schedule to be the trigger. That caused the lights to mostly work, but they misbehaved.
From checking the logs, followed by some experimentation, I figured out how to create the Schedule Helper correctly. All I had to do was then play around with the UI, and I figured out that my cursor would change to a double-arrow and I could drag the upper boundary of the time slot to extend as long as I wanted, to extend to the time I wanted the light to go off. Yeah, pretty basic, but somehow I missed it before.
Anyway, by doing that, I could easily set up the schedule to exactly control the “on” periods for my lights.
So, I’m learning. So far, I’ve gotten a bunch of automations set.
(I also figured out how to “cast” a Kasa outlet as a light, so I could then include it in a light group. That one was an accident, I was simply paying attention to the choices available in the “helpers” drop-down.)
Thanks for all the responses to my plea for help! They didn’t help me with that problem, but they helped me to learn how to use the program, and more importantly, how to help myself.
Next, I’m trying to figure out the device trackers, and how to automate the front door lock, so it’ll unlock automatically when we get home!