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

More examples needed in the documentation #24

Closed rnusser closed 2 years ago

rnusser commented 2 years ago

Firstly, thanks for this great module. It worked straight out of the box and mqtt messages were published as soon as I turned on the lights!

However I am finding certain parts of the setup a bit difficult to understand, regarding controlling the lights.

In debug mode I do get a load of information: (pressing the lights switch button once without letting go)

2021-09-10 17:18:33,396 DEBUG: FE:F8:CA:48->FF:FF:FF:FF (-92 dBm): 0x01 ['0xf6', '0x30', '0xfe', '0xf8', '0xca', '0x48', '0x30'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x5c', '0x0'] OrderedDict()
2021-09-10 17:18:33,400 INFO: received: FE:F8:CA:48->FF:FF:FF:FF (-92 dBm): 0x01 ['0xf6', '0x30', '0xfe', '0xf8', '0xca', '0x48', '0x30'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x5c', '0x0'] OrderedDict()
2021-09-10 17:18:33,423 DEBUG: enocean/passage_end: R1 (Rocker 1st action)=Button AO 
2021-09-10 17:18:33,431 DEBUG: enocean/passage_end: EB (Energy bow)=pressed 
2021-09-10 17:18:33,439 DEBUG: enocean/passage_end: R2 (Rocker 2nd action)=Button AI 
2021-09-10 17:18:33,447 DEBUG: enocean/passage_end: SA (2nd action)=No 2nd action 
2021-09-10 17:18:33,454 DEBUG: enocean/passage_end: T21 (T21)=True 
2021-09-10 17:18:33,464 DEBUG: enocean/passage_end: NU (NU)=True 

I would like to send this message to turn the lights on using MQTT. The document mentions default_data, in the hvac example: default_data = 0x32790008, which I didn't understand at all. What is that data, and how do I work out what I need.

Also for the hvac example a message is sent to enocean/heating/req/SP which is "set point", what would that be in the case of the switch?

If reading the code using hexdump -C < /dev/ttyAMA0 I see something like this:

55 00 07 07 01 7a f6 70 fe fa 41 49 30 00 ff ff ff ff 5b 00 0a

I suppose this somehow relates to that default_data?

Any help would be appreciated.

romor commented 2 years ago

Typically, an Enocean message contains multiple data bytes to transfer. To create its content, default_data is the starting point for the message. This can then be adapted using MQTT messages to customize various parts of the message based on the EEP data interpretation (e.g. changing the "set point" content of the data).

rnusser commented 2 years ago

So in my case it seems that telegrams from PTM transmitters F6-RPS EEP (Enocean telegram type for repeated switch communication) has it's data in the byte that follows 0xF6, being 0x30. After that there is the 4 byte address, and then another 1 byte for status (T21 = bit 7, NU = bit 6, RC (repeater count = 6 bits)

So the byte 0x30 is the actual data containing the R1, EB, R2, and SA.

Is the default_data optional, or must it be defined. If it is optional could one form the entire message by sending all the information usually received:

mosquitto_pub -d -h 192.168.100.30 -p 1883 -t 'enocean/passage_end/req/R1' -m '1'
mosquitto_pub -d -h 192.168.100.30 -p 1883 -t 'enocean/passage_end/req/EB' -m '1'
mosquitto_pub -d -h 192.168.100.30 -p 1883 -t 'enocean/passage_end/req/R2' -m '0'
mosquitto_pub -d -h 192.168.100.30 -p 1883 -t 'enocean/passage_end/req/T21' -m 'True'
mosquitto_pub -d -h 192.168.100.30 -p 1883 -t 'enocean/passage_end/req/NU' -m 'True'
mosquitto_pub -d -h 192.168.100.30 -p 1883 -t 'enocean/passage_end/req/send' -m '1'

Or have I totally misunderstood that bit?

I have tried but with no luck.

I have tried setting the default to 0x30 and 0xf610fef8ca4830.

romor commented 2 years ago

Is the default_data optional, or must it be defined. If it is optional could one form the entire message by sending all the information usually received:

Right now, default_data is not optional. Good idea, to allow this in future. However, you can just set it to zero and assemble the data content as you wrote.

I have tried but with no luck.

Could you give more information here? I assume the EnOcean packet is sent but with wrong content? Which content is sent (you should see this in the debug log)?

rnusser commented 2 years ago

Actually nothing seems to be happening according to the logs:

2021-10-08 15:09:53,762 DEBUG: Sending PINGREQ
2021-10-08 15:09:53,771 DEBUG: Received PINGRESP
2021-10-08 15:10:39,062 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/R1', ...  (1 bytes)
2021-10-08 15:10:39,107 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/EB', ...  (1 bytes)
2021-10-08 15:10:39,154 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/R2', ...  (1 bytes)
2021-10-08 15:10:39,201 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/T21', ...  (1 bytes)
2021-10-08 15:10:39,245 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/NU', ...  (1 bytes)
2021-10-08 15:10:39,289 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/send', ...  (1 bytes)
2021-10-08 15:10:54,319 DEBUG: Sending PINGREQ
2021-10-08 15:10:54,328 DEBUG: Received PINGRESP
romor commented 2 years ago

Thanks, I see.

Please try it again with the latest git commit. Sending of packets by MQTT trigger was broken in the revision before.

You can also omit the default data now, if you want.

rnusser commented 2 years ago

Thank you for the update. Now this is what I get (without a default set, or a default of 0x00)

2021-10-10 13:36:39,967 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/R1', ...  (1 bytes)
2021-10-10 13:36:39,972 DEBUG: Got MQTT message: enocean/passage_end/req/R1
2021-10-10 13:36:40,009 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/EB', ...  (1 bytes)
2021-10-10 13:36:40,014 DEBUG: Got MQTT message: enocean/passage_end/req/EB
2021-10-10 13:36:40,055 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/R2', ...  (1 bytes)
2021-10-10 13:36:40,060 DEBUG: Got MQTT message: enocean/passage_end/req/R2
2021-10-10 13:36:40,100 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/T21', ...  (1 bytes)
2021-10-10 13:36:40,105 DEBUG: Got MQTT message: enocean/passage_end/req/T21
2021-10-10 13:36:40,147 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/NU', ...  (1 bytes)
2021-10-10 13:36:40,152 DEBUG: Got MQTT message: enocean/passage_end/req/NU
2021-10-10 13:36:40,193 DEBUG: Received PUBLISH (d0, q0, r0, m0), 'enocean/passage_end/req/send', ...  (1 bytes)
2021-10-10 13:36:40,198 DEBUG: Got MQTT message: enocean/passage_end/req/send
2021-10-10 13:36:40,202 DEBUG: Trigger message to: enocean/passage_end
2021-10-10 13:36:40,227 WARNING: Cannot find data description for shortcut R1
2021-10-10 13:36:40,238 WARNING: Cannot find data description for shortcut EB
2021-10-10 13:36:40,248 WARNING: Cannot find data description for shortcut R2
2021-10-10 13:36:40,257 WARNING: Cannot find data description for shortcut T21
2021-10-10 13:36:40,266 WARNING: Cannot find data description for shortcut NU
2021-10-10 13:36:40,273 INFO: sending: FF:CC:62:00->FE:F8:CA:48 (-255 dBm): 0x01 ['0xa5', '0x0', '0x0', '0x0', '0x0', '0xff', '0xcc', '0x62', '0x0', '0x0'] ['0x3', '0xfe', '0xf8', '0xca', '0x48', '0xff', '0x0'] OrderedDict([('TMP', {'description': 'Temperature (linear)', 'unit': '°C', 'value': 10.0,  
'raw_value': 0})])
2021-10-10 13:36:40,332 INFO: Sending packet
2021-10-10 13:36:40,337 DEBUG: FF:CC:62:00->FE:F8:CA:48 (-255 dBm): 0x01 ['0xa5', '0x0', '0x0', '0x0', '0x0', '0xff', '0xcc', '0x62', '0x0', '0x0'] ['0x3', '0xfe', '0xf8', '0xca', '0x48', '0xff', '0x0'] OrderedDict([('TMP', {'description': 'Temperature (linear)', 'unit': '°C', 'value': 10.0, 'raw_vall
ue': 0})])
2021-10-10 13:36:40,445 DEBUG: 0x02 ['0x0'] [] OrderedDict()
2021-10-10 13:36:40,448 INFO: got response packet: OK
romor commented 2 years ago

Packets are sent now. However, the packet data cannot be set as the device profile is not found.

Please update again to the latest version. I found a bug that could have caused your issue.

Btw, you might want to add some delay between your mqtt messages to give the library time to process them before the next arrives.

rnusser commented 2 years ago

Now we have some more activity:

2021-10-14 21:04:28,938 DEBUG: Got MQTT message: enocean/passage_end/req/send
2021-10-14 21:04:28,942 DEBUG: Trigger message to: enocean/passage_end
2021-10-14 21:04:28,990 INFO: sending: FF:CC:62:00->FE:F8:CA:48 (-255 dBm): 0x01 ['0xf6', '0x32', '0x0', '0x0', '0x0', '0x0', '0x0'] ['0x3', '0xfe', '0xf8', '0xca', '0x48', '0xff', '0x0'] OrderedDict([('R1', {'description': 'Rocker 1st action', 'unit': '', 'value': 'Button AI', 'raw_value': 0}), ('EB', {'description': 'Energy bow', 'unit': '', 'value': 'released', 'raw_value': 0}), ('R2', {'description': 'Rocker 2nd action', 'unit': '', 'value': 'Button AI', 'raw_value': 0}), ('SA', {'description': '2nd action', 'unit': '', 'value': 'No 2nd action', 'raw_value': 0}), ('T21', {'description': 'T21', 'unit': '', 'value': False, 'raw_value': 0}), ('NU', {'description': 'NU', 'unit': '', 'value': False, 'raw_value': 0})])
2021-10-14 21:04:29,019 INFO: Sending packet
2021-10-14 21:04:29,023 DEBUG: FF:CC:62:00->FE:F8:CA:48 (-255 dBm): 0x01 ['0xf6', '0x32', '0x0', '0x0', '0x0', '0x0', '0x0'] ['0x3', '0xfe', '0xf8', '0xca', '0x48', '0xff', '0x0'] OrderedDict([('R1', {'description': 'Rocker 1st action', 'unit': '', 'value': 'Button AI', 'raw_value': 0}), ('EB', {'description': 'Energy bow', 'unit': '', 'value': 'released', 'raw_value': 0}), ('R2', {'description': 'Rocker 2nd action', 'unit': '', 'value': 'Button AI', 'raw_value': 0}), ('SA', {'description': '2nd action', 'unit': '', 'value': 'No 2nd action', 'raw_value': 0}), ('T21', {'description': 'T21', 'unit': '', 'value': False, 'raw_value': 0}), ('NU', {'description': 'NU', 'unit': '', 'value': False, 'raw_value': 0})])
2021-10-14 21:04:29,132 DEBUG: 0x02 ['0x0'] [] OrderedDict()
2021-10-14 21:04:29,134 INFO: got response packet: OK

I am not so sure about the unit and value. Those aren't something I get when pressing the light switch.

romor commented 2 years ago

Ok. So, it is working as expected now? Or do you expect other packet data to be sent?

rnusser commented 2 years ago

Well, I still have not managed to turn the lights on or off, so I am not quite sure what I might be missing or what is not working.

I might have to try the Python EnOcean library and see if i can get it working with that first.

romor commented 2 years ago

Closing this for now. Please reopen or file a more specific issue as needed.