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_MQTT target stops broadcasting after a few hours #44

Open
Watchfox opened this issue Apr 7, 2021 · 1 comment
Open

HA_MQTT target stops broadcasting after a few hours #44

Watchfox opened this issue Apr 7, 2021 · 1 comment

Comments

@Watchfox
Copy link

Watchfox commented Apr 7, 2021

I have setup a Pi Zero W to act as a gateway to feed my regular server which runs HA.
It works neatly, good job really, nodejs is not officially supported anymore but that's fine. I installed v15.13.0. It's the only thing the Pi does.

I have setup 4 Ruuvitags with a Home Assistant (MQTT) target.
The problem is that after a couple of hours (I have seen anywhere between 2 and 30 hours) all MQTT broadcasts will stop except for one tag.

  • The logs confirm that (only that one tag is logged being broadcast), as well as my MQTT server.
  • According to the web interface (and logs), all tags are still being read correctly (BT -> Gateway is good), only the broadcast (publishing) to MQTT fails

Some interesting bits:

  • Turning off and on the target is enough to put things back in order
  • Same behavior if I make one target per tag (instead of one for the four), eventually only one tag will be sent to MQTT
  • The only tag which keeps broadcasting is the first one which was discovered

Extra info: I broadcast at a 60 seconds interval

I did another experiment where I have one Home Assistant (MQTT) target (first in the list) and a regular MQTT target. After a couple of hours all stopped broacasting except the first tag via the Home Assistant (MQTT) target. Turning off and on the regular MQTT target allowed it to work again (the Home Assistant (MQTT) target remain not working except for that one tag, until I also turn it off and on again).

Any idea on where in the code I could add a debug line which would show the tags being iterated for broacasting to MQTT and which would show they are skipped ?

@Watchfox
Copy link
Author

Watchfox commented Apr 8, 2021

More debugging:
It appears that the tags which stop broacasting are entering the branch:
if (1 * target.interval > 0 && Date.now() - tagField.ts > 1000 * target.interval) in index.js

[2021-04-09T07:28:06.301Z] [ERROR] Data older than interval : 1617953286300 / 1617953226289 / 60
[2021-04-09T07:28:06.302Z] [ERROR] Data older than interval : 1617953286302 / 1617953226289 / 60
[2021-04-09T07:28:06.303Z] [ERROR] Data older than interval : 1617953286303 / 1617953226289 / 60
[2021-04-09T07:29:06.337Z] [ERROR] Data older than interval : 1617953346337 / 1617953286322 / 60
[2021-04-09T07:29:06.339Z] [ERROR] Data older than interval : 1617953346339 / 1617953286322 / 60
[2021-04-09T07:29:06.340Z] [ERROR] Data older than interval : 1617953346340 / 1617953286322 / 60

That's ${Date.now()} / ${tagField.ts} / ${target.interval}
Somehow tagField.ts value becomes identical for all the tags (minus the first detected one). It keeps being updated (to what value?), but lags just above my 60s interval, which results in those tags being dropped.

My sampling interval is set to 60000ms.

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

No branches or pull requests

1 participant