maxwellhadley / node-red-contrib-rfxcom

node-RED nodes to access an RFXtrx433 transceiver
BSD 2-Clause "Simplified" License
22 stars 13 forks source link

Update rfxcom.js, #112

Closed Anthony-vdm closed 10 months ago

Anthony-vdm commented 3 years ago

Set all in lower case in msg.payload return Then it can be integrated and mixed with other modules (e.g. through mqtt) without having to lowercase all payloads or develop any patch

maxwellhadley commented 3 years ago

Can you provide an example of another node or nodes that don't accept mixed-case strings, please? All my transmitter nodes ignore case.

Anthony-vdm commented 3 years ago

Sure One example among others: I have a physical mailbox with a chacon contact in it. Every time I get new email, I capture the RFXinfo and inject it in MQTT (I have the ID of the detector as topic and the on/off as payload) I use then MQTT to switch on the light (if dark) via a shelly that accept on/off and take a private picture through my netatmo that I sent to my telegram chat (botnet)

Another example: One button to switch on several lights. I pass the same msg.payload "on" to shelly and chacon. But as the nodered switches are case sensitive, I would have to create one set of switches "On/Off" for RFX and "on/off" for all the other ones.

The way I fix this is by "lowercasing" all msg.payloads in the rfxcom.js file, like I did in previous pull request in October

maxwellhadley commented 3 years ago

OK, I see, thanks. I also now learn that Shelly devices, in MQTT mode, require lower-case payload strings, so there is a definite wider requirement here. On the other hand, I am reluctant to break backward compatibility without good reason. What would be better is a settings switch offering lower case, UPPER CASE, or Mixed Case that works across all the RFX nodes.

I am using similar switches to control debug output, and the Somfy venetian blinds mode EU/US - but these settings clearly belong with the actual physical RFXtrx433 module, since you can connect more than one at a time, and are stored as properties of the rfx-port node. I don't want to put the 'case' switch into something transceiver-specific: it would fit better into a 'global settings' object, maybe another rfx-settings config node?

It also needs some thought, in that the code must tolerate an existing flow where the settings node does not exist, and 'do the right thing' without error. I wonder if there is anything else that such a node might be useful for?

I'd welcome your thoughts, comments or suggestions on this idea!

Anthony-vdm commented 3 years ago

The option to lowercase the msg.poayload based on a configuration parameter seems the most elegant one to me.

Another option, as a workaround, could be to lowercase the output of the node before injecting it in mqtt ?

maxwellhadley commented 10 months ago

Nodes lights-in, blinds-in, and detector-in nodes now all add an option to format the payload as Title Case, UPPER CASE, or lower case