I’m getting this error when I try to run an automation which I’ve created using the Lovelace UI in HA Core:
Invalid config for [automation]: required key not provided @ data['device_id']. Got None.
The idea is to respond to the “on” payload for my binary sensor by arming my home alarm system. I can’t work out which key I need to enter. The definition is below.
Could anyone advise?
The screenshot seems to be a little small, so here’s what I’ve entered (any field not listed I have left blank):
Click the overflow menu (three vertical dots) in the upper right hand corner of the Automation Editor and select “Edit in YAML”. Copy-paste the displayed YAML text.
The error message is referring to device_id but the automation you posted doesn’t appear to reference device_id. Are you certain the error message is complaining about this particular automation? The answer to that question might be revealed in the YAML text you post.
When you save an automation (via the Automation Editor) it checks the validity of all of your automations (not just the one you’re editing). As suspected, that automation contains no reference to device_id so the error is elsewhere.
You can also execute Configuration > Server Controls > Check Configuration and it’s likely to report the same error.
Examine the other automations you have and find the ones that refer to device_id. One of them appears to be missing required information.
The automation is not firing when I press the button which triggers “payload_on”
My Server Controls options don’t include a “Check Configuration” option (only Restart or Stop server)
Apart from removing my automations one at a time, is there any way of working out which one is causing the error?
If binary_sensor.sonoff_433mhz_remote changes from off to on but the automation fails to trigger, it implies the error message you saw has prevented Home Assistant from loading automations (i.e. it’s not just this automation that won’t work). You should run Check Configuration and then inspect Configuration > Logs.
That’s brilliant - thanks. I’ve now identified and removed the offending automation, and no longer get that error message. The automation now seems to be firing, but one of the actions is not working correctly (TTS using Google Home) - I’ve opened a separate question for that.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.