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

HA: RF, RF2, Pilight modules as sensors. Subscribe topic, according valueAsATopic. #2134

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

peshovec
Copy link
Contributor

@peshovec peshovec commented Dec 17, 2024

Description:

The RF sensors discovery are created with topics like "/433toMQTT"
If valueAsATopic is defined, then published messages are not in the main topic, but in subtree.
Change the topic to be like "/433toMQTT/#" , when valueAsATopic is defined.

Checklist:

  • The pull request is done against the latest development branch
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • I accept the DCO.

…e.g if vaule as topic, then subscribe ... to /#. So in the HA the received message will be populated in the sensors too
@Odyno
Copy link
Contributor

Odyno commented Dec 17, 2024

Hi @peshovec
I’m sorry, but it’s not clear to me why we need to provide "/433toMQTT/#" instead of the actual value like "/433toMQTT/123123". I agree that the PR is an improvement, but why do you prefer to keep it generic?

P.S. One small note: it seems that you’ve updated RF, RF2, and Pilight, not just RF. It might be helpful to include all of them in the PR title to simplify future searches.

@peshovec
Copy link
Contributor Author

peshovec commented Dec 17, 2024

No worries:) title is edited now.

The HA uses this topics to subscribe to them and to collect "sensor" information. At least i understood it this way. I agree, this information is mainly for diagnostic purposes.

The point is that, when valueAsATopic is defined, then the OMG publish like this:

Add the received "value" at the end of the topic

For the gateways that publish a "value" parameter on the json (RF, IR...), it is possible to concatenate this parameter at the end of the topic.
So as to activate this function you need to set valueAsATopic to true in User_config.h

#ifndef valueAsATopic
#  define valueAsATopic false // define true to integrate msg value into the subject when receiving
#endif

Per default you see the following data:

home/OpenMQTTGateway/SRFBtoMQTT {"raw":"2B660186042E00E7E5","value":"59365","delay":"1111","val_Thigh":"390","val_Tlow":"1070"}

With the line uncommented you will see:

home/OpenMQTTGateway/SRFBtoMQTT/59365 {"raw":"2B660186042E00E7E5","value":"59365","delay":"1111","val_Thigh":"390","val_Tlow":"1070"}

As i understood - the value (in this example 59365) is not fixed, and changes for the various devices (transmitters)
Took the example from the docs, as i am not able now to get ones from my setup. If i recall correctly, in my setup i even observed subtopics, two leve deep than .../MQTT. Hence i decide to "instruct" HomeAssistant to subscribe to the whole subtree (#, instead of +, +/+)

@Odyno
Copy link
Contributor

Odyno commented Dec 17, 2024

Ok, all of this was clear to me, but I finally understood where things don't add up for me. In short, I'm not sure about rf2 or Pilight, but for RF this PR is only useful if two discovery messages continue to be sent for the same RF signal.
I believe there is a hypothetical issue with the RF module (RCSwitch), tracked under #2139

@peshovec peshovec changed the title HA: RF modules as sensors. Subscribe topic, according valueAsATopic. HA: RF, RF2, Pilight modules as sensors. Subscribe topic, according valueAsATopic. Dec 18, 2024
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.

2 participants