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

add to homekit but can't control yeelight #2

Closed jackxu8 closed 5 years ago

jackxu8 commented 5 years ago

I have install this plugin and can see all the switch's in my homekit, but I can't control my yeelight in Homekit. Do I need get any things like token or IP to tell this plugin whick is my yeelight?

sahilchaddha commented 5 years ago

Hey @jackxu8 , You need to enable LAN Control for your yeelight lights. You can use Yeelight App to enable that setting for your light.

This setting makes sure that your light can expose its API to local network so that plugin can access and control the lights.

jackxu8 commented 5 years ago

Many thanks! Now it wotks. But only the main switch works. The scene modes is still don's. Another problem is that the the commend effect send by homekit is difficent form the comment effect send by Yeelight App. For example, after I set the full brightness in homekit, the Yeelight is not be setted to the full brightness. The brightness is much lower then the full brightness when I set it in Yeelight App. Is there any error on my operation?

Attached is my debug log for more detail.

Many thanks one more time.

` Loading logs from file CMD: sudo -n tail -n 200 -f /var/log/homebridge.log

{ id: -1, method: 'set_hsv', params: [ 44, 100, 'smooth', 500 ] } ] [11/19/2018, 11:07:20 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 saturation 13 [11/19/2018, 11:07:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 44, 13, 'smooth', 500 ] } ] [11/19/2018, 11:07:20 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 hue 37 [11/19/2018, 11:07:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 37, 13, 'smooth', 500 ] } ] [11/19/2018, 11:07:20 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 saturation 6 [11/19/2018, 11:07:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 37, 6, 'smooth', 500 ] } ] [11/19/2018, 11:07:20 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 hue 28 [11/19/2018, 11:07:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 28, 6, 'smooth', 500 ] } ] [11/19/2018, 11:07:20 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 saturation 3 [11/19/2018, 11:07:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 28, 3, 'smooth', 500 ] } ] [11/19/2018, 11:07:20 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 hue 22 [11/19/2018, 11:07:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 22, 3, 'smooth', 500 ] } ] [11/19/2018, 11:07:20 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 saturation 2 [11/19/2018, 11:07:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 22, 2, 'smooth', 500 ] } ] [11/19/2018, 11:07:22 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 hue 37 [11/19/2018, 11:07:22 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 37, 2, 'smooth', 500 ] } ] [11/19/2018, 11:07:22 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 saturation 14 [11/19/2018, 11:07:22 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 37, 14, 'smooth', 500 ] } ] [11/19/2018, 11:07:22 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 hue 36 [11/19/2018, 11:07:22 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 36, 14, 'smooth', 500 ] } ] [11/19/2018, 11:07:22 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 saturation 16 [11/19/2018, 11:07:22 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 36, 16, 'smooth', 500 ] } ] SyntaxError: Unexpected token { in JSON at position 28 at JSON.parse () at YeeDevice.didReceiveResponse (/usr/local/node/lib/node_modules/homebridge-yeelight-platform/node_modules/yeelight-platform/src/device.js:93:29) at Socket.socket.on (/usr/local/node/lib/node_modules/homebridge-yeelight-platform/node_modules/yeelight-platform/src/device.js:50:12) at Socket.emit (events.js:182:13) at addChunk (_stream_readable.js:283:12) at readableAddChunk (_stream_readable.js:264:11) at Socket.Readable.push (_stream_readable.js:219:10) at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) <Buffer 7b 22 69 64 22 3a 2d 31 2c 20 22 72 65 73 75 6c 74 22 3a 5b 22 6f 6b 22 5d 7d 0d 0a 7b 22 69 64 22 3a 2d 31 2c 20 22 72 65 73 75 6c 74 22 3a 5b 22 6f ... > [11/19/2018, 11:07:23 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 hue 48 [11/19/2018, 11:07:23 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 48, 16, 'smooth', 500 ] } ] [11/19/2018, 11:07:23 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 saturation 13 [11/19/2018, 11:07:23 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 48, 13, 'smooth', 500 ] } ] [11/19/2018, 11:07:24 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 hue 50 [11/19/2018, 11:07:24 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 50, 13, 'smooth', 500 ] } ] [11/19/2018, 11:07:24 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 saturation 20 [11/19/2018, 11:07:24 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_hsv', params: [ 50, 20, 'smooth', 500 ] } ] [11/19/2018, 11:07:53 PM] [Yeelight-Platform] [ ' Resetting all lights' ] [11/19/2018, 11:07:53 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'stop_cf', params: [] } ] [11/19/2018, 11:07:55 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_power', params: [ 'off', 'smooth', '500' ] } ] [11/19/2018, 11:08:09 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 power on [11/19/2018, 11:08:09 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500, 3 ] } ] [11/19/2018, 11:08:10 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 power off [11/19/2018, 11:08:10 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_power', params: [ 'off', 'smooth', 500, 3 ] } ] [11/19/2018, 11:08:12 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 power on [11/19/2018, 11:08:12 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500, 3 ] } ] [11/19/2018, 11:09:10 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500 ] } ] [11/19/2018, 11:09:12 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'start_cf', params: [ 0, 0, '2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10' ] } ] [11/19/2018, 11:09:12 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 power off [11/19/2018, 11:09:12 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_power', params: [ 'off', 'smooth', 500, 3 ] } ] [11/19/2018, 11:09:13 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'stop_cf', params: [] } ] [11/19/2018, 11:09:18 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'set_power', params: [ 'off', 'sudden', 500 ] } ] [11/19/2018, 11:09:18 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500 ] } ] [11/19/2018, 11:09:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'start_cf', params: [ 0, 0, '2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10' ] } ] [11/19/2018, 11:09:20 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 power on [11/19/2018, 11:09:20 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500, 3 ] } ] [11/19/2018, 11:09:22 PM] [Yeelight-Platform] Sending Command to LightBulb0x000000000531eed0 power off [11/19/2018, 11:09:22 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000531eed0' ], { id: -1, method: 'set_power', params: [ 'off', 'smooth', 500, 3 ] } ] [11/19/2018, 11:09:23 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'stop_cf', params: [] } ] [11/19/2018, 11:09:28 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'set_power', params: [ 'off', 'sudden', 500 ] } ] [11/19/2018, 11:09:28 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500 ] } ] [11/19/2018, 11:09:30 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'start_cf', params: [ 0, 0, '2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10' ] } ] [11/19/2018, 11:09:32 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'stop_cf', params: [] } ] [11/19/2018, 11:09:37 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'set_power', params: [ 'off', 'sudden', 500 ] } ] [11/19/2018, 11:09:38 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500 ] } ] [11/19/2018, 11:09:40 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'start_cf', params: [ 0, 0, '2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10' ] } ] [11/19/2018, 11:09:42 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'stop_cf', params: [] } ] [11/19/2018, 11:09:47 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83', '0x00000000052ebb4a' ], { id: -1, method: 'set_power', params: [ 'off', 'sudden', 500 ] } ] [11/19/2018, 11:09:47 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500 ] } ] [11/19/2018, 11:09:49 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83' ], { id: -1, method: 'set_power', params: [ 'on', 'smooth', 500, 5 ] } ] [11/19/2018, 11:09:55 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83' ], { id: -1, method: 'set_power', params: [ 'off', 'smooth', 500, 5 ] } ] [11/19/2018, 11:10:00 PM] [Yeelight-Platform] [ ' Sending Command to ', [ '0x000000000543dd83' ], { id: -1, method: 'set_power', params: [ 'off', 'sudden', 500 ] } ] [11/19/2018, 11:10:22 PM] [Config] Changes to config.json saved. `

sahilchaddha commented 5 years ago

Hey @jackxu8 ,

Looks like you have copied sample config from readme which was configured for advanced users. Try using this minimalist configuration =>

{
    "platforms": [
        {
            "platform": "Yeelight-Platform",
            "addResetSwitch": true,
            "shouldTurnOff": true,
            "scenes": [
                {
                    "name": "Sleep Time",
                    "scene": "custom",
                    "params": "2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10"
                },
                {
                    "name": "Disco Time",
                    "scene": "disco"
                },
                {
                    "name": "Police",
                    "scene": "police_1"
                }
            ]
        }
    ]
}

You can add more scenes by checking out available scenes or making your custom one.

sahilchaddha commented 5 years ago

@jackxu8 Regarding your question about inconsistent brightness between HomeKit and Yeelight App, i am unable to reproduce this issue at my end. The plugin uses Official Yeelight API to update the light. Can you tell me which Yeelight Device are you using ?

jackxu8 commented 5 years ago

My device is Yeelight LED Bulb (Color),https://www.yeelight.com/en_US/product/wifi-led-c, I update the plugin to the latest version, I will try it again, thank you for you work

sahilchaddha commented 5 years ago

@jackxu8 Did changing config.json fixed your Scene Switch issue ?