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 implementation details and other things #200

Merged
merged 10 commits into from
May 6, 2020
Merged

Add implementation details and other things #200

merged 10 commits into from
May 6, 2020

Conversation

piegamesde
Copy link
Contributor

I spent two hours reading issues and discussions so I thought I may as well put another two hours into writing down their conclusions (or at least what I think).

Any of the commits may be discussed separately and I'm open to create a distinct pull request for each if there's need for it.

This addresses topics from #150, #51, #148 and probably a few others.

piegamesde and others added 6 commits April 25, 2020 18:23
I stumbled over this in a comment in one of the discussions. The specification is pretty vague about this at the moment. So I added a sentence that makes this requirement more explicit and less hard to miss.
This gives controllers the guarantee that as long as a device is in any of the "operational" states, they can assume that the MQTT structure of that device won't change.
This also implies that each time a device goes back online, all nodes and properties must be re-checked for any changes.
In future, when referring to QoS levels, use:

- "At most once (0)"
- "At least once (1)"
- "Exactly once (2)"

Closes #196
spelling fix
Copy link
Contributor

@mjcumming mjcumming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For device reconfiguration, I am not sure there is a requirement for the device to go offline or to change its state to init? @Thalhammer ?

@piegamesde
Copy link
Contributor Author

Thanks for correcting the typo. Currently, the convention doesn't say anything about any changes or reconfiguration. I just thought it would make writing Homie-Controllers easier if they didn't have to be aware of any device changes all of the time (It may also make writing libraries easier). I remember some discussion about adding an explicit reconfiguring state, but I think a simple reconnection or using the init state should be enough.

@mjcumming
Copy link
Contributor

I think that makes sense. I'll let @Thalhammer weigh in on the proposal before approving.

convention.md Outdated Show resolved Hide resolved
convention.md Outdated
* A device may try to restore its state using MQTT. This can be done by subcribing to the respective channels.
An alternative way is to recover the state from other MQTT channels that are external to the Homie specification.
This is not a recommended approach though, because retained messages are only sent by the broker in response to a new subscription.
So if a device doesn't reconnect with a clean session, then the retained messages won't be resent.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a device connects with a non clean session it is assumed to "know" what happend in the last connection (mqtt kind of defines this). This means it should still know the retained values sent. If there is no persistence it should really be connecting with clean session set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, but I don't understand. What exactly is a "clean session"? What exactly is wrong about the paragraph and what should a more correct version?

My motivation behind this was to say that this approach at restoring state is a bad idea, and to explain why.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MQTT supports keeping sessions while the device is offline.
If you connect and request a clean session you will get one that looks as if you never connected before.
However if you dont request a clean session the broker will restore all subscriptions you had the last you where connected. It will also deliver all messages sent to a subscription with qos 1 or higher while the device was offline.

You would normally connect with a clean session if your device state is lost (like after a reboot without persistent storage, or after a reset) and connect to an existing session otherwise if you're device still knows what state its world is in (like a connection drop/reconnect).

The only difference is that with an existing session you dont get retained topics unless you unsubscribe and resubscribe them again or they changed while the device was offline. Also there is no need to subscribe if you have an existing session as the broker keeps subscriptions alive.

Copy link
Contributor

@mjcumming mjcumming Apr 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@homieiot/involved in my implementations, the Homie devices know their state ie on/off, dimmer percentage, temperature etc. Is there a situation where a device would not know it's own state and need to restore a value?

As part of other discussion regarding QoS, the Homie spec probably needs to address controller set messages that are not delivered in a timely fashion. Part of our discussion in #150

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjcumming The section I wrote about this is limited to settable properties that can't easily be recovered. Think of music players for example. Or in my case, a light effects controller.

Copy link
Contributor

@mjcumming mjcumming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this verbiage is clarifies the ready state.

@mjcumming mjcumming merged commit 6d852df into homieiot:develop May 6, 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.

4 participants