opendata-stuttgart / sensors-software

sourcecode for reading sensor data
571 stars 308 forks source link

How connect sensor to HomeAssistant? #405

Open andreas-bulling opened 5 years ago

andreas-bulling commented 5 years ago

Hi,

I was wondering what the easiest/best way is to get the sensor readings into HomeAssistant. Any standard solutions here (MQTT doesn't seem to be one of them) or people who have been successful with such an integration?

I know that there is a luftdaten component but that requires a detour over the internet...

ricki-z commented 5 years ago

It should be possible to change the mentioned component so that it is using the local json endpoint http:///data.json . But this endpoint is shut down for some seconds while the firmware is sending data to the external servers (otherwise the NodeMCU will run out of memory).

lichtteil commented 5 years ago

@andreas-bulling I also have trouble with the luftdaten component (I wrote the very first version of it but it was refactored so much that I have no idea what it is trying to do now :D). I will now try to use the REST-Component and access the sensor data like this: http://192.168.x.y/data.json

lichtteil commented 5 years ago

@andreas-bulling I took now my old code of the luftdaten component and changed it so that you can provide the IP address to your local sensor. Feel free to test and give feedback: https://github.com/lichtteil/local_luftdaten

rzr commented 5 years ago

An other option would be to run a rest to mqtt service on your HomeAssistant host (or elsewhere).

It's trivial with IoT.js: https://github.com/SamsungInternet/iotjs-express/commit/0ef4de558396f90886bf4d3f28e252298a2ab05e

I can provide more hints if needed.

UFROF commented 4 years ago

Hi, I also preferred reading the data directly, here my HA conf for that (if you have other sensors attached) look in ../data.json with your browser and change the number in brackets to the correct position number of the value - of course you probably need also to change the IP):

sensor:

I assume there is probably even a more elegant way via the rest interface that will probably be able to read the json-date natively but I have not figured it out yet...

beanieboi commented 3 years ago

I'm using the rest sensor to fetch the values once and sensor templates to extract all values. This way I can calculate Air Quality Index and a Air Quality Index Description as well. https://gist.github.com/beanieboi/1c94be3d97bd8bb618f3a31bee12c296

thomasdbnet commented 2 years ago

thanks beanieboy works perfect. . if not you can always flash the esp to tasmota , it supports the sensor and homeassistant aswel. but it can't be done over the air i think ?