eibenp / homebridge-gree-airconditioner

Homebridge plugin for GREE Air Conditioners
Apache License 2.0
26 stars 3 forks source link

Failed to save cached accessories to disk: Converting circular structure to JSON #16

Closed dsylex closed 1 month ago

dsylex commented 3 months ago

Describe The Bug: Devices do not persist through restart. They do add fine but stop working after HB or child bridge restart.

To Reproduce: Add devices to GUI or JSON config.

Remarks:

70% of storage is unused on device and HB has R/W access to it.

Logs:

[15/08/2024, 08:56:32] Failed to save cached accessories to disk: Converting circular structure to JSON
    --> starting at object with constructor 'ControllerStorage'
    |     property 'linkedAccessories' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'ControllerStorage'
    --- property 'parent' closes the circle
[15/08/2024, 08:56:32] Your accessories will not persist between restarts until this issue is resolved.
[15/08/2024, 08:56:32] [GREE Air Conditioner] Accessory f4911eb7b74d skipped
[15/08/2024, 08:56:32] [GREE Air Conditioner] [Garden Office AC -- 192.168.1.206:7000] Device is bound -> XXXXXXXXXXe35
[15/08/2024, 08:56:32] [GREE Air Conditioner] [Wardrobe AC -- 192.168.1.205:7000] Device is bound -> XXXXXXXXXX41d
[15/08/2024, 08:56:32] [GREE Air Conditioner] [Kid1 AC -- 192.168.1.204:7000] Device is bound -> XXXXXXXXXX767

Plugin Config:

    "name": "GREE Air Conditioner",
    "port": 7002,
    "scanAddress": "192.168.1.255",
    "scanCount": 10,
    "scanTimeout": 3,
    "devices": [
        {
            "mac": "XXXXXXXXXXe35",
            "name": "Garden Office AC",
            "speedSteps": 5,
            "statusUpdateInterval": 10,
            "sensorOffset": 40,
            "minimumTargetTemperature": 16,
            "maximumTargetTemperature": 30,
            "xFanEnabled": true,
            "temperatureSensor": "separate",
            "overrideDefaultVerticalSwing": 0,
            "defaultVerticalSwing": 0,
            "encryptionVersion": 0
        },
        {
            "mac": "XXXXXXXXXX767",
            "name": "Kid1 AC",
            "speedSteps": 5,
            "statusUpdateInterval": 10,
            "sensorOffset": 40,
            "minimumTargetTemperature": 16,
            "maximumTargetTemperature": 30,
            "xFanEnabled": true,
            "temperatureSensor": "separate",
            "overrideDefaultVerticalSwing": 1,
            "defaultVerticalSwing": 2,
            "encryptionVersion": 0
        },
        {
            "mac": "XXXXXXXXXX41d",
            "name": "Wardrobe AC",
            "speedSteps": 5,
            "statusUpdateInterval": 10,
            "sensorOffset": 40,
            "minimumTargetTemperature": 16,
            "maximumTargetTemperature": 30,
            "xFanEnabled": true,
            "temperatureSensor": "separate",
            "overrideDefaultVerticalSwing": 2,
            "defaultVerticalSwing": 2,
            "encryptionVersion": 0
        }
    ],
    "platform": "GREEAirConditioner",
    "_bridge": {
        "username": "0E:C6:D6:XX:XX:B7",
        "port": 50831
    }
}

Environment:

eibenp commented 3 months ago

This is not bug of the plugin. Cache is maintained by Homebridge not by plugins. The only solution I know is the following:

  1. Uninstall Homebridge
  2. Remove all related files including configuration files and dirs.
  3. Install Homebridge
  4. Install plugins
  5. Configure plugins as you do with new plugins at first time use (DO NOT RESTORE any configuration from backup because backup contains the same corrupted configuration as the cache!)
dsylex commented 3 months ago

This is not bug of the plugin. Cache is maintained by Homebridge not by plugins. The only solution I know is the following:

  1. Uninstall Homebridge
  2. Remove all related files including configuration files and dirs.
  3. Install Homebridge
  4. Install plugins
  5. Configure plugins as you do with new plugins at first time use (DO NOT RESTORE any configuration from backup because backup contains the same corrupted configuration as the cache!)

I have no issues with other plugins (30-40+) or accessories (200+) so I assumed it was this plugin. Prior to going nuclear as you've advised I digged around in the cache and it seems to be working now.

For future reference, the steps I did to fix the issues:

For no apparent reason it seems as though the plugin is creating more instances of the same accessories.

eibenp commented 3 months ago

Thank You for telling me a more useful solution. I will check this issue. Can you help me how to check cached accessories? I am not familiar with HB cache. By me this plugin works without any issues and no one else has told me a similar issue yet.

dsylex commented 3 months ago

Thank You for telling me a more useful solution. I will check this issue. Can you help me how to check cached accessories? I am not familiar with HB cache. By me this plugin works without any issues and no one else has told me a similar issue yet.

Sure, no problem :) I left my solution here for future reference if someone else encounters the same issue and maybe something you'd like to look into.

Most simple way to check cached accessories is via the GUI: 3dot menu -> Settings -> Remove Single Cached Accessory

and look for anything related to "homebridge-gree-ac")

P.S.: I'm really happy that this solution worked, tbh as this seems to be the best implementation of Gree AC control plugin so far (I've tried all of them in both HB and HA), so kudos. :)

DanielKupiniak commented 3 months ago

@dsylex Hi, I have the same issue when I've changed "temperatureSensor": "disabled", to separate value, changing it back resolves the error. But not quite. I could control units from the Homebridge accessories web UI, but not from the Apple Home app. Apple Home app shows me that units are "updating". I used your solution and under 3dot menu -> Settings -> Remove Single Cached Accessory apart from units entry duplicated "temperature sensor entries", I've removed them and restarted the plugin and it started working

eibenp commented 1 month ago

@dsylex @DanielKupiniak Hi, this issue is fixed in version v2.1.2