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

Add option to disable relay reporting to MQTT #1645

Merged
merged 3 commits into from
Mar 25, 2019

Conversation

Niek
Copy link
Contributor

@Niek Niek commented Mar 21, 2019

This feature is especially useful when using custom MQTT groups for relays. This adds the option to disable the reporting of relay statuses to MQTT, and report only to the custom MQTT groups (if defined).

@Niek
Copy link
Contributor Author

Niek commented Mar 22, 2019

It might make sense to change all mqttForward() calls in the code as well (which is determined by a check if MQTT_GETTER != MQTT_SETTER - I don't really understand the logic there).

@mcspr
Copy link
Collaborator

mcspr commented Mar 23, 2019

which is determined by a check if MQTT_GETTER != MQTT_SETTER - I don't really understand the logic there

For example, if both are empty (and therefore equal), we are subscribed to the <root>/relay/0 and will also use it to send our state.

@Niek
Copy link
Contributor Author

Niek commented Mar 25, 2019

which is determined by a check if MQTT_GETTER != MQTT_SETTER - I don't really understand the logic there

For example, if both are empty (and therefore equal), we are subscribed to the <root>/relay/0 and will also use it to send our state.

OK that makes sense - I changed the code to use mqttForward() instead.

@xoseperez xoseperez merged commit fe67fb6 into xoseperez:dev Mar 25, 2019
@xoseperez xoseperez added this to the 1.13.6 milestone Mar 25, 2019
@mcspr
Copy link
Collaborator

mcspr commented Mar 27, 2019

@Niek mqttForward() is not always available. 300KiB builds break because of that:
https://travis-ci.org/mcspr/espurna-nightly-builder/jobs/512070680#L984-L990

@Niek
Copy link
Contributor Author

Niek commented Mar 27, 2019

Ah I didn't think of that, what do you think would be the cleaned approach? Make a dummy mqttForward() function in relay.ino in case MQTT_SUPPORT is false? Or duplicate those calls with if #MQTT_SUPPORT blocks around it?

@Niek
Copy link
Contributor Author

Niek commented Mar 27, 2019

I submitted a fix in PR #1662

@mcspr
Copy link
Collaborator

mcspr commented Mar 27, 2019

IDK though why it must depend on it. Forwarding setting is only ever checked when relay status (or light, or domoticz) function is called from within MQTT callback, so that we do not report back to the same topic we just received data from. Now, it is always called.
Heartbeat mechanism also can send all relays status, which forwarding setting && new define does not stop, but it can be disabled at runtime or via define flag default (see HEARTBEAT_REPORT_RELAY in utils)
So maybe it should do something similar and just check in relayMqtt(id) new optional setting / define and do nothing (report=false and no send)? Or there can be a more elaborate reporting mechanism, following the idea of broker module.

edit: words

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.

3 participants