sahilchaddha / homebridge-yeelight-platform

Homebridge plugin for Yeelight Lights supporting Scenes/Moods/Color Flow/Custom Presets/Music Flow/Night Mode
MIT License
58 stars 7 forks source link

Can’t turn on my lights. Just turn them off #4

Closed phenomeus closed 5 years ago

phenomeus commented 5 years ago

Hi

I discovered your plugin today and installed it (removed Homebridge-Yeelight for this)

But now I can’t turn my light on. Just off?!

Can you help?

Best regards

sahilchaddha commented 5 years ago

Hi, I hope you removed your old devices created from homebridge-yeelight, and you can now see new lights created by homebridge-yeelight-platform.

I am also assuming that you can turn off the lights using this plugin but are unable to turn them on. That means that connection between plugin and light is established.

Can you share some logs with us ? Also set debug to true to get detailed logs. Also Try Restarting your yeelights by power source & homebridge. This will let the plugin to rediscover and reconnect to all devices.

Also do note Yeelight Devices has a limit on connected devices. Make sure homebridge-yeelight is properly uninstalled from your node_modules else homebridge-yeelight-platform will be unable to communicate.

phenomeus commented 5 years ago

hi, thanks for the quick answer.

i uninstalled the old plugin, and removed the folders accessories and persist, so I had to re-add the whole HomeBridge to my Homekit. I'm pretty sure the old plugin is gone

how can I extract the log from the rpi when I use homebridge with systemd? the log is already on debug mode

sahilchaddha commented 5 years ago

Maybe this will help you get the logs => tail -F /var/log/daemon.log or journalctl -f -u homebridge or sudo journalctl --unit=homebridge.service --since=2016-11-01

phenomeus commented 5 years ago

ok here we go. 9MB log file since 7th December 2018. logggg.log

sahilchaddha commented 5 years ago

Hey @phenomeus , Unfortunately these logs are not helpful. They only have one event from Yeelight-Platform. And its full of logs from harmony plugin.

Lets start with a much neater approach to debug this issue.

  1. Make sure LAN Control is enabled for each light on Yeelight App.

  2. Stop your original currently running homebridge instance systemctl stop homebridge

  3. Create new directory

mkdir ~/.yeehome

  1. Copy this config file to your raspberrypi as config.json inside a newly created folder ~/.yeehome/config.json
{
    "bridge": {
        "name": "Dummy-Bridge",
        "username": "CB:02:AB:AC:CD:48",
        "port": 51823,
        "pin": "921-80-105"
    },
    "description": "New Dummy House",
    "accessories": [],
    "platforms": [{
        "platform": "Yeelight-Platform",
        "debug": true,
        "addResetSwitch": true,
        "shouldTurnOff": true,
        "scenes": [{
                "name": "Police_1",
                "scene": "police_1"
            },
            {
                "name": "Police_2",
                "scene": "police_2"
            },
            {
                "name": "Night Mode",
                "scene": "night_mode"
            }
        ]
    }]
}
  1. Start a new Homebridge service with new config file. Assuming you have homebridge installed globally.

homebridge -D -U ~/.yeehome

  1. Add a New Home in Home App & add new homebridge bridge to control the accessories.

  2. Play around with lights and scenes, while capturing the logs.

  3. After sufficient amount of logs, you can kill new homebridge service with Control+C, & start your original homebridge service. You can also delete Dummy Home added in HomeKit.

Starting Original Homebridge Service systemctl start homebridge

phenomeus commented 5 years ago

sorry, I enabled debug for your plugin, I thought its enough to have it on debug for homebridge.

is this log better?

yelight_debug.log

sahilchaddha commented 5 years ago

Hey @phenomeus ,

I have refactored some code in Interaction between HomeKit & Plugin. Have also added few extra debug logs to help us to identify the issue.

Please uninstall the current version of the plugin before installing

npm install -g git://github.com/sahilchaddha/homebridge-yeelight-platform.git#dev

Once installed, try running homebridge as normal, play around with lights, change brightness etc, and wait for atleast 30-60 seconds to capture some extra device update logs as well.

Do share the logs here, will help us to identify the core issue.

https://github.com/sahilchaddha/homebridge-yeelight-platform/pull/5

phenomeus commented 5 years ago

`npm ERR! code 128 npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b dev git://github.com/sahilchaddha/homebridge-yeelight-platform.git /root/.npm/_cacache/tmp/git-clone-a103a47b npm ERR! fatal: Konnte führende Verzeichnisse von '/root/.npm/_cacache/tmp/git-clone-a103a47b' nicht erstellen.: Keine Berechtigung npm ERR!

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-12-08T16_06_26_826Z-debug.log`

tried with --unsafe-perm still no help

sahilchaddha commented 5 years ago

Hey @phenomeus , This looks like permissions issue. npm is not able to install plugin from github.

Maybe try sudo

sudo npm install -g git://github.com/sahilchaddha/homebridge-yeelight-platform.git#dev

Which Linux user runs your homebridge instance ? What is your node version ? I am assuming since its a systemd job, it has its own Linux user ?

phenomeus commented 5 years ago

hi @sahilchaddha, my error from above is already with sudo, without sudo.

i fixed it by going to "sudo su" and the command: sudo npm install -g git://github.com/sahilchaddha/homebridge-yeelight-platform.git#dev

and yes, I have a homebridge user for my instance. node v8.11.3 npm v6.4.1

phenomeus commented 5 years ago

and here is the crashing homebridge

[2018-12-9 09:18:02] [Yeelight-Platform] [ ' Starting discovery ' ] [2018-12-9 09:18:02] [Yeelight-Platform] [ ' Adding Base Accessories' ] [2018-12-9 09:18:02] [Yeelight-Platform] [ ' Adding new FlowSwitch Police_1' ] [2018-12-9 09:18:02] [Yeelight-Platform] [ ' Adding new FlowSwitch Police_2' ] [2018-12-9 09:18:02] [Yeelight-Platform] [ ' Adding new FlowSwitch Night Mode' ] [2018-12-9 09:18:02] [Yeelight-Platform] [ ' Adding ResetSwitch' ] [2018-12-9 09:18:02] [homebridge-miio.XiaomiMiio] DidFinishLaunching [2018-12-9 09:18:02] [homebridge-yeelight.yeelight] DidFinishLaunching [2018-12-9 09:18:02] [homebridge-yeelight.yeelight] no ble cap, skip ble device discovery [2018-12-9 09:18:02] Homebridge is running on port 51823. [2018-12-9 09:18:02] [Yeelight-Platform] [ ' Discovery Started **' ] Error: bind EADDRINUSE 0.0.0.0:1982 at Object._errnoException (util.js:992:11) at _exceptionWithHostPort (util.js:1014:20) at _handle.lookup (dgram.js:266:18) at _combinedTickCallback (internal/process/next_tick.js:141:11) at process._tickCallback (internal/process/next_tick.js:180:9) at Function.Module.runMain (module.js:695:11) at startup (bootstrap_node.js:191:16) at bootstrap_node.js:612:3

sahilchaddha commented 5 years ago

This exception means socket 1982 required by homebridge-yeelight-platform is already in use.

As i can see from the logs [2018-12-9 09:18:02] [homebridge-yeelight.yeelight] no ble cap, skip ble device discovery, homebridge-yeelight is still installed. You need to uninstall it properly

phenomeus commented 5 years ago

how to uninstall properly then? I didn't think that I missed that, sorry

phenomeus commented 5 years ago

i uninstalled it again, still this error

[2018-12-9 09:52:44] [Yeelight-Platform] [ ' Starting discovery ' ] [2018-12-9 09:52:44] [Yeelight-Platform] [ '** Adding Base Accessories' ] [2018-12-9 09:52:44] [homebridge-miio.XiaomiMiio] DidFinishLaunching [2018-12-9 09:52:44] Homebridge is running on port 51823. Error: bind EADDRINUSE 0.0.0.0:1982 at Object._errnoException (util.js:992:11) at _exceptionWithHostPort (util.js:1014:20) at _handle.lookup (dgram.js:266:18) at _combinedTickCallback (internal/process/next_tick.js:141:11) at process._tickCallback (internal/process/next_tick.js:180:9) at Function.Module.runMain (module.js:695:11) at startup (bootstrap_node.js:191:16) at bootstrap_node.js:612:3

sahilchaddha commented 5 years ago

@phenomeus Try restarting your system, some service is already using socket 1982. And make sure no other homebridge instance is running on the system.

phenomeus commented 5 years ago

done, its the main systemctl homebridge service that is already running and using the port

ok now I will use the plugin and generate some logs

phenomeus commented 5 years ago

ok here I'm back, turned on, off, adjusted every light I have. the desk lamp is also working (flawless), the light strip also working perfectly and flawless, only the newest v2 bulbs white are not turning on by click or sliding at all. the ceiling 450 as the other 2 kids ceiling are turning on ONLY by sliding but not by click.

the reset scene button is not working at all, the night mode is working, but I can't escape it without a working reset scene.

I hope the log helps

yeelightdev_log.log

sahilchaddha commented 5 years ago

Hey @phenomeus ,

I am glad it solved your issue for multiple lights. You can turn off Night mode by turning off Night Mode Switch instead of Reset Scenes.

I can see multiple issues with your ceiling lights according to logs =>

  1. Dez 09 09:58:38 raspberrypi homebridge[4122]: [2018-12-9 09:58:38] [Yeelight-Platform] Sending Command to LightBulb0x00000000049a0763 ct 361
    Dez 09 09:58:38 raspberrypi homebridge[4122]: [2018-12-9 09:58:38] [Yeelight-Platform] [ '** Sending Command to ',
    Dez 09 09:58:38 raspberrypi homebridge[4122]:   [ '0x00000000049a0763' ],
    Dez 09 09:58:38 raspberrypi homebridge[4122]:   { id: -1, method: 'set_ct_abx', params: [ 4167, 'smooth', 500 ] } ]
    Dez 09 09:58:38 raspberrypi homebridge[4122]: [2018-12-9 09:58:38] [Yeelight-Platform] [ 'Device Response',
    Dez 09 09:58:38 raspberrypi homebridge[4122]:   { id: -1,
    Dez 09 09:58:38 raspberrypi homebridge[4122]:     error: { code: -1, message: 'client quota exceeded' } } ]

This error is being returned by light. It basically means lights are rejecting multiple requests from the plugin. The lights have Request limit of 60 calls per minute. Exceeding those calls will block the plugin to spam the lights with many requests.

To solve this issue, limit your requests per minute to the light.

You can refer to https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf It says

NOTE: Currently WiFi smart device support up to 4 simultaneous TCP connections, any further
connect attempt will be rejected. For each connection, there is a command message quota,
that is 60 commands per minute. There is also a total quota for all the LAN commands: 144
commands per minute 4 × 60 × 60%.

2.

Dez 09 10:03:12 raspberrypi homebridge[4122]: [2018-12-9 10:03:12] [Yeelight-Platform] Sending Command to LightBulb0x0000000005e778bf power on
Dez 09 10:03:12 raspberrypi homebridge[4122]: [2018-12-9 10:03:12] [Yeelight-Platform] [ '** Sending Command to ',
Dez 09 10:03:12 raspberrypi homebridge[4122]:   [ '0x0000000005e778bf' ],
Dez 09 10:03:12 raspberrypi homebridge[4122]:   { id: -1,
Dez 09 10:03:12 raspberrypi homebridge[4122]:     method: 'set_power',
Dez 09 10:03:12 raspberrypi homebridge[4122]:     params: [ 'on', 'smooth', 500, 3 ] } ]
Dez 09 10:03:12 raspberrypi homebridge[4122]: Sun, 09 Dec 2018 09:03:12 GMT EventedHTTPServer [::ffff:192.168.1.104] HTTP Response is finished
Dez 09 10:03:12 raspberrypi homebridge[4122]: [2018-12-9 10:03:12] [Yeelight-Platform] [ 'Device Response', { id: -1, result: [ 'ok' ] } ]
Dez 09 10:03:12 raspberrypi homebridge[4122]: [2018-12-9 10:03:12] [Yeelight-Platform] [ 'Device Response',
Dez 09 10:03:12 raspberrypi homebridge[4122]:   { id: -1, error: { code: -5000, message: 'general error' } } ]

This error is returned by ceiling light, when power on command is sent. This is unknown error general error -5000. I am not sure what this error is. Since it is not documented, we will need to raise this issue to Yeelight Developers. I can see multiple people facing this

https://github.com/home-assistant/home-assistant/issues/17444

Let me see if i can fix anything from the plugin side.

I can see multiple disconnects stating Host is unreachable

ez 09 09:43:41 raspberrypi homebridge[4122]: [2018-12-9 09:43:41] [Yeelight-Platform] Disconnected 0x00000000049a0763
Dez 09 09:43:41 raspberrypi homebridge[4122]: Socket Closed : { Error: connect EHOSTUNREACH 192.168.1.103:55443
Dez 09 09:43:41 raspberrypi homebridge[4122]:     at Object._errnoException (util.js:992:11)
Dez 09 09:43:41 raspberrypi homebridge[4122]:     at _exceptionWithHostPort (util.js:1014:20)
Dez 09 09:43:41 raspberrypi homebridge[4122]:     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
Dez 09 09:43:41 raspberrypi homebridge[4122]:   code: 'EHOSTUNREACH',
Dez 09 09:43:41 raspberrypi homebridge[4122]:   errno: 'EHOSTUNREACH',
Dez 09 09:43:41 raspberrypi homebridge[4122]:   syscall: 'connect',
Dez 09 09:43:41 raspberrypi homebridge[4122]:   address: '192.168.1.103',
Dez 09 09:43:41 raspberrypi homebridge[4122]:   port: 55443 }
Dez 09 09:43:41 raspberrypi homebridge[4122]: Reconnecting in 5 secs

The plugin will try to reconnect the lights after 5 seconds of disconnection. Make sure your lights are connected to Wifi and are working properly.

Avoid using Yeelight App simultaneously with Yeelight-Platform, this will limit the number of connected clients to app.

Looks like most of your issues are light returning random errors, instead of the plugin itself. I will try to raise this issue to Yeelight. Meanwhile you can try restarting your yeelights & re-pair them to your Yeelight App and re-enable LAN Control

sahilchaddha commented 5 years ago

@phenomeus Looks like i have resolved your original issue where you are unable to power on the devices. I have updated the dev branch with a potential fix.

The issue was set_power command on older devices like ceiling1 expects different number of params. Fixed it now.

Can you kindly re-install the plugin, and test it and confirm it for us ?

Installation => npm install -g git://github.com/sahilchaddha/homebridge-yeelight-platform.git#dev Make sure to uninstall and delete older version of the plugin

phenomeus commented 5 years ago

... and it’s working! Awesome. Every light is doing what it should. On, off, dimm, adjust, scenes are doing what they have to.

So only the Spamming is to solve, what you wanted to do with Yeelight, right?

sahilchaddha commented 5 years ago

@phenomeus Awesome, il reduce device update polling calls to reduce network traffic. Allow me some time to merge the PR and release a new version on npm.

sahilchaddha commented 5 years ago

@phenomeus , You can update the plugin to version 1.2.0 from npm.

razvanu commented 4 years ago

it will work with version 2.x on yeelight bulb light led ?