jlama / powertagd

15 stars 7 forks source link

[Feature Request] MQTT #1

Open fakethinkpad85 opened 1 year ago

fakethinkpad85 commented 1 year ago

Noticed the description mentioned upcoming MQTT support and just wanted to let it be known that it would be a welcome feature. Dont run your firmware at the moment (or own a Dongle) but if it would support MQTT directly to Home Assistant i would really appreciate that.

Seems this is the only hope or apprcoach that would support having the PowerTags be paired to HA at the moment, been looking for almost a year for a solution to this.

jlama commented 1 year ago

I can look into this if you can provide what kind of MQTT message format HA expects.

jonassoderback commented 1 year ago

it is possible to manage all types of mqtt messages in HA by manual configuration or by using eg node red . but if you want values sent via mqtt to enter fully automatically in HA, it is required that the mqtt messages are sent in a specific way.

Seekersdk commented 1 year ago

Im no programmer, but after some inspirtation from Ocara and help Morten Vinding, and a long discussion with ChatGPT, I now have a powertaged2mqtt HA edition. It will auto discover and you should be able to find the powertag under entities. Might need a routined programmers touch, but it works.

Compile it, add it to your powertagd folder, and run it with (change the IP, user and password): ./powertagd -d /dev/ttyACM0 | ./powertag2mqtt -broker tcp://10.0.2.11:1883 -user YOURUSER-password YOURPASSWORD

Credit: https://github.com/octera/energy-center/tree/main/powertag?fbclid=IwAR2A0RXt6b_I2pR4gDLSSGt0RxWB3d7syT4UOet9jsvkbNWSY6xvOd6Y6dU https://github.com/MortenVinding/energy-center/tree/main/powertag

powertag_HA.zip

Seekersdk commented 1 year ago

and just to finish it off, so you can put the data into the energy dashboard:

sensor:

Eg.:

sensor:

Thanks to Jlama for the great work with the dongle software :) Much appriciated. Next step would be to make an addon for HA, and run the powertagd and powertag2mqtt inside a docker there.

SeanHood commented 10 months ago

Hey folks, I've been working on adding MQTT (and HA's MQTT Discovery) support to this project. It's not in the shape for a PR yet but I've been running it reasonably reliably for a couple weeks now.

https://github.com/jlama/powertagd/compare/master...SeanHood:powertagd:master

jonassoderback commented 9 months ago

It would be very nice if you could implement support for MQTT communication. I've managed to get your application running in my rpi4 and get values from the powertag sensors, but I can't manage to implement a function to send the data out to external mqtt broker / Home Assistant. It would be greatly appreciated if you could find time to finish MQTT support.

jonassoderback commented 9 months ago

Hey folks, I've been working on adding MQTT (and HA's MQTT Discovery) support to this project. It's not in the shape for a PR yet but I've been running it reasonably reliably for a couple weeks now.

master...SeanHood:powertagd:master

SeanHood: I get this error when I try to install your modified version of jlama/powertagd. Any idea what is wrong or what I am doing wrong?

pi@pitouch:~/build$ git clone https://github.com/SeanHood/powertagd Cloning into 'powertagd'... remote: Enumerating objects: 200, done. remote: Counting objects: 100% (200/200), done. remote: Compressing objects: 100% (123/123), done. remote: Total 200 (delta 108), reused 167 (delta 76), pack-reused 0 Receiving objects: 100% (200/200), 6.05 MiB | 5.71 MiB/s, done. Resolving deltas: 100% (108/108), done. pi@pitouch:~/build$ cd ~/build/powertagd/src && make cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -DENABLE_MQTT -c -o ash.o ash.c cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -DENABLE_MQTT -c -o crc-ccitt.o crc-ccitt.c cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -DENABLE_MQTT -c -o ezsp.o ezsp.c cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -DENABLE_MQTT -c -o ezsp_types.o ezsp_types.c cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -DENABLE_MQTT -c -o gp.o gp.c gp.c: In function ‘gp_handle_commissioning_frame’: gp.c:335:11: warning: variable ‘gpd_key_mic’ set but not used [-Wunused-but-set-variable] 335 | uint32_t gpd_key_mic = 0; | ^~~ cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -DENABLE_MQTT -c -o log.o log.c cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -DENABLE_MQTT -c -o serial.o serial.c cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -DENABLE_MQTT -c -o powertag.o powertag.c make: *** No rule to make target 'cJSON.o', needed by 'powertagd'. Stop. pi@pitouch:~/build/powertagd/src$