-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Does not re-connect when MQTT broker restarts #30
Comments
I suspect a lua script might act as a watchdog for this service. class Client(plugin has methods that seem like they should be exposed to lua. There is no mechanism I can find in client.py that watches over the connection state. I would make adjustments to the plugin myself but I have had no success building a good build environment for these plugins. |
Uhm lua ? |
Yes. Run a small lua script on a timer to check for connection and restart if required. This lua script interacts with your plugin to send the mqtt debug message. The only flaw in this plan is that Client does not have the correct methods. -- hass mqtt plugin has to be installed function onInit() function onDeviceStateChanged(device, state, stateValue) |
but fixing the behavior in paho would be better |
A lua script fix while paho is broken.
|
Looks interesting. Could you share also the HA automation part? |
I´m experiencing the same issue. In my case we have a lot of power outages at the winter and when my znet starts up before my HA instance the MQTT connection fails and won´t reconnect until i powercykle my znet. |
I have modified the lua a bit since I last posted. It also relies on a
"ClockTick" device set once a minute. We can probably find a better
solution to that.
The HA script is simple. It just sets a switch every 1/10 second.
You need to create this "virtual" watchdog switch for Tellstick by creating
a Nexa switch and then not assigning to a real switch.
*alias: TellstickPingRepeatdescription: ''trigger: - platform:
time_pattern seconds: /10condition: []action: - type: turn_on
device_id: 702668760f977dea1be89b83a55adfb0 entity_id:
switch.hasstellsickmqttwatchdog domain: switchmode: single*
…On Mon, 17 Jan 2022 at 13:11, pierrebengtsson ***@***.***> wrote:
I´m experiencing the same issue. In my case we have a lot of power outages
at the winter and when my znet starts up before my HA instance the MQTT
connection fails and won´t reconnect until i powercykle my znet.
@crashmatt <https://github.com/crashmatt> could you share youre
HA-automation? If i create an automation that sets the fictional device to
"on" every 10 second the only message I get from the LUA-script is
"HassTellstickMQTTWatchdog timeout"
—
Reply to this email directly, view it on GitHub
<#30 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVYHIW4V2C35JWIL6XNGTUWQBPZANCNFSM5JL2UGIQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Important update.
The watchdog from hass is sent to the tellstick. What I didn't know before
is that the tellstick transmitts the virtual switch code.
I am using a nexa switch as a virtual device. Since the watchdog transmits
every 10seconds, when you retrain a physical Nexa switch it is likely to
capture the watchdog also.
This has been driving me crazy for a few months of light switches always
switching themselves back on.
Solution is to always have the watchdog send an off state. That way a
switch that is training always unlearn the watchdog.
Another solution might be to pick a device on a different protocol. HAve
not tested this yet.
More and patchwork required...
On Mon, 17 Jan 2022 at 17:35, matthew coleman ***@***.***>
wrote:
… I have modified the lua a bit since I last posted. It also relies on a
"ClockTick" device set once a minute. We can probably find a better
solution to that.
The HA script is simple. It just sets a switch every 1/10 second.
You need to create this "virtual" watchdog switch for Tellstick by
creating a Nexa switch and then not assigning to a real switch.
*alias: TellstickPingRepeatdescription: ''trigger: - platform:
time_pattern seconds: /10condition: []action: - type: turn_on
device_id: 702668760f977dea1be89b83a55adfb0 entity_id:
switch.hasstellsickmqttwatchdog domain: switchmode: single*
On Mon, 17 Jan 2022 at 13:11, pierrebengtsson ***@***.***>
wrote:
> I´m experiencing the same issue. In my case we have a lot of power
> outages at the winter and when my znet starts up before my HA instance the
> MQTT connection fails and won´t reconnect until i powercykle my znet.
> @crashmatt <https://github.com/crashmatt> could you share youre
> HA-automation? If i create an automation that sets the fictional device to
> "on" every 10 second the only message I get from the LUA-script is
> "HassTellstickMQTTWatchdog timeout"
>
> —
> Reply to this email directly, view it on GitHub
> <#30 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACVYHIW4V2C35JWIL6XNGTUWQBPZANCNFSM5JL2UGIQ>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
I've had this issue for quite some time, don't know a good solution though. It would be great if @crashmatt could share the lua and ha config (with formatting) for a watchdog. |
Fredrik,
There are a few different parts to this.
1. A virtual switch item on tellstick to receive the heartbeats
2. A heartbeat automation from hass to tellstick so the tellstick knows
it is healthy
3. A watchdog monitor on tellstick to reboot if the heartbeat is not ok
Do this in order.
Check the heartbeats are being received at the tellstickbefore adding the
watchdog monitor. Otherwise your tellstick will be continuously rebooting
and you are in for a frustrating day.
Step 1
[image: image.png]
Let me know if you need more guidance and I will attempt to document it
better
…On Sun, 16 Apr 2023 at 22:29, Fredrik Erlandsson ***@***.***> wrote:
I've had this issue for quite some time, don't know a good solution though.
#9 <#9>
It would be great if @crashmatt <https://github.com/crashmatt> could
share the lua and ha config (with formatting) for a watchdog.
—
Reply to this email directly, view it on GitHub
<#30 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVYHNW6G23NAZ3HXISLI3XBRJDXANCNFSM5JL2UGIQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Might have a look at my comments on the mentioned ticket. Maybe that's a thing? |
Here are my current configurations.
I've not had any issues with MQTT since I started running this, but I can't say that it is just because of this script (I might be lucky too). |
This is the error which paho throws, if the mqtt server is restarted or shut down same problem here: |
It will be interesting to see how stable your system is. I don't know how
finely this setup is.
A bad MQTT connection can be faked by stopping the watchdog transmit. I
did this a few times and checked the system came back together. Sometimes
takes a while to heal and become stable again.
/Matt
…On Mon, 24 Apr 2023 at 21:55, Fredrik Erlandsson ***@***.***> wrote:
Here are my current configurations.
1. Created a switch in Telldus Live (called MQTT-watchdog)
2. Changed id for the new switch to switch.tellstick_mqtt_watchdog in
HA
3. Built the following automation in HA:
alias: HassTellstickMQTTWatchdogdescription: ""trigger:
- platform: time_pattern
seconds: /10condition: []action:
- service: switch.turn_on
data: {}
target:
entity_id: switch.tellstick_mqtt_watchdogmode: single
4. Built the following Lua script on my Telldus TellStick (accessed
trough the local IP):
-- hass mqtt plugin has to be installedlocal mqtt = require 'HASSMQTT.Client'local deviceManager = require "telldus.DeviceManager"local running_timer = falselocal watchdog_count = 0local watchdog_timeout_seconds = 30 -- Delay in seconds
function init()
if mqtt == nil then
print "No mqtt client"
else
print "mqtt client ok"
endend
function onInit()
init()end
function onDeviceStateChanged(device, state, stateValue)
if mqtt == nil then
return
end
dev_name = device:name()
if dev_name == "HassTellsickMQTTWatchdog" then
if device:state() == 1 then
watchdog_count = watchdog_count + 1
print "HassTellstickMQTTWatchdog signal received"
end
end
if not running_timer then
running_timer = true
watchdog_count = 0
sleep(watchdog_timeout_seconds*1000)
if watchdog_count == 0 then
print("HassTellstickMQTTWatchdog timeout")
mqtt:connect()
else
print("HassTellstickMQTTWatchdog count %u", watchdog_count)
end
running_timer = false
endend
I've not had any issues with MQTT since I started running this, but I
can't say that it is just because of this script (I might be lucky too).
—
Reply to this email directly, view it on GitHub
<#30 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVYHJ3DQ62FOF5LFMYCFDXC3LCJANCNFSM5JL2UGIQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
MQTT_Homeassistant-0.90.4_paho-1.5.1.zip p.s. the files are signed and unmodified from this repo, otherwise it would not be possible to load them in telldus. So you might trust the content of the ZIP 😉 |
I have no idea how to use those files. I presume they modify the
tellstick plugin?
…On Tue, 25 Apr 2023 at 23:57, tiehfood ***@***.***> wrote:
MQTT_Homeassistant-0.90.4_paho-1.5.1.zip
<https://github.com/quazzie/tellstick-plugin-mqtt-hass/files/11327122/MQTT_Homeassistant-0.90.4_paho-1.5.1.zip>
@crashmatt <https://github.com/crashmatt> , @fredrike
<https://github.com/fredrike> you may want to try this version. It seems
that the reconnect is working better with paho <1.6.0. So this is just the
current version 0.90.4 repacked with the paho 1.5.1 from version 0.90.0.
For me this is far more stable on reconnects and no exception is thrown so
far.
—
Reply to this email directly, view it on GitHub
<#30 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVYHLJWRHVW6EKXPJU2KLXDBCFFANCNFSM5JL2UGIQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Just install the zip file as a plug-in (don't extract). As you do it with the official plugin from the releases page. And yes, it just replaces the paho version (from 1.6.1 down to 1.5.1) |
This seems to be working well. I installed this and tried a couple of times restarting my mqtt server and power cycling my network switch and the mqtt connection was restored correctly. |
I forgot to check what version I had first, but tried the zip-file, my problem still persists. Lately the addon have disconnected just seconds after connecting, making the znet dumb as f**k Going to try the lua script now, fingers crossed X |
Looks like the client disconnects just seconds after connecting either way. Made myself a virtual switch that a lua listens to and connects the MQTT, making it easier to investigate. Earlier I had to login and bump the addon by removing and adding a number in the config in the addon I have several other clients that connects to the broker without issues. Tried increasing and decreasing the keepalive ping on the broker, but no luck. Is there any way to enable logging on the znet? To see whats going on there |
My problems with disconnects only happens after a while. After years with issues where I have had to restart the znet manually from time to time, I’ve now connected it to a power switch that I automatically power cycle every night. |
Broker connection is broken after a restart.
Tested reconnect by entering configuration, touching a field and then saving status.
Touch may not be required. This is not tested.
Reboot may make a reconnect. This is not tested.
The text was updated successfully, but these errors were encountered: