igdr / node-red-contrib-xiaomi-smart-devices

8 stars 4 forks source link

Cannot control the gateway (maybe due to new firmware?) #32

Open quyetvk opened 4 years ago

quyetvk commented 4 years ago

Hi @igdr

Thank you for your developing nodes. I am using nodes to control the gateway. The node can connect to Gateway but it seem it cannot control it (only receive event from Gateway) For example, I use function to change the light of gateway:

let cmd = {
    "rgb": 440038609
}
msg.payload = cmd;
return msg;

After that, the node show received message but the Gateway's light is not controlled

{"fromip":"NodeRED_IP:9898","ip":"NodeRED_IP","port":9898,"payload":{"sid":"xxxxxxxxxx","cmd":"write","model":"gateway","data":{"rgb":440038609,"key":"xxxxxxxxxxxxxxxxx"}},"_msgid":"c214c09f.ded6e"}

If I use Mi Home to control light, I received the event from Gateway (report event):

{"fromip":"Gateway_IP:4321","ip":"Gateway_IP","port":4321,"payload":{"cmd":"report","model":"gateway","sid":"xxxxxxxxxx","short_id":0,"data":{"rgb":0,"illumination":1292}},"_msgid":"1093628b.43d86d"}

I guess due to gateway's firmware is changed, the command format is changed. Do you have any idea?

Thank you!

igdr commented 4 years ago

Hi, I am using the last one firmware and everything works fine. Here is my example with sound which I have just tried. Can you check it up?

image

quyetvk commented 4 years ago

Thank you for your reply.

I tried the same thing but cannot receive the the confirmation packet ("report" packet) and there is no sound. Capture

The sent message from your NodeRED server is same format as mine?

igdr commented 4 years ago

image

quyetvk commented 4 years ago

Your first message is same as mine. But I did not receive second message (write_ack). I don't know why.

igdr commented 4 years ago

Just double-check sid of your gateway, you can find it in mobile app

quyetvk commented 4 years ago

I think SID is no problem. I found that SID is MAC address of my gateway. And SID of gateway is auto determined by node (there is no SID configuration in node configurator)

ghost commented 4 years ago

I get a message when I try to control the color and brightness of the gateway

works every other time - sometimes it turns on the desired color normally, sometimes it gives an error

what's wrong?

michaelblight commented 4 years ago

I can't get this to work either for sound or rgb. I'm not getting an error, but do get the output msg suggesting it was sent.

I saw on another issue there may be a conflict with the hub set up in both Home Assistant and Node Red. When I have it configured in Home Assistant, I can play a ringtone from HA. However, never from Node red, even if I remove the HA config and restart HA.

Also, when I do play a ringtone from HA, I would expect the Node Red instance to show the event, but it does not.

mobamoba commented 3 years ago

In order to make this problem go away, I had to disable the Mi Home app completely as in freeze/disable it because otherwise it autostarts itself. I think the gateway runs into trouble when it's receiving commands from more than one place.

Also, I found I needed to wait a good minute after startup/re-deploy and also insert 10 seconds delays between commands, like if I want the LED to change color AND have an alarm go off those need a little spacing.

I'm not saying it works perfectly 100% of the time, but disabling the app (or uninstalling it or putting it on a device you never turn on and only using it if you decide to add another sensor/light/whatever) helped a lot in my case.