embyt / enocean-mqtt

Receives messages from an enOcean serial interface (USB) and provides selected messages to an MQTT broker.
GNU General Public License v3.0
42 stars 21 forks source link

Setting status bits in send messages #41

Closed LarsKoeppel closed 1 year ago

LarsKoeppel commented 1 year ago

Hello,

i use HA_enoceanmqtt which builds on enocean-mqtt to integrate and control my devices in Home Assistant. As described in this discussion, my shutter only seems to respond to messages that have the status bits set correctly. So my question is if it would be possible to implement this functionality in enocean-mqtt.

Best regards

romor commented 1 year ago

I read the discussion in the linked thread but I do not really understand what is missing. The packet data are set using set_eep() in the underlying enocean library.

Are the status bits present there in the EEP profile and supported? It is not my intention to forward you one more time, but I guess this topic is more related to the enocean library?

LarsKoeppel commented 1 year ago

Hi @romor,

the status bits are present in the EEP and are requered from enocean. I used this EEP with this specification. As can be seen in the debug output in the other discussion, the status bits are not taken into account in the array of data to be sent, which is why I assumed that it was already ignored when the message was created. Or is the message to be sent created in the enocean library? Is this methode used to generate the message to send?

This is the message from debug, in the other discussion:

['0xf6', '0x70', '0xff', '0xab', '0xf3', '0x1', '0x0']
[<EEP>, <data>, <sender>, <sender>, <sender>, <sender>, <status bits>]

And the status bits should be in this case a 0x30.

mak-gitdev commented 1 year ago

Hi @romor, Hi @LarsKoeppel

I think I found the problem. The problem I think, comes from the set_eep() function which does not set the status bits of the packet. The status bits have to be appended to the packet data in the same manner as it is done here.

As we use ERP1 and its DATA structure is always [\\\\], we could solve this issue in communicator.py by adding after L461

packet.data[-1] = packet.status

@romor, is this OK for you or do you have a better idea ? If OK, do you want me to make the pull request ?

romor commented 1 year ago

@mak-gitdev, thanks for your support!

I still do not fully understand why the status bits are not set within set_eep(). Is this intentionally not done there or just missing?

However, I trust in your proposal and for me it's fine to add it here, even if it is a work-around. Feel free to raise a pull request.

mak-gitdev commented 1 year ago

@romor, I am as baffled as you are but I think it is done intentionally because in the Packet.create() function, the data payload is first set with the set_eep() function, then the status bits are set separately as aforementioned.

Ok for the pull request. Thanks.