Energy Meter - periodic update via Modbus

Hi everyone,

I’m working on an app that retrieves data from an energy meter via Modbus. To do this, I set a timer that checks the energy data via Modbus every 30 seconds and updates Homey if there are any changes. After a few hours, however, the app stops working (I don’t get any errors, but the energy consumption data simply isn’t updated anymore). I’ve checked the code several times and there shouldn’t be any memory leaks, but I wanted to see if there was a way (for example, using Homey’s development tools) to determine if the lack of updates is due to Homey forcing the app to stop.

I’d also like to know if you have any other ideas for managing the periodic retrieval of data via Modbus without using homey.setTimeout.

Thank you.

Simone

Did you use homey app run -r
This will show the debug log.

Hi Peter, the problem is that updates arrive promptly for several hours/days before stopping, as if Homey stopped the timer at a certain point. So I was thinking of Homey Developers Tool rather than homey app run --r, but at first glance I couldn’t find any alerts.

Hi Simone,
With using homey app run -r, I was thinking like: when the updates stop after x days, you’d see error messages popping up in the console. If not…, and if the issue is not on the Energy device, or MQTT, the only cause I can think of atm is Homey CPU or Memory management shutting down the app, due to exceeding CPU use or memory use.

You can use Dev Tools as well at the same time.

Thanks Peter, I’m starting to think I’ve been using ‘homey app run --r’ incorrectly all along. I was convinced that once I closed VSCode, the app would stop working and that only ‘homey app install’ was persistent…
Anyway, I’ve now run ‘homey app run --r’. How can I see the logs in a few days without keeping my PC on all the time? I tried reopening VSCode, but there’s no log in the terminal.

YW.
AFAIK you’ll need to keep the console open.

Then I think I’ll try saving the logs inside /userdata folder. Thanks for now!

1 Like