A command line sensor I’ve had for some time suddenly started misbehaving. To boot, misbehaving in a very odd way. The sensor is contained within its own command_line.yaml file.
The sensor works. I have a live HA sensor entity… it just isn’t getting the data entirely correctly.
“Last_updated” is generated by the python script itself; everything else is pulled from a webpage via the script/BeautifulSoup.
Here’s the odd bit – the script DOES run, because HA is being fed the “last_updated” data; everything else however, is blank. I can verify this both by looking at the sensor entity, as well as by looking at a text file the python script outputs (raw json). However, if I run the script manually, the output is completely correct, including all the data being pulled from the webpage!
Has anyone seen anything like this, or have any advice as to how to troubleshoot?
-J
UPDATE:
Thanks everyone who helped – at least we all learned something about indentation!
Nothing was wrong with HA or the script persay. The URL I was scraping had changed … and in a fairly subtle way so I didn’t notice it when checking the code.
… and same issue. When HA runs the script all it gets is “last_updated” and fails to retrieve anything from the webpage. When I run the script locally… it produces the JSON as designed.
Also, I think that py file should be in a folder which is accessible for HA in docker. Like inside “/config/my_scripts” where “my_scripts” is declared in “allowlist_dir” (or how it is called) option.