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

8 stars 4 forks source link

Multiple msg ? #4

Closed piznel closed 5 years ago

piznel commented 5 years ago

Hello, Congratulations on this work! I have a magic cube, several temperature sensors, opening alarms and switch. I have several questions: 1- Why in your diagram, did you connect the devices to the output of the gateway? By doing like you, I have several times the same payload per action on a device. 2-What are the nodes of the equipment for, because by putting the gateway alone, I get the same message? 3-could you share your processing function before the MQTT? Thank you in advance:)

GoSpursGoNL commented 5 years ago

I also would like to know the answers to these questions. I did quite a bit of searching to find a good Xiaomi module for Node-Red. This one seems the best but still it seems to have some issues, or I'm doing something wrong.

Like:

Door opens... Message 1: status: open, previous status: close (correct) Message 2 (3 milliseconds later): status: open, previous status: open (why this message?) Door closes... Message 3: status: close, previous status: open (correct) Message 4 (2 milliseconds later): status: close, previous status: close (why this message?)

/edit: played around a bit more and suddenly I'm receiving 4 messages for each event, instead of 2. It's message 2 and message 4 of above example (the useless messages) that appears 2 times more. This can be handled by putting a RBE node on 'payload.status' before the debug node to filter out the duplicate messages, but things like that should not be necessary.

GoSpursGoNL commented 5 years ago

Hi @igdr would you be able to have a look at these issues?

realjax commented 5 years ago

Same problem here. I actually got 5 (almost) similar door opening messages. There were some initial messages that reported the door opening but had no battery status info, only the last three did.

GoSpursGoNL commented 5 years ago

I gave up on Xiaomi Gateway in combination with Node-RED as there doesn't seem to be a proper module. I now use it in Node-RED via Home Assistant which works flawlessly.

realjax commented 5 years ago

Hmm, I'm not too eager to have to configure another package ( HA )

GoSpursGoNL commented 5 years ago

I can understand that. In my case I'm already using HA and all my automations are in NR. Fortunately the integration between the two is superb, via this module: https://community.home-assistant.io/t/node-red-contrib-home-assistant-websocket/71032

realjax commented 5 years ago

I'll have a look at that, thanks.

Meanwhile, there seems to be something going haywire in the specific device code. The gateway itself is correctly sending only two messages so it seems. One for open and one for close. I'll run through the code to see if I can find out what is happening..

igdr commented 5 years ago

I will look at it this problem this weekend

igdr commented 5 years ago

The issue with duplicating messages has been fixed, the new version is 1.0.9. Could you check it up?

realjax commented 5 years ago

Hi, thanks for the fix. Did a quick test with a door sensor and ended up getting 3 messages, I guess it has to do with getting the battery level?

msg : Object object fromip: "192.168.1.208:4321" ip: "192.168.1.208" port: 4321 payload: object status: "open" previous_status: null voltage: null voltage_level: null time: 1552122873493 device: "zolder" _msgid: "7b03df92.11fb9" 09/03/2019, 10:14:34node: 8e1326ed.b5dbe8

msg : Object object fromip: "192.168.1.208:4321" ip: "192.168.1.208" port: 4321 payload: object status: "open" previous_status: "open" voltage: 3.075 voltage_level: "high" time: 1552122874731 device: "zolder" _msgid: "91d79223.8e3b1" 09/03/2019, 10:14:36node: 8e1326ed.b5dbe8

msg : Object object fromip: "192.168.1.208:4321" ip: "192.168.1.208" port: 4321 payload: object status: "close" previous_status: "open" voltage: 3.075 voltage_level: "high" time: 1552122875958 device: "zolder" _msgid: "bc912d15.72d89"

igdr commented 5 years ago
  1. the first one is OPEN
  2. it is heartbeat with battery level and status isn't changed it is still OPEN
  3. CLOSE
GoSpursGoNL commented 5 years ago

@realjax What you can do in NR is use a change node to move the status element to the payload and then a RBE-node afterwards to only handle messages with real status changes so you filter out that heartbeat message. I'll stick to HA, but thanks for your efforts @igdr

igdr commented 5 years ago

Also, I can actually skip heartbeat messages - just update voltage and do not pass the message to the node output

realjax commented 5 years ago

Hi. Thanks for the info. AFAIC I think it is fine the way it is. They are actual and valid messages being sent so it is up the user to handle them. I was just wonderin about the third message. Ive found it to be pretty difficult getting any info on the net about what messages are being sent by the gateway and messages you can send to it.

igdr commented 5 years ago

Close issue cause no activity