skrollme / homebridge-eveatmo

Homebridge plugin which adds a Netatmo weatherstation as HomeKit device and tries to act like Elgato Eve Room/Weather
Apache License 2.0
69 stars 7 forks source link

homebridge error if device not reachable #39

Closed MexxReal closed 4 years ago

MexxReal commented 4 years ago

If the Netatmo station isn't available, no errors in log or in homebridge are shown.

A few days ago, the cable for the Netatmo station has been loosened. Because of that, all devices in homebridge haven't been accessible anymore. After hours of troubleshooting, I discovered the problem; the cable of the station.

Therefor it would be nice, to become informed in log about an error like that.

RPJacobs commented 4 years ago

My outdoor battery died, same result. Homebridgehad no error but all accessories where no longer available in homekit.

skrollme commented 4 years ago

Thank you for your reports. Because I have not much spare time for this hobby-project at the moment It could take a while for me to investigate this.

Feel free to take a look at the code, giving hints or doing PRs.

nicoduj commented 4 years ago

Hi, just a "guess", but I think it is because for all getCharacteristic, you are doing the callback only after data refresh.

            this.accessory.refreshData(function(err,data) {
                callback(err, this.transformCO2ToCarbonDioxideDetected());
            }.bind(this));

So, if the netatmo is not responding, it will take time to have a timeout I think, and block all following refresh I think, making device non responsive in homekit. I found that for getCharacteristic (not set generally if we want to ensure the command is good), it seems better to callback immediately with last know value, launch an update / refresh( if possible handling multiple calls that will arrive since multiple characterisitc are refreshed at the same time), and use an event when refreshed data is there to update all the characteristics .

It is off course open to discussion :)

skrollme commented 4 years ago

After some tinkering I got my local homebridge development setup back working and tested with some mockup data.

@RPJacobs If I lower the battery-percent value below 20%, I get a battery warning indicator in the eve.app, but no push/warning in the default home.app. Does the home.app do this normally (battery warnings/push) on battery accessories? I do not own any other battery-powered accessories.

Next test was, removing a whole device from the mockup-data, but that did not caused any problem either. In the last years when I used the plugin by myself some devices also died the battery-death (without push/notification) but when I (or my wife) saw the battery-warning in the original netatmo.app we replaced the battery and every was fine. No homebridge/homekit problems in this battery-died-periods.

And concerning the unplugged base-station, @MexxReal . The plugin does not query the base-station, it does request all data from the netatmo-servers. If they fail to respond, the plugin struggles, but a missing base-station should not cause a total failture. But I will test it soon, by unplugging my netatmo station and check what the netamo-API and the plugin do.

RPJacobs commented 4 years ago

@skrollme correct I ignored the warning. The battery died, and HomeKit froze.

RPJacobs commented 4 years ago

@skrollme i removed all plugins from home bridge one by one until HomeKit worked again. That’s how I found out that netatmo was the problem. So I logged into there website to verify my api key. That’s when I saw that one device was grey (lost). My outdoor module. So after some investigation I replaced te battery and al problems disappeared.

skrollme commented 4 years ago

Thanks for the hints. As mentioned before I will test unplugging my base-station or removing the batteries of a module and check what is happening.

skrollme commented 4 years ago

An hour ago I removed the batteries from one indoor-module. So far no problems. All other Netatmo-modules (basestation and other battery-powered modules) are still working and reporting.

The module which is dead was still reporting it's last value in homebridge. After I restarted homebridge it is not reporting anything at all - only it's default-values (11,1° Temp), but it is not crashing or blocking homebridge.

Other Homebridge-plugins (TV, AV-Receiver, People/Presence) are still working before and after restart. So do real HomeKit-Devices like Hue, Aurora or Eve-Outlets. Home.app and Eve.app are still working.

I will keep the module dead until tomorrow and see how my whole setup behaves. But at the moment I have no idea how to reproduce this

Question to @MexxReal & @RPJacobs : Are you on the latest version of this plugin? homebridge-eveatmo@0.5.0 ?

MexxReal commented 4 years ago

Thanks for responding! I'm using the actual version 0.5.0, but under Hoobs. Idk if this may cause those errors. In my case, the basestation has been without energy. I didn't took a look on netatmo-website or the app.

In Hoobs, all devices were shown, but in HomeKit-App on iOS devices none of my devices responded.

skrollme commented 4 years ago

Thanks for your response @MexxReal . I will test unplugging the base-station and report

sedony23 commented 4 years ago

I also had similar problems without any low battery of the stations or an unplugged base station. All of a sudden all devices in HomeKit were not responding any more. I went through uninstalling all plugins and resetting homebridge until I figured out that this plugin caused it. No errors in the homebridge logs. This happened a couple of times already. I in the end uninstalled this plugin completely and I am using a different one now... Hope you can find the issue that is causing it!

skrollme commented 4 years ago

Can you say if the Netatmo-Servers were down while the problems occurred, @sedony23 ? Netatmo-API outages were the only events when my homebridge-setup (native RaspberryPi then, docker on RaspberryPi now) got stuck. But after the Netatmo-Servers recover, a simple homebridge-restart did the job to get everything back working.

MexxReal commented 4 years ago

Right now I got an error in Log:

12.5.2020, 22:45:59 [eveatmo platform] WARN - Netatmo: Error: getStationsDataError error: Internal Server Error

Via https://my.netatmo.com/app/station I can see my station and the ext. modul. Also in netatmo app, no errors are shown and correct data of base-station and ext. modul are shown.

I checked, if my devices in Homebridge are useable; they are not. In hoobs all devices are responding. After restarting the hoods-service, everything works again now.

If you need some logs, please let me know.

skrollme commented 4 years ago

12.5.2020, 22:45:59 [eveatmo platform] WARN - Netatmo: Error: getStationsDataError error: Internal Server Error .. says, that there are problems on netatmo's API Servers or at least the server-response was not what the plugin expected (could be a timeout, too). Their normal webpage (my.netatmo.com) may work in the meantime, but that's unrelated.

But similar messages/errors from the API can also occur, if the API is called too often. Then you run into a request-rate limit on the server which blocks further calls for some time. Because the basestation does not report more frequently, I set the polling-rate of the homebridge-eveatmo plugin to 540s (once per 9min) and I did not ran into some issues in recent times.

MexxReal commented 4 years ago

My TTL is set to 900 the whole time. For my use case it's not necessary that the data is requested more often.

How can I check the response of the API?

skrollme commented 4 years ago

900s should definitely be high enough to not get soft-banned. I used a small test script (see below, netatmo npm package has to be installed for this) to test the API when needed:

var netatmo = require('netatmo');

// FILL THIS OUT
var auth = {
    "client_id": "###",
        "client_secret": "###",
        "username": "###",
        "password": "###"
};

var api = new netatmo(auth);

api.on("error", function(error) {
    console.error('Netatmo threw an error: ' + error);
});

api.on("warning", function(error) {
    console.log('Netatmo threw a warning: ' + error);
});

api.getStationsData(function(err, devices) {
  console.log(devices);
});
sedony23 commented 4 years ago

OK, so I checked again and it might actually also have been a problem with the battery of my outdoor sensor as I had to replace the battery now... But still this shouldn't lead to a situation where all homebridge devices appear with no response in HomeKit...

skrollme commented 4 years ago

Interesting. As I mentioned before, I removed the batteries from one module for about 24h and everything kept working without problems. So I did not have the "no response" situation. Is this behavior reproducible when you remove the batteries from this module again?

sedony23 commented 4 years ago

Interesting. As I mentioned before, I removed the batteries from one module for about 24h and everything kept working without problems. So I did not have the "no response" situation. Is this behavior reproducible when you remove the batteries from this module again?

Sorry, but I won’t try it again. It messed up the whole setup. I actually had to reset the whole homebridge setup... switched to a different plugin, which doesn’t have the eve history but well...

RPJacobs commented 4 years ago

I also got the error:

[5/25/2020, 11:55:20 AM] [netatmo platform] WARN - Netatmo: Error: getStationsDataError error: Internal Server Error

Unable to start homebridge

On https://my.netatmo.com/app/station:

[A screenshot of a cell phone Description automatically generated]

[A screenshot of a cell phone Description automatically generated]

My main module was disconnected from the power, after reconnecting and restarting home bridge everything is back alive!

Ralph

From: MexxReal notifications@github.com Reply to: skrollme/homebridge-eveatmo reply@reply.github.com Date: Tuesday, 12 May 2020 at 22:56 To: skrollme/homebridge-eveatmo homebridge-eveatmo@noreply.github.com Cc: Syca - Ralph Jacobs r.p.jacobs@syca.nl, Mention mention@noreply.github.com Subject: Re: [skrollme/homebridge-eveatmo] homebridge error if device not reachable (#39)

Right now I got an error in Log:

12.5.2020, 22:45:59 [eveatmo platform] WARN - Netatmo: Error: getStationsDataError error: Internal Server Error

Via https://my.netatmo.com/app/station I can see my station and the ext. modul. Also in netatmo app, no errors are shown and correct data of base-station and ext. modul are shown.

I checked, if my devices in Homebridge are useable; they are not. In hoobs all devices are responding. After restarting the hoods-service, everything works again now.

If you need some logs, please let me know.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/skrollme/homebridge-eveatmo/issues/39#issuecomment-627589060, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADNGFUNRR6YPT4QM325ZUQDRRGZXRANCNFSM4MNVM3QQ.

skrollme commented 4 years ago

@RPJacobs these "Mailresponse to GitHub Issue comment" is terribly to read. And I don't know if you wanted to attach screenshots, they are not here.

As mentioned multiple-times before everytime I disconnect the base-station or a module reaches low- or zero-battery the plugin does not stop working. It just keeps the last values.

If you restart the Homebridge and you get errors, this should be a sign to look at your weather-station setup.

The plugin's base code (where I forked this from) is built upon the fact, that Netamo's API is reachable on homebridge-startup. I do not plan to change this, especially because recently I rarely use the plugin by myself at all.