Zacknetic / HomebridgeMagicHome-DynamicPlatform

Homebridge Plugin for MagicHome LED controllers and light bulbs
Apache License 2.0
61 stars 11 forks source link

Brightness issues #22

Closed NajibNour closed 4 years ago

NajibNour commented 4 years ago

Hello, I just want to start off by saying thank you to the developers who have created and are maintaining this plugin!

I was wondering if you could help me out here. When I set 100% brightness in homekit it shows 39% brightness in the magic home app. When I do set brightness to 100% in the magic home app I can see a pretty big difference in the led brightness(Much Brighter). Not sure if this was intended to save led lifespan or if this is an issue on my end. Would there be any way to achieve true 100% brightness in homekit as well?

Using: Yuehuam LED Smart Controller, Single Color LED WiFi Controller

Config only containing the following:

   {
    "platform": "homebridge-magichome-dynamic-platform",
        "pruning": {
            "pruneMissingCachedAccessories": false,
            "restartsBeforeMissingAccessoriesPruned": 3,
            "pruneAllAccessoriesNextRestart": false
        },
        "whiteEffects": {
            "simultaniousDevicesColorWhite": true
        }
    }

Your reply is greatly appreciated!

Thanks.

Zacknetic commented 4 years ago

Try setting the config through the config ui plugin>homebridgemagichomedynamicplatform>settings and hitting save. Restart and see how it goes. That config does not look complete but may not be the issue.

Let me know how it goes or if you need any guidance.

NajibNour commented 4 years ago

I don't really use the config UI plugin but I installed it and proceeded with your instructions and the issue still persists.

Zacknetic commented 4 years ago

May You please upload your config.json file.

NajibNour commented 4 years ago

One sec let me sanitize it

NajibNour commented 4 years ago
{
    "bridge": {
        "name": "Bedroom_HomeBridge",
        "username": "01:23:45:67:89:AB",
        "port": 51826,
        "pin": "246-42-464"
    },
    "description": "Homebridge configuration for the Garage Door",
    "ports": {
        "start": 52100,
        "end": 52150,
        "comment": "This section is used to control the range of ports that separate accessory (like camera or television) should be bind to."
    },
    "accessories": [
        {
            "accessory": "GarageCommand",
            "name": "Garage Door",
            "open": "node /var/lib/homebridge/Ryobi/open.js",
            "close": "node /var/lib/homebridge/Ryobi/close.js",
            "state": "/var/lib/homebridge/Ryobi/state.sh",
            "status_update_delay": 15,
            "poll_state_delay": 7
        },
        {
            "accessory": "Dht",
            "name": "Bedroom Tempature",
            "service": "dht22",
            "gpio": "2"
        },
        {
            "accessory": "webostv",
            "name": "TV",
            "ip": "192.168.0.6",
            "mac": "20:3d:bd:b6:1a:14",
            "pollingInterval": 5,
            "tvService": true,
            "inputs": [
                {
                    "appId": "com.webos.app.hdmi1",
                    "name": "Apple Tv"
                },
                {
                    "appId": "com.webos.app.hdmi2",
                    "name": "PS4"
                }
            ],
            "volumeControl": "slider",
            "channelControl": false,
            "notificationButtons": [
                "Garage Door - Opened",
                "Garage Door - Closed",
                "Back Door - Locked",
                "Back Door - Unlocked"
            ]
        }
    ],
    "platforms": [
        {
            "platform": "config",
            "name": "Config",
            "port": 8080,
            "restart": "sudo -n systemctl restart homebridge",
            "log": {
                "method": "systemd",
                "service": "homebridge"
            }
        },
        {
            "platform": "Nest-cam",
            "access_token": "***TOKEN***",
            "ffmpegCodec": "libx264"
        },
        {
            "platform": "Nest",
            "access_token": "***TOKEN***",
            "options": [
                "HomeAway.Disable",
                "Thermostat.Eco.Disable",
                "Thermostat.Fan.Disable"
            ]
        },
        {
            "platform": "TplinkSmarthome",
            "name": "TplinkSmarthome"
        },
        {
            "pruning": {
                "pruneMissingCachedAccessories": false,
                "restartsBeforeMissingAccessoriesPruned": 3,
                "pruneAllAccessoriesNextRestart": false
            },
            "whiteEffects": {
                "simultaniousDevicesColorWhite": true,
                "colorWhiteThreshold": 10,
                "colorWhiteThresholdSimultaniousDevices": 50,
                "colorOffThresholdSimultaniousDevices": 5
            },
            "deviceManagement": {
                "blacklistOrWhitelist": "blacklist"
            },
            "platform": "homebridge-magichome-dynamic-platform"
        },
        {
            "platform": "AppleTvPlatform",
            "devices": [
                {
                    "name": "BedroomTV",
                    "credentials": "***TOKEN***",
                    "isOnOffSwitchEnabled": true,
                    "onOffSwitchName": "Tv ON-OFF",
                    "commandSwitches": [
                        {
                            "name": "Project Cameras",
                            "commands": [
                                {
                                    "wait": 7000
                                },
                                {
                                    "key": "topmenu",
                                    "longPress": false
                                },
                                {
                                    "wait": 2000
                                },
                                {
                                    "key": "topmenu",
                                    "longPress": false
                                },
                                {
                                    "wait": 2000
                                },
                                {
                                    "key": "topmenu",
                                    "longPress": false
                                },
                                {
                                    "wait": 2000
                                },
                                {
                                    "key": "select",
                                    "longPress": false
                                },
                                {
                                    "wait": 2000
                                },
                                {
                                    "key": "left",
                                    "longPress": false
                                },
                                {
                                    "wait": 600
                                },
                                {
                                    "key": "select",
                                    "longPress": false
                                },
                                {
                                    "wait": 500
                                },
                                {
                                    "key": "menu",
                                    "longPress": false
                                },
                                {
                                    "wait": 500
                                },
                                {
                                    "key": "left",
                                    "longPress": false
                                },
                                {
                                    "wait": 2000
                                },
                                {
                                    "key": "select",
                                    "longPress": false
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}
Zacknetic commented 4 years ago

I see no issues here, today was the first day of classes for me so I will be working on this come Saturday.

Thanks for being patient.

Zacknetic commented 4 years ago

Under normal circumstances, yes 100% is 100%. In the meantime, send me a sanitized log too. Thank you.

NajibNour commented 4 years ago

I looked over the logs nothing too abnormal. In debug mode, it does set the brightness value to 100%

Aug 27 13:45:43 Bedroom_Pi homebridge[27078]: 2020-08-27T17:45:43.614Z Accessory [Bedroom_HomeBridge] Processing characteristic set: [{"aid":10,"iid":9,"value":1},{"aid":10,"iid":12,"value":100}]
Aug 27 13:45:43 Bedroom_Pi homebridge[27078]: 2020-08-27T17:45:43.614Z Accessory [Bedroom_HomeBridge] Setting Characteristic "On" to value 1
Aug 27 13:45:43 Bedroom_Pi homebridge[27078]: 2020-08-27T17:45:43.616Z Accessory [Bedroom_HomeBridge] Setting Characteristic "Brightness" to value 100
Aug 27 13:45:43 Bedroom_Pi homebridge[27078]: 2020-08-27T17:45:43.619Z EventedHTTPServer [::ffff:192.168.0.36] Muting event '10.12' notification for this connection since it originated here.
Aug 27 13:45:43 Bedroom_Pi homebridge[27078]: 2020-08-27T17:45:43.620Z EventedHTTPServer [::ffff:192.168.0.102] Sending HTTP event '10.12' with data: {"characteristics":[{"aid":10,"iid":12,"value":100}]}
Aug 27 13:45:43 Bedroom_Pi homebridge[27078]: 2020-08-27T17:45:43.633Z EventedHTTPServer [::ffff:192.168.0.36] HTTP Response is finished

Here is the plugin adding in the cached accessory.(NON DEBUG)

Aug 27 13:48:41 Bedroom_Pi homebridge[27868]: [27/08/2020, 13:48:41] [homebridge-magichome-dynamic-platform] Scanning broadcast-address: '192.168.0.255' on interface: 'wlan0' for Magichome lights...
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: [27/08/2020, 13:48:43] [homebridge-magichome-dynamic-platform]
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Found 1 devices.
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: [27/08/2020, 13:48:43] [homebridge-magichome-dynamic-platform]
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Registering cached accessory 'Counter Lights'
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Model: 'AK001-ZJ2101'
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Unique ID: 'D8F15BF6C9B9'
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: IP-Address: '192.168.0.110'
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Version 99
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Version Modifier: 33
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: [27/08/2020, 13:48:43] [homebridge-magichome-dynamic-platform]
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Registered 1 Magichome device(s).
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: New devices: 0
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Cached devices that were seen this restart: 1
Aug 27 13:48:43 Bedroom_Pi homebridge[27868]: Cached devices that were not seen this restart: 0

let me know if there is anything else you need!

Zacknetic commented 4 years ago

Huh, I can't believe this wasn't caught before. I think I know the issue. The brightness values are not being converted properly from % to byte. Change coming in a bit.

Zacknetic commented 4 years ago

@NajibNour Give it a try, should be working now after you update and restart.

NajibNour commented 4 years ago

After updating the plugin, HomeBridge seems to be crashing unexpectedly, I have reverted back to 1.38 in the meantime. Here are the logs for that.

  Aug 27 14:43:26 Bedroom_Pi homebridge[962]: (node:962) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]: (Use `node --trace-warnings ...` to show where the warning was created)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]: [27/08/2020, 14:43:26] Error: The requested platform 'homebridge-magichome-dynamic-platform' was not registered by any plugin.
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at PluginManager.getPluginForPlatform (/usr/lib/node_modules/homebridge/src/pluginManager.ts:223:15)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at /usr/lib/node_modules/homebridge/src/server.ts:361:37
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at Array.forEach (<anonymous>)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at Server.loadPlatforms (/usr/lib/node_modules/homebridge/src/server.ts:348:27)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at Server.start (/usr/lib/node_modules/homebridge/src/server.ts:151:29)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at cli (/usr/lib/node_modules/homebridge/src/cli.ts:74:10)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at Module._compile (internal/modules/cjs/loader.js:1185:30)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]:     at Module.load (internal/modules/cjs/loader.js:1034:32)
  Aug 27 14:43:26 Bedroom_Pi homebridge[962]: [27/08/2020, 14:43:26] Got SIGTERM, shutting down Homebridge...
Zacknetic commented 4 years ago

@NajibNour Apologies, things should be working now. Please update. My suggestion is that if you get errors this time, check "prune all accessories next restart">restart homebridge>uncheck "prune all accessories next restart". See how that goes.

NajibNour commented 4 years ago

I have updated and followed your instructions, upon home bridge starting everything works fine until I open the home app from my phone.

  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]: [27/08/2020, 15:26:05] Error: This callback function has already been called by someone else; it can only be called one time.
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:6:13
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at DimmerStrip.getOn (/usr/local/lib/node_modules/homebridge-magichome-dynamic-platform/src/PlatformAccessory.ts:249:5)
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at Characteristic.emit (events.js:327:22)
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at Characteristic.EventEmitter.emit (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at Characteristic._this.getValue (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:451:12)
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1180:22
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at Array.forEach (<anonymous>)
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at Bridge.Accessory._this._handleGetCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1108:10)
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at HAPServer.emit (events.js:315:20)
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]:     at HAPServer.EventEmitter.emit (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
  Aug 27 15:26:05 Bedroom_Pi homebridge[3642]: [27/08/2020, 15:26:05] Got SIGTERM, shutting down Homebridge...
Zacknetic commented 4 years ago

Please run the "prune all accessories next restart" function in the settings. Then disable it.

NajibNour commented 4 years ago

Oddly I did that the first time and it did not work, this time it did the trick! it is seeing it as an RGBWW now tho not sure why. Config has not changed "simultaniousDevicesColorWhite" is still set to true.

  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: [27/08/2020, 15:43:10] [homebridge-magichome-dynamic-platform]
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Discovered 1 devices.
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: [27/08/2020, 15:43:10] [homebridge-magichome-dynamic-platform]
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Registering cached accessory 'RGBWW Non-Simultanious'
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Model: 'AK001-ZJ2101'
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Unique ID: 'D8F15BF6C9B9'
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: IP-Address: '192.168.0.110'
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Version 5
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Version Modifier: 53
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: [27/08/2020, 15:43:10] [homebridge-magichome-dynamic-platform]
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Registered 1 Magichome device(s).
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: New devices: 0
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Cached devices that were seen this restart: 1
  Aug 27 15:43:10 Bedroom_Pi homebridge[7926]: Cached devices that were not seen this restart: 0
Zacknetic commented 4 years ago

Hi @NajibNour , thank you for waiting,

I've updated the plugin. It now has improved version determination and should solve your problem.

Please update in config ui x > plugins > homebridge-magichome-dynamic-platform > update. (!Important!) Next purge all magic-home accessories by going to config ui x > plugins > homebridge-magichome-dynamic-platform > settings > checkmark "Prune All Accessories Next Restart (Warning Dangerous!)" > restart homebridge at least twice > un-checkmark "Prune All Accessories Next Restart (Warning Dangerous!)" > restart homebridge.

Let me know how this goes.

NajibNour commented 4 years ago

Sorry for the delay, I have been busy all day! This now works beautifully! Both the brightness issue and "simultaniousDevicesColorWhite" Have been resolved. Thank you once again for creating this great plugin!

Version 1.4.2

Zacknetic commented 4 years ago

Yes! So good to hear. Thank you for giving it another shot.