theengs / decoder

Efficient, portable and lightweight library for Internet of Things payload decoding.
https://decoder.theengs.io
GNU General Public License v3.0
123 stars 43 forks source link

Support request for ThermoPro TP357S #425

Closed ewaldc closed 1 year ago

ewaldc commented 1 year ago

Is your feature request related to a problem? Please describe. ThermoPro has replaced the TP357 by the TP357S, which is recognized only as a generic device and as such no temperature/humidity is being reported. I forked the repo and made the necessary changes to TPTH_json.h (basically just adding the TP357S in the logical OR condition) and was able to recompile the decoder library, but not to regenerate the python package (there is not much info on how to do that). I managed to create a new EGG file once, but subsequent builds failed (MSVC compiler complains about missing stddef.h or some scikit-build integration issue) Manufacturing data produced by the TP357S:

{"manufacturerdata": "c2d60043220b01", "name": "TP357S (AEF2)", "id": "FF:AC:31:C7:AE:F2", "rssi": 0}

Other than this the gateway solution is working flawlessly (created a Systemd service on RPI4 in combination with OpenHab) - congratulation on this great project !

Describe the solution you'd like I am happy to contribute with a pull request, but I would need to be able to build and test the python package first. Any hints appreciated. Alternatively, if the development team is willing to add TP357S support directly, this is even a better solution :-).

Describe alternatives you've considered

  1. Contribute the change myself (code change succeeded but rebuild failed).
  2. Given a new (test) version, I would be happy to validate and report back.

Thanks in advance, Ewald

koenvervloesem commented 1 year ago

The Python package can be built by running pip install . from the repository's python directory. We would be happy to accept a pull request adding support for the TP357S.

ewaldc commented 1 year ago

Thanks for this lighning fast response! I was able to rebuild the python package :-). It's getting late here, will test this weekend and report back.

DigiH commented 1 year ago

Hi @ewaldc,

Thanks a lot for the update on the ThermoPro TP357S.

Is it just a hardware revision update, or a totally new model? I can't seem to find any info on the TP357S. Do you have any link?

I forked the repo and made the necessary changes to TPTH_json.h (basically just adding the TP357S in the logical OR condition)

The already existing model condition

"name", "index", 0, "TP357", …

should work fine with even the TP357S, as there is only the additional S trailing it, but the manufacturerdata you quoted above is one octet longer, so I changed the AND model condition to

… "&", "manufacturerdata", ">=", 12, "index", 0, "c2"

to also catch the 14 long TP357S manufacturerdata.

You can give this change a test with the branch

https://github.com/DigiH/decoder/tree/TP357S

Leaving the docs unchanged until it is clearer if this is a separate new model or a hardware revsion of the TP357.

Thanks

ewaldc commented 1 year ago

Super, will test today. Externally, the TP357 and TP357S look exactly the same, to the point that the TP357S mentions TP357 as product number. So I guess it's just a HW revision. I did my best to try to fix it myself, but it would have taken an extra day or so. I had already discovered the scananddecode app and concluded that it's just a decoder issue.

ewaldc commented 1 year ago

I took the quick route and just modified the one file changed. ScanAndDecode results look outstanding:

F9:FA:46:4A:09:15:AdvertisementData(local_name='TP357S (0915)', manufacturer_data={52674: b'\x00>"\x0b\x01'}, rssi=0)
data sent to decoder:  {"manufacturerdata": "c2cd003e220b01", "name": "TP357S (0915)", "id": "F9:FA:46:4A:09:15", "rssi": 0}
TheengsDecoder found device: {"manufacturerdata":"c2cd003e220b01","name":"TP357S (0915)","id":"F9:FA:46:4A:09:15","rssi":0,"brand":"ThermoPro","model":"TH Sensor","model_id":"TP35X/393","type":"THB","cidc":false,"acts":true,"tempc":20.5,"tempf":68.9,"hum":62}
{"properties":{"tempc":{"unit":"°C","name":"temperature"},"hum":{"unit":"%","name":"humidity"}}}
brand: ThermoPro , model: TH Sensor

Also in MQTTExplorer the messages are coming through perfectly, with RSSI being non zero most of the time also. Just need to figure out how to build it for ARM Linux, as I run it normally on a RPI 3 and Orange Pi 5+.

Problem solved in a record time :-)

DigiH commented 1 year ago

Thanks for the verification @ewaldc

Merging into the Theengs Decoder development branch …

If any reaming build queries remain please open a discussion for Theengs Decoder or Theengs Gateway.

DigiH commented 1 year ago

@ewaldc

BTW, if you have some time and feel like taking a picture of your TP357S ("the TP357 and TP357S look exactly the same") on a white background and would allow us to use it in our Decoder compatibility listing, that would be great.

You could just post the image here in the thread and we can include it in the docs.

Thanks