DesconBelgrade / Klimerko

☁ DIY Air Quality Monitoring Device
https://klimerko.org
GNU General Public License v3.0
114 stars 21 forks source link

Documenting MQTT messages #51

Open jrocketfingers opened 1 year ago

jrocketfingers commented 1 year ago

Hi folks, I'm running a Klimerko-like setup (same sensors, same NodeMCU, but possibly ESP32 instead), with ESPHome firmware. If I understand Klimerko's code correctly, it's just sending MQTT messages to api.allthingstalk.io, and klimerko.org is picking up Klimerko devices from there? If this is the case, I could contribute sensor data as well if I knew the messages being sent.

I should be able to deduce MQTT messages from the codebase, but are there any intentions to document this? If not, I'd be glad to document them if I manage to make it work. In that case, could you direct me on how/where would you want it documented?

jrocketfingers commented 1 year ago

Just read this off a Klimerko unit UART logs, pasting it here for future reference:

{"air-quality":{"value":"Good"},"pm1":{"value":16},"pm2-5":{"value":22},"pm10":{"value":24},"temperature":{"value":19.59},"humidity":{"value":26.51},"pressure":{"value":1003.7},"firmware":{"value":"2.0.0"},"wifi-signal":{"value":"Good"}}
epiller commented 1 year ago

Hey @jrocketfingers, Klimerko follows the AllThingsTalk MQTT topic/payload convention documented here.

jrocketfingers commented 1 year ago

Hey @epiller, thanks! I've seen that doc, but it seems to explain the per-asset messages, not the bulk transfer that Klimerko seems to be making. I assume you've actually used these device states documented on the data formats page?

epiller commented 1 year ago

@jrocketfingers Yup! That's exactly what's being used.

dkwireless commented 9 months ago

Can you please share config yaml so we dont have to do it all ove again? :)

jrocketfingers commented 9 months ago

Sadly I never got it fully operating, hence why I never closed this ticket. I might be misremembering, but the format itself was ok, I think I've failed somewhere else.

I have a mangled mess of a config, but the relevant part should be:

I'll hide it here so people skimming the thread don't copy paste, and then lose hours of their life for no good reason.

```yaml mqtt: id: att broker: "api.allthingstalk.io" client_id: "KLIMERKO" username: "maker:" password: "arbitrary" keepalive: 30s port: 1883 interval: - interval: 1min then: - logger.log: "Interval triggered" - mqtt.publish_json: topic: "device//state" payload: |- root["pm1"]["value"] = id(pm_1_0).state; root["pm2-5"]["value"] = id(pm_2_5).state; root["pm10"]["value"] = id(pm_10_0).state; root["temperature"]["value"] = 0; root["humidity"]["value"] = 0; root["pressure"]["value"] = 0; root["firmware"]["value"] = "2.1.0"; sensor: - platform: pmsx003 type: PMSX003 id: pmsensor pm_1_0: name: "Particulate Matter <1.0µm Concentration" id: "pm_1_0" on_value: - mqtt.publish_json: topic: "device//asset/pm1/state" payload: |- root["value"] = id(pm_1_0).state; ```

You'll have to tweak the sensors to fit your naming as well as add the temperature/humidity/pressure sensor, as I didn't have it at the time. All blocks are top level, indentation should be correct.

⚠️ I'm providing it as-is, it's been quite a while since I've worked on it, and I'm pretty sure this version is just a kitchen sink rather than a solution.

Let me know of any tweaks you make to it :)

dkwireless commented 9 months ago

No problem. Thanks. I'm still waiting on parts. Just ordered them. But will write here if I manage to build something.

dkwireless commented 6 months ago

Sucess! Thanks @jrocketfingers for pointing me in right direction.

You can find code on https://github.com/dkwireless/ESPHOME-Klimerko

jrocketfingers commented 6 months ago

Happy to have helped, thanks for pushing it across the finish line 🎉 I'll play around with it when I get the chance, in order to make a PR to add MQTT message shape to the docs. That being said I've no idea when it'll happen, so feel free to take it over if you have the time.