oogje / homebridge-i6-bigAssFans

A Homebridge plugin which allows you to control a Big Ass Fan.
MIT License
20 stars 4 forks source link

Loop of Child bridge process ended #16

Closed thicla01 closed 1 year ago

thicla01 commented 1 year ago

Describe The Bug:

The plugin was working flawlessy for several month, but now the Child bridge process ends continually

To Reproduce:

I have remove the plugin, clean the cache, restart the server, reinstall the plugin, reconfigure my Haiku Fan. The process start normaly. when I restart Homebridge, the child bridge process ends again continually

Expected behavior:

The process stay up after a Homebridge restart

Logs:

[24/09/2022, 20:21:22] [BigAssFans-i6] Initializing BigAssFans-i6 platform...
[24/09/2022, 20:21:22] [BigAssFans-i6] Initializing child bridge 0E:7A:F6:A6:CA:CB
[24/09/2022, 20:21:24] [homebridge-i6-bigassfans] Launched child bridge with PID 4695
[24/09/2022, 20:21:24] Registering platform 'homebridge-i6-bigassfans.BigAssFans-i6'
[24/09/2022, 20:21:24] [homebridge-i6-bigassfans] Loaded homebridge-i6-bigassfans v0.5.1 child bridge successfully
[24/09/2022, 20:21:24] [homebridge-i6-bigassfans] Init - initializing devices
[24/09/2022, 20:21:24] [homebridge-i6-bigassfans] Adding new accessory: Haiku_Salon

This a part of the loop : 
[24/09/2022, 20:30:17] [homebridge-i6-bigassfans] Restarting Process...
[24/09/2022, 20:30:19] [homebridge-i6-bigassfans] Launched child bridge with PID 11307
[24/09/2022, 20:30:20] Registering platform 'homebridge-i6-bigassfans.BigAssFans-i6'
[24/09/2022, 20:30:20] [homebridge-i6-bigassfans] Loaded homebridge-i6-bigassfans v0.5.1 child bridge successfully
[24/09/2022, 20:30:20] Loaded 1 cached accessories from cachedAccessories.0E7AF6A6CACB.
[24/09/2022, 20:30:20] [homebridge-i6-bigassfans] Loading accessory from cache: Haiku_Salon
[24/09/2022, 20:30:20] [homebridge-i6-bigassfans] Init - initializing devices
[24/09/2022, 20:30:20] [homebridge-i6-bigassfans] Restoring existing accessory from cache: Haiku_Salon
Error: listen EADDRINUSE: address already in use :::45070
    at Server.setupListenHandle [as _listen2] (node:net:1372:16)
    at listenInCluster (node:net:1420:12)
    at Server.listen (node:net:1508:7)
    at EventedHTTPServer.listen (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/eventedhttp.ts:155:20)
    at HAPServer.listen (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/HAPServer.ts:332:21)
    at Bridge.<anonymous> (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1279:18)
    at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27)
    at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)
    at fulfilled (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:115:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[24/09/2022, 20:30:20] [homebridge-i6-bigassfans] Child bridge process ended
[24/09/2022, 20:30:20] [homebridge-i6-bigassfans] Process Ended. Code: 1, Signal: null

[24/09/2022, 20:30:27] [homebridge-i6-bigassfans] Restarting Process...
[24/09/2022, 20:30:30] [homebridge-i6-bigassfans] Launched child bridge with PID 11328
[24/09/2022, 20:30:30] Registering platform 'homebridge-i6-bigassfans.BigAssFans-i6'
[24/09/2022, 20:30:30] [homebridge-i6-bigassfans] Loaded homebridge-i6-bigassfans v0.5.1 child bridge successfully
[24/09/2022, 20:30:30] Loaded 1 cached accessories from cachedAccessories.0E7AF6A6CACB.
[24/09/2022, 20:30:30] [homebridge-i6-bigassfans] Loading accessory from cache: Haiku_Salon
[24/09/2022, 20:30:30] [homebridge-i6-bigassfans] Init - initializing devices
[24/09/2022, 20:30:30] [homebridge-i6-bigassfans] Restoring existing accessory from cache: Haiku_Salon
Error: listen EADDRINUSE: address already in use :::45070
    at Server.setupListenHandle [as _listen2] (node:net:1372:16)
    at listenInCluster (node:net:1420:12)
    at Server.listen (node:net:1508:7)
    at EventedHTTPServer.listen (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/eventedhttp.ts:155:20)
    at HAPServer.listen (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/HAPServer.ts:332:21)
    at Bridge.<anonymous> (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1279:18)
    at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:144:27)
    at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:125:57)
    at fulfilled (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:115:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
[24/09/2022, 20:30:31] [homebridge-i6-bigassfans] Child bridge process ended
[24/09/2022, 20:30:31] [homebridge-i6-bigassfans] Process Ended. Code: 1, Signal: null

Plugin Config:

Note : I have remove the "pin", "ip address" and "mac Address"
{
    "bridge": {
        "name": "Homebridge AADC",
        "username": "0E:95:9B:BC:AA:DC",
        "port": 51808,
        "pin": "",
        "advertiser": "avahi"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "auth": "form",
            "theme": "purple",
            "tempUnits": "c",
            "lang": "auto",
            "sessionTimeout": 57600,
            "platform": "config"
        },
{
            "fans": [
                {
                    "name": "Haiku_Salon",
                    "ip": "",
                    "mac": "",
                    "fanModel": "Haiku H/I Series",
                    "showWhooshSwitch": true,
                    "showFanAutoSwitch": false,
                    "showLightAutoSwitch": false,
                    "showDimToWarmSwitch": false,
                    "showEcoModeSwitch": true
                }
            ],
            "_bridge": {
                "username": "0E:7A:F6:A6:CA:CB",
                "port": 45070
            },
            "platform": "BigAssFans-i6"
        }
    ]
}

Screenshots:

Environment:: Homebridge run on a Raspberry Pi 4B, Raspbian GNU/Linux 11 (bullseye)

thicla01 commented 1 year ago

You should receive the second one soon.

oogje commented 1 year ago

Got it. Thanks.

oogje commented 1 year ago

I see in the logs for the fan in the bedroom during startup, [16/10/2022, 22:40:40] Restoring existing accessory from cache: Haiku Salon but I presume the bedroom fan is "Haiku Chambre".

Each homebridge accessory must be registered with unique identifier. My plugin used the MAC address you specify in the config file as that unique ID. The plugin should use the MAC address provided by the fan instead of relying on the user to provide it in the config file but that's more complicated for me to code so I rely on the config file.

In fact it doesn't matter what you enter in the config file for the MAC address if it's unique among the accessories, the plugin only uses that for the unique identifier and reports it as the "serial number" to HomeKit.

So, can you verify the MAC address in the config file for the two fans is different?

Next, I notice when you start the Haiku Salon the "persist" and "accessories" are removed. Can you do that also when you start the Haiku Chambre?

Going forward could you send the config file along with the logs in email with the MAC un-redacted?

The next question is how do you determine when a fan is working? Are you changing a setting in the Home app to see if it responds? Or are you making a change with the remote or BAF app to see if the Home app shows the change? Whatever the method, could you note what you did at the appropriate time in the log file?

Thanks!

thicla01 commented 1 year ago

Hello oogje,

Below the answers

Le 17 oct. 2022 à 13:31, oogje @.***> a écrit :

I see in the logs for the fan in the bedroom during startup, [16/10/2022, 22:40:40] Restoring existing accessory from cache: Haiku Salon but I presume the bedroom fan is "Haiku Chambre".

Each homebridge accessory must be registered with unique identifier. My plugin used the MAC address you specify in the config file as that unique ID. The plugin should use the MAC address provided by the fan instead of relying on the user to provide it in the config file but that's more complicated for me to code so I rely on the config file.

In fact it doesn't matter what you enter in the config file for the MAC address if it's unique among the accessories, the plugin only uses that for the unique identifier and reports it as the "serial number" to HomeKit.

So, can you verify the MAC address in the config file for the two fans is different?

Answer : Yes Next, I notice when you start the Haiku Salon the "persist" and "accessories" are removed. Can you do that also when you start the Haiku Chambre?

Answer : Usually I remove all cached accessories and I reset Homebridge accessory before restarting with a new configuration. I suppose the logs show that. Going forward could you send the config file along with the logs in email with the MAC un-redacted?

Answer : Yes, I will do that tonight. The next question is how do you determine when a fan is working? Are you changing a setting in the Home app to see if it responds? Or are you making a change with the remote or BAF app to see if the Home app shows the change? Whatever the method, could you note what you did at the appropriate time in the log file?

Answer : I look in the Accessories section of the Homebridge UI to ses if the Haiku accessories are created and if it’s possible to control the Haiku fan with it. The second step is to control the Haiku fan via the Home app in iOS. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/oogje/homebridge-i6-bigAssFans/issues/16#issuecomment-1281211859, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQKQPZWQDYDEACWJBDBTGVLWDWENNANCNFSM6AAAAAAQU3SURU. You are receiving this because you authored the thread.

thicla01 commented 1 year ago

For your information, yesterday I noticed that when I configure the Haiku fan that is working properly with the plugin, the CPU of the Raspberry Pi is around 3 to 6% load. With the Haiku fan that is not working, the CPU load is like 30%. There is no other plugins configured when I'm testing.

oogje commented 1 year ago

I got your configs and logs for the two fans. Perfect, thank you.

Comparing the configs I notice each of the fans use a different bridge "username" and "port". Can you make it so the "bridge" configurations for the two fans are identical? Use the working bridge configuration for both fans (the one with "pin" ending in "788").

The only things that should be different between the two config files are the "name", "ip", and "mac" values for the fan.

Can you rerun the test with the "Haiku Salon" and email the config file and results please?

thicla01 commented 1 year ago

OK. Il will try to do that tomorrow.

For your information, yesterday I noticed that when I configure the Haiku fan that is working properly with the plugin, the CPU of the Raspberry Pi is around 3 to 6% load. With the Haiku fan that is not working, the CPU load is like 30%. There is no other plugins configured when I'm testing.

oogje commented 1 year ago

Noted.

On Oct 18, 2022, at 9:57 PM, thicla01 @.***> wrote:

For your information, yesterday I noticed that when I configure the Haiku fan that is working properly with the plugin, the CPU of the Raspberry Pi is around 3 to 6% load. With the Haiku fan that is not working, the CPU load is like 30%. There is no other plugins configured when I'm testing.

thicla01 commented 1 year ago

I sent the logs by email a few minutes ago. Same behavior for the CPU load (3% vs 30%)

oogje commented 1 year ago

I received the logs, thank you.

Can you log into your raspberry pi and operate in the command line?

thicla01 commented 1 year ago

Yes. What do you need?

oogje commented 1 year ago

I'd like to bypass Homebridge UI.

Is the config file currently set up for Haiku Salon or Haiku Chambre?

thicla01 commented 1 year ago

Haiku Chambre

thicla01 commented 1 year ago

Control working with Accessories in Homebridge UI and HomeKit

oogje commented 1 year ago

Control working with Accessories in Homebridge UI and HomeKit

I don't understand.

thicla01 commented 1 year ago

Haiku Chambre is working in Homekit right now. I can configure with Haiku Salon it takes 2 minutes.

thicla01 commented 1 year ago

Sorry for the confusion

thicla01 commented 1 year ago

I'm in the command line in the Raspberry Pi. Just let me know what you need.

oogje commented 1 year ago

Great.

oogje commented 1 year ago

First I want you to kill the homebridge process from the command line with the kill command, then edit the config.json file with a text editor with some specific changes..

Change "Haiku Chambre" to "test fan". Change the IP to xxx.xxx.xxx.xxx (the real IP for Haiku Salon) Change the MAC address to "AB:CD:EF:01:23:45" save the changes,

start homebridge from the command line by (i'm guessing the path):

/usr/local/lib/node_modules/homebridge/bin/homebridge -I -D

It should output the logs to your window.

thicla01 commented 1 year ago

Yes, I will send you the new log by email.

thicla01 commented 1 year ago

email sent

oogje commented 1 year ago

I received it.

oogje commented 1 year ago

I assume it (test fan) still does not show up in the Home app on you iPad?

thicla01 commented 1 year ago

I have Haiku Chambre and Haiku Salon but both have the warning "No answer". Nothing about "test fan"

oogje commented 1 year ago

kill the homebridge process (cntrl-C in the window you started the command in). You should get a shell prompt.

remove the caches

rm /var/lib/homebridge/persist/*
rm /var/lib/homebridge/accessories/*

restart /usr/local/lib/node_modules/homebridge/bin/homebridge -I -D

Anything change in the Home app?

thicla01 commented 1 year ago

Sorry in a meeting. I will get back to you in a few minutes

oogje commented 1 year ago

No problem.

thicla01 commented 1 year ago

Done. No change in the Home app in iOS.

oogje commented 1 year ago

Now can you go into the Home app and in the Haiku Salon accessory settings drill down to the bridge and remove it. I would think that would also remove both the Haiku Salon and Haiku Cambre accessories.

If so, go ahead and kill and restart homebridge from the command line and let me know if anything changed in the Home app - like the appearance of the “test fan”.

thicla01 commented 1 year ago

Now the Haiku Chambre and Haiku Salon are removed. I try to add the bridge to HomeKit but I just have a spinning wheel.

thicla01 commented 1 year ago

It just timed out. Accessory not available.

oogje commented 1 year ago

Now I need to step away for an hour or so. Sorry.

thicla01 commented 1 year ago

No problem

oogje commented 1 year ago

Okay, would you edit the name, ip and mac in the config file to the values for the Haiku Chambre,

remove the caches:

rm /var/lib/homebridge/persist/*
rm /var/lib/homebridge/accessories/*

and kill and restart homebridge from the command line.

Can you add the homebridge to the Home app now or does it still time out?

oogje commented 1 year ago

No problem at all.

thicla01 commented 1 year ago

I'm back sorry. I did the modifications you asked. I added the bridge successfuly with the QR code in the Home app. The fan Haiku Chambre is also working.

thicla01 commented 1 year ago

Do you need the log?

oogje commented 1 year ago

No need for the log, thanks. Now would you edit the name, ip and mac in the config file to the values for the Haiku Salon,

kill homebridge from the command line, remove the bridge from the Home app through the Haiku Chambre accessory settings,

remove the caches:

rm /var/lib/homebridge/persist/*
rm /var/lib/homebridge/accessories/*

and restart homebridge from the command line.

And try to add homebridge to the Home app again.

thicla01 commented 1 year ago

Modifications done. Trying to add the bridge to the Home app with QR code. Spinning wheel again.

thicla01 commented 1 year ago

Timed out. Accessory not available.

thicla01 commented 1 year ago

Before I saw the spinning wheel, I saw the usual message that the accessory is not certified.

oogje commented 1 year ago

If I remember correctly you have a wall controller. Does it have an IP address?

thicla01 commented 1 year ago

Yes

oogje commented 1 year ago

How about adding the Haiku Chambre to the config file as an additional fan, before the Haniku Salon entry. All parameters the same but ip, mac and name.

kill/restart

Can you add the bridge to the Home app with that configuration.

thicla01 commented 1 year ago

I just add the wall control related to Haiku Chambre and it's working. I'm able to control the light.

thicla01 commented 1 year ago

Trying now for Salon

oogje commented 1 year ago

okay

thicla01 commented 1 year ago

With the wall control related to Haiku Salon, I have the same spinning Wheel.

thicla01 commented 1 year ago

Timed out