hamkichi / homebridge-echonet-lite-eolia

Apache License 2.0
8 stars 5 forks source link

Making unnecessary requests slowing down Homebridge? #6

Open TommyGKiwi opened 1 year ago

TommyGKiwi commented 1 year ago

Everytime I go into home app the aircon takes a little bit of time to respond, I noticed the log says some calls are taking some time to reply. I noticed some of the requests are for threshold values like heating when the aircon is off (and when turned on would be for cooling), so I assume many requests are made, which maybe are not needed

To Reproduce: Normal running often when open the home app the log shows slow response

Expected behavior: No delay in information in home app on the aircon

Logs:

{7/16/2023, 2:18:42 PM] (homebridge-echonet-lite-eolia] This plugin slows down Homebrid ge. The read handler for the characteristic 'Heating Threshold Temperature' was slow to respond! See https: //homebridge.io/w/JtMGR for more info.


Show the Homebridge logs here, remove any sensitive information.

**Plugin Config:**
You have no real config to show apart from your initial settings

**Screenshots:**
<!-- If applicable, add screenshots to help explain your problem. -->

**Environment:**

* **Plugin Version**: 0.0.3
* **Homebridge Version**: 1.6.1
* **Node.js Version**:  18.16.1
* **NPM Version**: <!-- npm -v -->
* **Operating System**: <!-- Raspbian / Ubuntu / Debian / Windows / macOS / Docker / hb-service -->
TommyGKiwi commented 1 year ago

More info with log in debug mode This is the sequence of requests: [7/16/2023, 6:03:32 PM] [EoliaPlatform] Triggered GET Active [7/16/2023, 6:03:32 PM] [EoliaPlatform] Triggered GET CurrentHeaterCoolerState [7/16/2023, 6:03:32 PM] [EoliaPlatform] Triggered GET Active [7/16/2023, 6:03:32 PM] [EoliaPlatform] Triggered GET TargetHeaterCoolerState [7/16/2023, 6:03:32 PM] [EoliaPlatform] Triggered GET CurrentTemperature [7/16/2023, 6:03:32 PM] [EoliaPlatform] Triggered GET CoolingThresholdTemperature [7/16/2023, 6:03:32 PM] [EoliaPlatform] Triggered GET HeatingThresholdTemperature

hamkichi commented 9 months ago

In my home, I manage three air conditioners and have not encountered any delay issues. Additionally, with the latest Homebridge 1.7.0, there were no logs indicating any slowdowns.

I have released v0.3.1-beta-2 as a test fix. I've implemented a minor change in the handleCurrentHeaterCoolerStateGet method. Instead of calling handleActiveGet, the method now relies on a static variable this.isActive. https://github.com/hamkichi/homebridge-echonet-lite-eolia/commit/27ae9f4c27472fb427c82cb4212bdf12dbb09ade

The modification is currently in a trial phase. Assuming no issues arise, I plan to move forward with a general availability (GA) release in about one week.

TommyGKiwi commented 9 months ago

Installing it now.Hopefully it also fixes the issue where it becomes unresponsive in homekit and I need to restart home bridge, it happens several times a day or when I restart the router Sent from my iPhoneOn Nov 27, 2023, at 21:11, hamkichi @.***> wrote: In my home, I manage three air conditioners and have not encountered any delay issues. Additionally, with the latest Homebridge 1.7.0, there were no logs indicating any slowdowns. I have released v0.3.1-beta-2 as a test fix. I've implemented a minor change in the handleCurrentHeaterCoolerStateGet method. Instead of calling handleActiveGet, the method now relies on a static variable this.isActive. 27ae9f4 The modification is currently in a trial phase. Assuming no issues arise, I plan to move forward with a general availability (GA) release in about one week.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

TommyGKiwi commented 9 months ago

The logs look a lot cleaner and the only one that works However during the night I get the no response issue from homekit (as before). Strange thing the log shows that plugin is making the queries, but the answers maybe slow coming back? If I restart Homebridge homekit recovers the aircon.

side question does Echonet support 0.5 degreee steps?

Log: [11/28/2023, 7:40:10 AM] [EoliaPlatform] Triggered GET HeatingThresholdTemperature [11/28/2023, 7:40:10 AM] [EoliaPlatform] Triggered GET TargetHeaterCoolerState [11/28/2023, 7:40:10 AM] [EoliaPlatform] Triggered GET CurrentHeaterCoolerState [11/28/2023, 7:40:10 AM] [EoliaPlatform] Triggered GET CoolingThresholdTemperature [11/28/2023, 7:40:10 AM] [EoliaPlatform] Triggered GET Active [11/28/2023, 7:40:10 AM] [EoliaPlatform] Triggered GET CurrentTemperature [11/28/2023, 7:40:20 AM] [EoliaPlatform] Triggered GET Active [11/28/2023, 7:40:20 AM] [EoliaPlatform] Triggered GET CurrentHeaterCoolerState [11/28/2023, 7:40:20 AM] [EoliaPlatform] Triggered GET TargetHeaterCoolerState [11/28/2023, 7:40:20 AM] [EoliaPlatform] Triggered GET CurrentTemperature [11/28/2023, 7:40:20 AM] [EoliaPlatform] Triggered GET CoolingThresholdTemperature [11/28/2023, 7:40:20 AM] [EoliaPlatform] Triggered GET HeatingThresholdTemperature [11/28/2023, 7:40:23 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Active' was slow to respond! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:23 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Current Heater-Cooler State' was slow to respond! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:23 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Target Heater-Cooler State' was slow to respond! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:23 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Current Temperature' was slow to respond! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:23 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Cooling Threshold Temperature' was slow to respond! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:23 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Heating Threshold Temperature' was slow to respond! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:29 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Active' didn't respond at all!. Please check that you properly call the callback! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:29 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Current Heater-Cooler State' didn't respond at all!. Please check that you properly call the callback! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:29 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Target Heater-Cooler State' didn't respond at all!. Please check that you properly call the callback! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:29 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Current Temperature' didn't respond at all!. Please check that you properly call the callback! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:29 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Cooling Threshold Temperature' didn't respond at all!. Please check that you properly call the callback! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:29 AM] [homebridge-echonet-lite-eolia] This plugin slows down Homebridge. The read handler for the characteristic 'Heating Threshold Temperature' didn't respond at all!. Please check that you properly call the callback! See https://homebridge.io/w/JtMGR for more info. [11/28/2023, 7:40:29 AM] [EoliaPlatform] Triggered GET TargetHeaterCoolerState [11/28/2023, 7:40:29 AM] [EoliaPlatform] Triggered GET CurrentHeaterCoolerState [11/28/2023, 7:40:29 AM] [EoliaPlatform] Triggered GET HeatingThresholdTemperature [11/28/2023, 7:40:29 AM] [EoliaPlatform] Triggered GET CoolingThresholdTemperature [11/28/2023, 7:40:29 AM] [EoliaPlatform] Triggered GET Active [11/28/2023, 7:40:29 AM] [EoliaPlatform] Triggered GET CurrentTemperature [11/28/2023, 7:40:42 AM] [EoliaPlatform] Triggered GET CurrentTemperature [28/11/2023, 07:40:42] [SwitchbotBluetoothPlatform] Current power state of the switch is: OFF [28/11/2023, 07:40:42] [SwitchbotBluetoothPlatform] Getting Battery level for device (address f7:6e:6a:cc:c3:5b) [28/11/2023, 07:40:42] [SwitchbotBluetoothPlatform] Current battery level of switch is 91 [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET TargetHeaterCoolerState [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET Active [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET HeatingThresholdTemperature [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET CurrentTemperature [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET CurrentHeaterCoolerState [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET CoolingThresholdTemperature [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET Active [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET CurrentHeaterCoolerState [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET TargetHeaterCoolerState [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET CurrentTemperature [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET CoolingThresholdTemperature [11/28/2023, 7:40:51 AM] [EoliaPlatform] Triggered GET HeatingThresholdTemperature

TommyGKiwi commented 9 months ago

The log above info seems to only happen when the plugin is no longer working between it and the Echonet device. In homekit the aircon is in no response mode. Seems to be permenant until restart Homebridge. Cases where this seems to happen A) after a period of time, at least several hours after restating Homebridge B) after powering on and off the aircon C) rebooting the router

TommyGKiwi commented 8 months ago

My assumption is your fix works for the orginal problem. looks like for the above reasons the plugin disconnected from the aircon,

so I think if you modify the code to act on “no response” say five times, then attempt to reconnect.

TommyGKiwi commented 7 months ago

Traced the issue to a call to getPropertyValue in node-echonet-lite.js that seems to not callback. I put debug messages before and after. The after does not comeback after toggling wi-fi off and on.

TommyGKiwi commented 7 months ago

Hi I fixed the issue of gets not returning when the network(wi-fi) is temporary dropped. for the usual call to "GET CurrentTemperature", I added a token system. At the start of the routine I set the token and after the call I reset the token. So when it comes around again at a later time, and the token is still set. Then the previous call to echonet lite stack did not return from the call.

In the platformAccessory.js: Intial section: let armGetCall = 0; const { spawn } = require("child_process");

In handleCurrentTemperatureGet() was changed to add token process and restart (I assume you can internally restart the process, but I just sledge hammered it.) async handleCurrentTemperatureGet() { this.platform.log.debug('Triggered GET CurrentTemperature'); let currentValue = -127; if (armGetCall === 1) { this.platform.log.error('Token Not disarmed, Restarting child'); const pkill = spawn('pkill', ['-15','-f', 'homebridge: homebridge-echonet-lite-eolia']); pkill.stdout.on('data',(data) => { this.platform.log.error('Tom Output'); }); pkill.stderr.on('data',(data) => { this.platform.log.error('Tom ERROR'); }); } else { armGetCall = 1; } try { const res = await this.getPropertyValue(this.address, this.eoj, 0xBB); currentValue = res.message.data.temperature; if (currentValue === null) { currentValue = -127; } armGetCall = 0; } catch (err) { this.platform.log.error(err.message); currentValue = -127; } return currentValue;

TommyGKiwi commented 7 months ago

Sorry it closed it. I meant to say, I provided a way to fix it which you can improve upon.

TommyGKiwi commented 7 months ago

Small addition, changed the token, to restart on second pass token value 2. As I noticed, it has a rare false positive when homebridge restarts and makes it a little forgiving. Also I noticed your system can call twice, so it is more inline with your code.

TommyGKiwi commented 7 months ago

Finally settled on the following stable solution: Use one token (two created some issues with web interface etc, even though plugin functioned) Set initial setting to -1 ( to avoid rare initial triggers) Change armGetCall = 1; to armGetCall++;

TommyGKiwi commented 6 months ago

I think we should close this, as the original problem has been fixed (repeated requests). if you want I can reopen another one with the issue when the wifi is unstable. That way you can release this beta, as it is vastly better than the current release.