iobroker-community-adapters / ioBroker.yeelight-2

Control your yeelights with ioBroker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot control Yeelight Ceiling from a script

lexmephi opened this issue · comments

Hi!

Cannot switch the state of Yeelight Ceiling Light to "on" from a script. Somehow it gets turned off every time.

A script example

on("mihome.0.devices.switch_158d0002b221d8.click", function(obj){
    if(getState("mihome.0.devices.switch_158d0002b221d8.click").val == true){
        setState("yeelight-2.0.ceiling1-0x000000000370088e.control.power", true);
    }
});

If I will use simple

setState("yeelight-2.0.ceiling1-0x000000000370088e.control.power", true);

without subscription, everything is ok, lamp will not switch off

In the event log

type ID val ack from timestamp last change
stateChange yeelight-2.0.ceiling1-0x000000000370088e.control.power false true yeelight-2.0 2019-01-20 23:44:52.314 2019-01-20 23:44:52.314
stateChange yeelight-2.0.ceiling1-0x000000000370088e.info.connect true true yeelight-2.0 2019-01-20 23:44:52.314 2019-01-20 23:33:01.154
stateChange system.adapter.yeelight-2.0.outputCount 15 true yeelight-2.0 2019-01-20 23:44:44.391 2019-01-20 23:44:44.391
stateChange system.adapter.yeelight-2.0.inputCount 8 true yeelight-2.0 2019-01-20 23:44:44.391 2019-01-20 23:44:44.391
stateChange system.adapter.yeelight-2.0.uptime 706 true yeelight-2.0 2019-01-20 23:44:44.391 2019-01-20 23:44:44.391
stateChange system.adapter.yeelight-2.0.memHeapUsed 10.72 true yeelight-2.0 2019-01-20 23:44:44.391 2019-01-20 23:44:44.391
stateChange system.adapter.yeelight-2.0.memHeapTotal 13.83 true yeelight-2.0 2019-01-20 23:44:44.391 2019-01-20 23:44:14.383
stateChange system.adapter.yeelight-2.0.memRss 37.2 true yeelight-2.0 2019-01-20 23:44:44.391 2019-01-20 23:44:44.391
stateChange system.adapter.yeelight-2.0.connected true true yeelight-2.0 2019-01-20 23:44:44.391 2019-01-20 23:32:59.069
stateChange system.adapter.yeelight-2.0.alive true true yeelight-2.0 2019-01-20 23:44:44.390 2019-01-20 23:32:59.067
stateChange yeelight-2.0.ceiling1-0x000000000370088e.control.power true true yeelight-2.0 2019-01-20 23:44:43.930 2019-01-20 23:44:43.917

please try:

on("mihome.0.devices.switch_158d0002b221d8.click", function(obj){
    if(obj.newState.val){
        setState("yeelight-2.0.ceiling1-0x000000000370088e.control.power", true);
    }
});

no, the same...

type ID val ack from Timestamp Last change
stateChange yeelight-2.0.ceiling1-0x000000000370088e.control.power false true yeelight-2.0 2019-01-21 21:22:43.917 2019-01-21 21:22:43.917
stateChange yeelight-2.0.ceiling1-0x000000000370088e.info.connect true true yeelight-2.0 2019-01-21 21:22:43.916 2019-01-20 23:33:01.154
stateChange yeelight-2.0.ceiling1-0x000000000370088e.control.power true true yeelight-2.0 2019-01-21 21:22:35.530 2019-01-21 21:22:35.511
stateChange yeelight-2.0.ceiling1-0x000000000370088e.info.connect true true yeelight-2.0 2019-01-21 21:22:35.528 2019-01-20 23:33:01.154
stateChange yeelight-2.0.ceiling1-0x000000000370088e.control.power true false javascript.0 2019-01-21 21:22:35.511 2019-01-21 21:22:35.511

do you have any suggestions why this is happening?

no i havent, i also have a problem with the scene value if i send it from the object everything works, if i send it from a script it dosnt work. if i have some free time i will chekc this

Also happens when trying to set values via Node Red.
Anything we can do to help debugging it?

Edit:
Setting the adapter to debug shows that there is a send command:
(16729) SEND STATE: id:0x0000000005443143, state: rgb, value: #ff9800
when doing it via the "Objects" page.

Sending the same via Node-Red causes no reaction in the debug log.

Ah, k. Figured out my NR issue:

if (state && !state.ack) {
requires !state.ack, so sending new values as "Command" works.