Hi! I ran into a problem with the default timeout setting. I tried searching for forums a way around it and haven’t found anything so far. Default timeout is probably around 15-20 seconds. I tried to manually set timeout for a sensor but there doesn’t seem to be a feature for that. Is that something I could edit easily from source code?
My sensor is a python script that scans three Ruuvitag weather sensors via bluetooth. The script works and it takes about 23 seconds to complete. I have successfully scanned one sensor which takes about 11 seconds and timeout isn’t a problem in that case. I could try configuring a sensor for each of these, but in my case it would be easier to get the info from all the sensors and after filter it with a template sensor. My raspberry is years old and slow, but this is the first time it gives me a real problem.
My gut reaction is you might want to consider running the script another way, say as a cron job, and have it write the values to a file. Then have your HA sensor just read the most recent values from the file.
Thanks for the reply! I actually started thinking about that right after posting here. I will take a look into it. Looks like the File Sensor component is the thing to try here.
Yep, just saw someone else mention the file sensor. Or I understand that MQTT is a popular method, too. I haven’t tried either yet, though, so can’t really comment further about either.
You could use the rest api of HA and even run the python script as a crons job every 5 mins. I do that to process some security camera images before HA consumes it.
Thanks for the tips. I decided to read about REST API Python bindings and that actually does the job quite nicely after some initial setup. I spent quite some time thinking what kind of sensor to put in the HA conf file for dumping the data via rest but then I found out it doesn’t need any sensors and the rest makes the sensors on the go and with couple attributes formatting can be set. So now I have a python script running every five minutes triggered by cron.
If anyone has a need for this, here’s a quick guide
The things needed:
ruuvitag and home assistant python modules installed (I decided to run everything as the homeassistant user and use the ha environment as source so some copying of modules was required.
Sudo rights for bluetooth services for ha user. (use “sudo visudo”)