Anrijs / Aranet4-Python

Aranet4, Aranet2 and Aranet Radiation Python client
MIT License
212 stars 18 forks source link

FEATURE REQUEST: mqtt.publish would be a killer! #1

Closed austrisv closed 4 years ago

austrisv commented 5 years ago

Anrij, THANK YOU a ton for this. I had created my own quick&dirty aranet4 reader, but yours is so much better. Having also MQTT publish would be a killer feature, as it would open your project for all of mqtt-friendly smart home systems (like openhab, hass, domoticz, etc). I could comment with my own code that does through paho-mqtt ... though it is a kindergarten level, comparing to yours ... I'm too shy for a proper pull ;)

Anrijs commented 5 years ago

I haven't checked paho-mqtt, but I might do it later. For now I have separated main logic in library to make it easier to use for other projects. You can use it in your own project by adding aranet4 folder to your project and in main code just import it.

Something like this:

import aranet4

device_mac = "00:00:00:00:00:00"
ar4 = aranet4.Aranet4(device_mac)
current = ar4.currentReadings()

print "Temperature:", current["temperature"]
print "Humidity:", current["humidity"]
print "Pressure:", current["pressure"]
print "CO2:", current["
austrisv commented 5 years ago

lovely, Thank You for this! I also realized for one of my scenarios I could use -u to post directly to influx. But for another one (and for entire smart home community) the mqtt would still be great! Kudos!

Anrijs commented 4 years ago

I have added mqtt.publish as an example. It can be found at examples/mqtt/publish.py