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

Chaning Topic using MQTT keeps device online in old topic #436

Closed
dravik1991 opened this issue May 10, 2017 · 10 comments
Closed

Chaning Topic using MQTT keeps device online in old topic #436

dravik1991 opened this issue May 10, 2017 · 10 comments
Labels
stale Action - Issue left behind - Used by the BOT to call for attention

Comments

@dravik1991
Copy link

Hi,

I am programming an control application in UWP for Windows 10 including voice commands support using Cortana. It is starting to get in shape but I am having one issue.

I am using MQTT (broker=cloudmqtt.com). When I restart a Sonoff it is immidiately shown as offline, but when I rename the topic using command: "cmnd/sonoff_standing/topic: sonoff_standing_aap" it starts listening to sonoff_standing_app but it never takes offline the old topic.

Any idea what I am doing wrong or is this a bug?

Kind regards,
Sander

@davidelang
Copy link
Collaborator

davidelang commented May 10, 2017 via email

@khcnz
Copy link

khcnz commented May 11, 2017

I think this relates to the retained flag on the online/offline messages. When you change the topic I don't think it sends an offline message on the old topic. I guess ideally it would send an offline message and tell the broker to stop retaining the message so it falls off the broker.

@mrmin24
Copy link

mrmin24 commented May 11, 2017

See ticket #417

@mrmin24
Copy link

mrmin24 commented May 11, 2017

Also it should not just send an empty message to broker in my opinion, because if the controller is not online at that stage for some reason, it will never get the offline message before the message is removed. Maybe the controller should clear the broker and Sonoff just send an offline as per ticket #417?

@arendst
Copy link
Owner

arendst commented May 11, 2017

Sending an empty message with previous topic will be implemented in next release (unless there is a majority voting for just sending an offline message...)

@dravik1991
Copy link
Author

In my opinion the device should be listed as offline, unsubscribed, or even removed if this is possible by MQTT standards? I am also not sure if it is a bug in the Sonoff firmware or a bug of the broker if the device does not respond for a long time and should list the device as offline after a timeout?

Maybe a solution would be changing the topic after restart so the device will unsubscribe first.

@mrmin24
Copy link

mrmin24 commented May 11, 2017

I believe the broker pings on client ID and not topic. The same client ID is still connected and that is why it is not taken offline.

This is also not a subscribe issue, it is a publish of LWT problem. If it is possible to select offline message at topic change as arendst suggests that should be ok and if broker restarts in non persistent mode it should remove the LWT

@dravik1991
Copy link
Author

dravik1991 commented May 11, 2017

I've contacted the broker to see if this is the problem and asked to propose a solution (for the client ID check). I think they should de-list a topic that does not send a message for a week.

arendst added a commit that referenced this issue May 11, 2017
5.0.7 20170511
* Fix possible exception 28 on empty command
* Add command SetOption0 as replacement for SaveState
* Add command SetOption1 as replacement for ButtonRestrict
* Add command SetOption2 as replacement for Units
* Add command SetOption4 as replacement for MqttResponse
* Add command SetOption8 as replacement for TempUnit
* Add command SetOption10 On|Off to select between Offline or Removing
previous retained topic (#417, #436)
@stale
Copy link

stale bot commented Apr 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Apr 24, 2018
@stale
Copy link

stale bot commented May 8, 2018

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem.

@stale stale bot closed this as completed May 8, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.0.7 20170511
* Fix possible exception 28 on empty command
* Add command SetOption0 as replacement for SaveState
* Add command SetOption1 as replacement for ButtonRestrict
* Add command SetOption2 as replacement for Units
* Add command SetOption4 as replacement for MqttResponse
* Add command SetOption8 as replacement for TempUnit
* Add command SetOption10 On|Off to select between Offline or Removing
previous retained topic (arendst#417, arendst#436)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Action - Issue left behind - Used by the BOT to call for attention
Projects
None yet
Development

No branches or pull requests

5 participants