I figured that would work, but how would that work with polling at a reasonably high frequency?
If I’m reading a voltage from a PIR it needs to be a reasonably high frequency of say 4Hz. Firing a script 4 times a second might not work very well, particularly if you have multiple PIRs.
I’m really just starting to look into it, so I don’t know if it’s are real problem or how it would work in practice, just thinking about which way to tackle it. It would have been much easier if they just released a python 3 wrapper for the device!
If you don’t want to poll, you’ll have to push. You could do this by wrapping the Python 2.7 script with another script that can pass messages between processes - using MQTT might be a good choice. Then you could just create an MQTT sensor in HASS.
I’m pretty green to this, but that does sound like a more elegant solution. I know nothing about MQTT, but it seems to be well documented, so shouldn’t be an issue.
Is there any reason I couldn’t just bypass MQTT and use a python subprocess? Essentially the same type of solution, but calling the python 2 subprocess directly without going through MQTT. This may not be any more elegant and may be more difficult, but without any MQTT experience, I’m not sure how easy it is.
Before I went too far down the rabbit hole, I thankfully found that someone has forked the original labjack wrapper and added some limited python 3 support. Hopefully it will have the necessary sensors I need and I will be able to keep it all within Python 3.
A subprocess would work too, and would probably be easier since you don’t have any existing MQTT infrastructure. But if there is Python 3 support, that would definitely be best!