Initially, the script runs fine, but after a few days it stops. If I edit and save the script it starts working again. The logs when it fails show no steps are executed and when I attempt to run the script manually once it has failed, I get:
Failed to call service script/pause_vehicle_detector. 'NoneType' object has no attribute 'async_turn_on'
The script is triggered by a few different automations, such as garage door open or someone arrives home. The automations/triggers run fine, and show they invoked the script. There are entries in the logbook when the script works but none when it fails. Nothing is in the homeassistant log.
OK, I solved or worked around my problem. Apparently it’s a bug caused by having a script and automation with the same name. I have an automation trigger the script and also can trigger the script via the API. When I open my door, it turns on the person detector, and while it’s off it keeps extending the off period by five minutes when the cameras see a person. So I can go outside for 30 minutes and the notifications will be off, but once I’m back inside 5 minutes I get notifications if someone appears on my property. Same with the vehicles.
I’m facing this hurdle too, but the names of my Automation & Script are not the same. Can you say more about the bug you identified, or any other details?
My use is “when a fan on a smart outlet gets turned on or off, begin an endlessly repeating script that will toggle the fan on/off at intervals”. I desire having some air circulation, such that the fan is on for 7 minutes and off for 16. I’m using the Automation to kick off the script. And the Script is set to turn on and off the fan with delays, then end with calling itself. But the Automation is hitting this same error you were seeing. 'NoneType' object has no attribute 'async_turn_on'
FWIW, I worked out my issue with an Automation that calls a Script. Baseline, the fan is off. But when the fan is manually turned on, it enters a cycle: 6min on, 4min off.