Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pilight value as subject #752

Merged

Conversation

hugokernel
Copy link
Contributor

Thank you for this project ;)

The Pilight gateway with the valueAsASubject parameter does not work (compilation problem).

This PR fixes this problem and closes the #408 ticket.

I also added a patch that allows to find a correct ID (in order to have a non null topic) because PiLight only reads ID and ignores the others fields.

One question, in the ZgatewayPilight.ino file, there are this line: RFPiLightdata.set("length", (char*)deviceID.c_str()); is it normal to set the length value from the deviceID value?

Thank you.

@1technophile 1technophile linked an issue Sep 1, 2020 that may be closed by this pull request
@1technophile
Copy link
Owner

Thanks for this PR!

One question, in the ZgatewayPilight.ino file, there are this line: RFPiLightdata.set("length", (char*)deviceID.c_str()); is it normal to set the length value from the deviceID value?

Seems strange, I think it should be removed.

@1technophile 1technophile added this to the v0.9.5 milestone Sep 1, 2020
@hugokernel
Copy link
Contributor Author

One question, in the ZgatewayPilight.ino file, there are this line: RFPiLightdata.set("length", (char*)deviceID.c_str()); is it normal to set the length value from the deviceID value?

Seems strange, I think it should be removed.

Or replaced with the length of the payload ?

What is the purpose of the length field in general?

@1technophile
Copy link
Owner

1technophile commented Sep 1, 2020

Or replaced with the length of the payload ?
What is the purpose of the length field in general?

I think it is as an analogy with the length obtained by RCSwitch, which is the number of signal bits.

We would have the length with Pilight if receiving a pulse train (the raw signal) through setPulseTrainCallBack , the current data used with Pilight throught setCallback is at a higher level compared to RCSwitch , so I don't think we need it.

@hugokernel
Copy link
Contributor Author

Or replaced with the length of the payload ?
What is the purpose of the length field in general?

I think it is as an analogy with the length obtained by RCSwitch, which is the number of signal bits.

We would have the length with Pilight if receiving a pulse train (the raw signal) through setPulseTrainCallBack , the current data used with Pilight throught setCallback is at a higher level compared to RCSwitch , so I don't think we need it.

👍

@hugokernel
Copy link
Contributor Author

When a radio frame arrives, Pilight will test all the protocols he knows in order to parse the content in search of the right one.

It is therefore quite possible to obtain several protocols that match for the same frame.

The problem is that the same frame can return several different protocols but with the same ID, the frames being published with the corresponding ID in the topic, all the protocols are not visible.

It would be interesting to have an option to add the protocol in the topic, for example, instead of having:

home/OpenMQTTGateway/PilighttoMQTT/32342.

We would have:

home/OpenMQTTGateway/PilighttoMQTT/iwds07/32342

The patch is extremely simple and very useful with PiLight (I use it), maybe it would be a good idea to add a general option for that or add it at least when Pilight is configured?

If you want, I can submit my commit in this PR.

@1technophile
Copy link
Owner

The problem is that the same frame can return several different protocols but with the same ID, the frames being published with the corresponding ID in the topic, all the protocols are not visible.

Do you mean that they are not published but overwritten by the last one?

@hugokernel
Copy link
Contributor Author

The problem is that the same frame can return several different protocols but with the same ID, the frames being published with the corresponding ID in the topic, all the protocols are not visible.

Do you mean that they are not published but overwritten by the last one?

Frame is published but overwritten by the last one.

@hugokernel
Copy link
Contributor Author

I saw you have a RFBridge hacked with Pilight on it, if you want to try:

diff --git a/main/main.ino b/main/main.ino
index 3c222e7..1cf9403 100644
--- a/main/main.ino
+++ b/main/main.ino
@@ -245,8 +245,9 @@ void pub(char* topicori, JsonObject& data) {
 #ifdef valueAsASubject
 #  ifdef ZgatewayPilight
     String value = data["value"];
+    String protocol = data["protocol"];
     if (value != 0) {
-      topic = topic + "/" + value;
+      topic = topic + "/" + protocol + "/" + value;
     }
 #  else
     SIGNAL_SIZE_UL_ULL value = data["value"];

The patch is only applied when Pilight is enabled but I think it could be interesting to have this option which can be useful especially to avoid collisions of devices with the same ID but different protocols or simply to classify things more finely.

If you think it will be interesting, I can do a pull request about that.

@1technophile
Copy link
Owner

If you think it will be interesting, I can do a pull request about that.

I agree, it can be interesting and enables us to have a more detailed view of the signal received. Nevertheless, I'm not sure about the best way to do it more globally. I have also some thinking around 433mhz that I would like to mature before making you work on this.

Thanks for the proposal and the PR :-)

@1technophile 1technophile force-pushed the fix-pilight-value-as-subject branch from 2d6a043 to 1ad5a59 Compare September 2, 2020 20:44
@1technophile 1technophile merged commit 347783a into 1technophile:development Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lack of valueAsASubject in ZgatewayPilight messages
2 participants