stason325 / node-red-contrib-miio-localdevices

Nodes for controlling MIIO devices via node-mihome lib. List of devices and commands to be extended.
GNU General Public License v3.0
18 stars 7 forks source link

Method GET #13

Closed ONyklicek closed 2 years ago

ONyklicek commented 2 years ago

Is there a problem with the GET method? I'm trying to figure out how to get it working. Retrieving the current status would be very helpful.

stason325 commented 2 years ago

Is there a problem with the GET method?

I'm trying to figure out how to get it working.

Retrieving the current status would be very helpful.

Hello. Actually I don't use separate GET-commands in my nodes. I prefer to poll the device for the whole json of properties via get_prop (for miio) or get_properties (for miot) command. That's why I've deleted get-part in defFile.

The logic is like: want to get properties - use get-node and get full json, want to execute command - use command-node and specify the exact command or send custom json with list of commands.

Regards

ONyklicek commented 2 years ago

Would it be possible to get a preview of the node?

stason325 commented 2 years ago

Would it be possible to get a preview of the node?

What do you mean? I've already released 0.5.11 - you can look it through if you like. Concerning whole get-logic that I previously explained it is in place starting from very early releases.

Regards

ONyklicek commented 2 years ago

Sorry. I'm not sure exactly how to make it work. The commands have gone, but I don't know how to get the current status.

stason325 commented 2 years ago

Sorry. I'm not sure exactly how to make it work. The commands have gone, but I don't know how to get the current status.

Poll the device using get-node. And turn on autopolling option to get changes in properties each time they have changed

ONyklicek commented 2 years ago

Sorry. I'm not sure exactly how to make it work. The commands have gone, but I don't know how to get the current status.

Poll the device using get-node. And turn on autopolling option to get changes in properties each time they have changed

I have autopolling turned on, but it doesn't return anything.

{ "polling":"ON. Every 30 sec", "name":"Xiaom AirPurifier 4 Pro - ", "address":"192.168.1.103", "model":"zhimi.airp.vb4", "payload":{}, "_msgid":"117fed2dfd4a0063" }

My test code

`[ { "id": "b0463420f27feeea", "type": "debug", "z": "f6f2187d.f17ca8", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 485, "y": 100, "wires": [], "l": false }, { "id": "860ffc5fd40ede2b", "type": "MIIOgetdata", "z": "f6f2187d.f17ca8", "devices": "49643805fbf61247", "prop_type": "MiProtocol", "x": 170, "y": 100, "wires": [ [ "b0463420f27feeea" ] ] }, { "id": "2fc384d3ca9ed557", "type": "MIIOsendcommand", "z": "f6f2187d.f17ca8", "name": "", "devices": "49643805fbf61247", "command": "Power", "command_state": "payload", "x": 360, "y": 180, "wires": [ [ "98a934df0ef515cc" ] ] }, { "id": "a9774253ec3f8586", "type": "MIIOsendcommand", "z": "f6f2187d.f17ca8", "name": "", "devices": "49643805fbf61247", "command": "Mode", "command_state": "payload", "x": 360, "y": 320, "wires": [ [ "b1a523cd201762f9" ] ] }, { "id": "c1c810db43b1d7d0", "type": "MIIOsendcommand", "z": "f6f2187d.f17ca8", "name": "", "devices": "49643805fbf61247", "command": "LcdBrightness", "command_state": "payload", "x": 390, "y": 580, "wires": [ [ "7f9cb081e327302f" ] ] }, { "id": "48b20bc23d54d207", "type": "MIIOsendcommand", "z": "f6f2187d.f17ca8", "name": "", "devices": "49643805fbf61247", "command": "Buzzer", "command_state": "payload", "x": 360, "y": 460, "wires": [ [ "6a4f089c3b3c5204" ] ] }, { "id": "98a934df0ef515cc", "type": "debug", "z": "f6f2187d.f17ca8", "name": "debug 1", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 530, "y": 180, "wires": [] }, { "id": "80dc57deebdd0cde", "type": "inject", "z": "f6f2187d.f17ca8", "name": "ON", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "true", "payloadType": "bool", "x": 180, "y": 160, "wires": [ [ "2fc384d3ca9ed557" ] ] }, { "id": "1e8e1a93cea388ce", "type": "inject", "z": "f6f2187d.f17ca8", "name": "OFF", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "false", "payloadType": "bool", "x": 180, "y": 200, "wires": [ [ "2fc384d3ca9ed557" ] ] }, { "id": "cc3a33af5a0e95a5", "type": "inject", "z": "f6f2187d.f17ca8", "name": "Sleep", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "1", "payloadType": "num", "x": 180, "y": 300, "wires": [ [ "a9774253ec3f8586" ] ] }, { "id": "d2211d712a685589", "type": "inject", "z": "f6f2187d.f17ca8", "name": "Auto", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "0", "payloadType": "num", "x": 180, "y": 260, "wires": [ [ "a9774253ec3f8586" ] ] }, { "id": "37c5ecc466ef4a8c", "type": "inject", "z": "f6f2187d.f17ca8", "name": "Favorite", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "2", "payloadType": "num", "x": 180, "y": 340, "wires": [ [ "a9774253ec3f8586" ] ] }, { "id": "28c3217434bb05fd", "type": "inject", "z": "f6f2187d.f17ca8", "name": "Manual", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "3", "payloadType": "num", "x": 180, "y": 380, "wires": [ [ "a9774253ec3f8586" ] ] }, { "id": "b1a523cd201762f9", "type": "debug", "z": "f6f2187d.f17ca8", "name": "debug 2", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 530, "y": 320, "wires": [] }, { "id": "770dedb15c79f08e", "type": "inject", "z": "f6f2187d.f17ca8", "name": "ON", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "true", "payloadType": "bool", "x": 180, "y": 440, "wires": [ [ "48b20bc23d54d207" ] ] }, { "id": "41e9a196f486b522", "type": "inject", "z": "f6f2187d.f17ca8", "name": "OFF", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "false", "payloadType": "bool", "x": 180, "y": 480, "wires": [ [ "48b20bc23d54d207" ] ] }, { "id": "6a4f089c3b3c5204", "type": "debug", "z": "f6f2187d.f17ca8", "name": "debug 3", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 530, "y": 460, "wires": [] }, { "id": "9e05e30507ba0d2e", "type": "inject", "z": "f6f2187d.f17ca8", "name": "1", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "1", "payloadType": "num", "x": 180, "y": 580, "wires": [ [ "c1c810db43b1d7d0" ] ] }, { "id": "ca19454a4afce63d", "type": "inject", "z": "f6f2187d.f17ca8", "name": "0", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "0", "payloadType": "num", "x": 180, "y": 540, "wires": [ [ "c1c810db43b1d7d0" ] ] }, { "id": "9314333a8b258b78", "type": "inject", "z": "f6f2187d.f17ca8", "name": "2", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "2", "payloadType": "num", "x": 180, "y": 620, "wires": [ [ "c1c810db43b1d7d0" ] ] }, { "id": "7f9cb081e327302f", "type": "debug", "z": "f6f2187d.f17ca8", "name": "debug 4", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 590, "y": 580, "wires": [] }, { "id": "7e56e164c0545ad0", "type": "MIIOsendcommand", "z": "f6f2187d.f17ca8", "name": "", "devices": "49643805fbf61247", "command": "ChildLock", "command_state": "payload", "x": 370, "y": 700, "wires": [ [ "7792cc2ec00cca48" ] ] }, { "id": "2a146427ffd2786e", "type": "inject", "z": "f6f2187d.f17ca8", "name": "ON", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "true", "payloadType": "bool", "x": 180, "y": 680, "wires": [ [ "7e56e164c0545ad0" ] ] }, { "id": "0e6ac6905fd1ad29", "type": "inject", "z": "f6f2187d.f17ca8", "name": "OFF", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "false", "payloadType": "bool", "x": 180, "y": 720, "wires": [ [ "7e56e164c0545ad0" ] ] }, { "id": "7792cc2ec00cca48", "type": "debug", "z": "f6f2187d.f17ca8", "name": "debug 5", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 550, "y": 700, "wires": [] }, { "id": "780033dee2349644", "type": "MIIOsendcommand", "z": "f6f2187d.f17ca8", "name": "", "devices": "49643805fbf61247", "command": "FanLevel", "command_state": "payload", "x": 370, "y": 820, "wires": [ [ "e16fd657931796ee" ] ] }, { "id": "a17492cd7276c53d", "type": "inject", "z": "f6f2187d.f17ca8", "name": "1", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "1", "payloadType": "num", "x": 180, "y": 780, "wires": [ [ "780033dee2349644" ] ] }, { "id": "f5146e0e16bcd660", "type": "inject", "z": "f6f2187d.f17ca8", "name": "3", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "3", "payloadType": "num", "x": 180, "y": 860, "wires": [ [ "780033dee2349644" ] ] }, { "id": "a631c82b97c6a47a", "type": "inject", "z": "f6f2187d.f17ca8", "name": "2", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "2", "payloadType": "num", "x": 180, "y": 820, "wires": [ [ "780033dee2349644" ] ] }, { "id": "e16fd657931796ee", "type": "debug", "z": "f6f2187d.f17ca8", "name": "debug 6", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 550, "y": 820, "wires": [] }, { "id": "1de5ed6a0532a279", "type": "MIIOsendcommand", "z": "f6f2187d.f17ca8", "name": "", "devices": "49643805fbf61247", "command": "FavLevel", "command_state": "payload", "x": 450, "y": 1120, "wires": [ [ "fb6e66ba312071bb" ] ] }, { "id": "ebb31ee91aef193e", "type": "inject", "z": "f6f2187d.f17ca8", "name": "1", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "1", "payloadType": "num", "x": 180, "y": 920, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "c6834f31ce6ee323", "type": "inject", "z": "f6f2187d.f17ca8", "name": "3", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "3", "payloadType": "num", "x": 180, "y": 1000, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "a59937c781d462b5", "type": "inject", "z": "f6f2187d.f17ca8", "name": "2", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "2", "payloadType": "num", "x": 180, "y": 960, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "4db1ea12a3554135", "type": "inject", "z": "f6f2187d.f17ca8", "name": "4", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "4", "payloadType": "num", "x": 180, "y": 1040, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "361158b973c2510a", "type": "inject", "z": "f6f2187d.f17ca8", "name": "6", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "6", "payloadType": "num", "x": 180, "y": 1120, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "ecb6c987dd3098aa", "type": "inject", "z": "f6f2187d.f17ca8", "name": "5", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "5", "payloadType": "num", "x": 180, "y": 1080, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "9be3a74af02fb9d7", "type": "inject", "z": "f6f2187d.f17ca8", "name": "7", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "7", "payloadType": "num", "x": 180, "y": 1160, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "5fc0a4629166f1ef", "type": "inject", "z": "f6f2187d.f17ca8", "name": "9", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "9", "payloadType": "num", "x": 180, "y": 1240, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "b3662b2515373961", "type": "inject", "z": "f6f2187d.f17ca8", "name": "8", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "8", "payloadType": "num", "x": 180, "y": 1200, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "41cadb2dd9b0d9c6", "type": "inject", "z": "f6f2187d.f17ca8", "name": "10", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "10", "payloadType": "num", "x": 180, "y": 1280, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "4bf1326e4c8d79f3", "type": "inject", "z": "f6f2187d.f17ca8", "name": "11", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "11", "payloadType": "num", "x": 180, "y": 1320, "wires": [ [ "62d2a9bb93265007" ] ] }, { "id": "fb6e66ba312071bb", "type": "debug", "z": "f6f2187d.f17ca8", "name": "debug 7", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 630, "y": 1120, "wires": [] }, { "id": "62d2a9bb93265007", "type": "junction", "z": "f6f2187d.f17ca8", "x": 350, "y": 1120, "wires": [ [ "1de5ed6a0532a279" ] ] }, { "id": "49643805fbf61247", "type": "MIIOdevices", "name": "Xiaom AirPurifier 4 Pro", "room": "", "MI_id": "Xiaomi AirPurifier 4 Pro", "device_type": "purif", "model": "zhimi.airp.vb4", "address": "192.168.1.103", "token": "711ade8ef10", "isMIOT": false,

    "isPolling": true,
    "pollinginterval": "30"
}

]`

stason325 commented 2 years ago

Empty payload... I'm confused a bit. Do the commands work properly?

By the way, I looked through different integrations of that device and everything looks ok in defFile. At list the same as in python-miio:

https://python-miio.readthedocs.io/en/latest/_modules/miio/integrations/airpurifier/zhimi/airpurifier_miot.html

stason325 commented 2 years ago

And to be sure: did you update nodes to version 0.5.11 and paste new defFile from the latest version to target folder?

ONyklicek commented 2 years ago

Yes, I have version 0.5.11 installed. I also had to add zhimi.airp.vb4.js to node-mihome to make the node work. Now all sent commands work, but do not return data about the current state. This data is important to me because of the homekit.

stason325 commented 2 years ago

Yes, I have version 0.5.11 installed. I also had to add zhimi.airp.vb4.js to node-mihome to make the node work. Now all sent commands work, but do not return data about the current state. This data is important to me because of the homekit.

Anything changes in msg.payload from get-node if you turn off friendly name option and delete your mihome credentials?

ONyklicek commented 2 years ago

Yes, I have version 0.5.11 installed. I also had to add zhimi.airp.vb4.js to node-mihome to make the node work. Now all sent commands work, but do not return data about the current state. This data is important to me because of the homekit.

Anything changes in msg.payload from get-node if you turn off friendly name option and delete your mihome credentials?

Prop type set to MiProtocol. Cloud Auth turned off and data deleted.

Returning

{"polling":"ON. Every 30 sec","name":"Xiaom AirPurifier 4 Pro - ","address":"192.168.1.103","model":"zhimi.airp.vb4","payload":{},"_msgid":"aedef611d4c5b885"}

stason325 commented 2 years ago

Very strange

Yes, I have version 0.5.11 installed. I also had to add zhimi.airp.vb4.js to node-mihome to make the node work. Now all sent commands work, but do not return data about the current state. This data is important to me because of the homekit.

Anything changes in msg.payload from get-node if you turn off friendly name option and delete your mihome credentials?

Prop type set to MiProtocol. Cloud Auth turned off and data deleted.

Returning

{"polling":"ON. Every 30 sec","name":"Xiaom AirPurifier 4 Pro - ","address":"192.168.1.103","model":"zhimi.airp.vb4","payload":{},"_msgid":"aedef611d4c5b885"}

very strange. When saw pull request from you, I thought that you had tested your device

Anyway, let's try to adjust defFile a bit. In constructor section: 1) add this._miotSpecType = 'urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-vb4:2' 2) comment this._miotSpec = {...}

Then save updated defFile, reboot NR and come back with the result

ONyklicek commented 2 years ago

very strange. When saw pull request from you, I thought that you had tested your device

Anyway, let's try to adjust defFile a bit. In constructor section:

  1. add this._miotSpecType = 'urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-vb4:2'
  2. comment this._miotSpec = {...}

Then save updated defFile, reboot NR and come back with the result

Tried and failed.

I tried to rebuild according to zhimi.airpurifier.vb2 and also failed.

stason325 commented 2 years ago

very strange. When saw pull request from you, I thought that you had tested your device Anyway, let's try to adjust defFile a bit. In constructor section:

  1. add this._miotSpecType = 'urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-vb4:2'
  2. comment this._miotSpec = {...}

Then save updated defFile, reboot NR and come back with the result

Tried and failed.

I tried to rebuild according to zhimi.airpurifier.vb2 and also failed.

Did I understand you correct: empty msg.payload from get-node either on init or on change after any commands?

What I see from that test: it doesn't matter from where to get the list of properties - from miot server using "this._miotSpecType = 'urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-vb4:2'" or from local array in defFile using " this._miotSpec = {...}"

Then you can come back to defFile from v.0.5.11 with _miotSpec array and without _miotSpecType.

There possibly could be several reasons: 1) something wrong with connection/credentials 2) spelling of properties is wrong

Second reason is not in place here, because you can set the value of that properties through command-node... by why the device doesn't answer with current value...unclear at the moment.

Let's try this: 1) reboot the purifier (unplug from the socket for some time) => after that recheck credentials (update token if needed) 2) shorten the list of properties in defFile for a while (maybe some of them violate polling across the entire array of properties) this._propertiesToMonitor = [ "air-purifier:on", "air-purifier:fault", "air-purifier:mode", "air-purifier:fan-level", "air-purifier:anion" ] Let's start with that

Then save => reboot NR => come back with the result (msg.payload from get-node

ONyklicek commented 2 years ago

Amazing, now it's working. Thank you very much for your help.

I will debug the code and send.

stason325 commented 2 years ago

Amazing, now it's working. Thank you very much for your help.

I will debug the code and send.

Great!

But I still hope that it was connection issue and we could come back to larger list of properties to monitor (consider me a perfectionist) :)

Let's try all the properties except some not needed I hope. Try to put this list to defFile:

this._miotSpec = { "air-purifier:on": {"siid":2,"piid":1}, "air-purifier:fault": {"siid":2,"piid":2}, "air-purifier:mode": {"siid":2,"piid":4}, "air-purifier:fan-level": {"siid":2,"piid":5}, "air-purifier:anion": {"siid":2,"piid":6}, "environment:relative-humidity": {"siid":3,"piid":1}, "environment:pm2.5-density": {"siid":3,"piid":4}, "environment:temperature": {"siid":3,"piid":7}, "environment:pm10-density": {"siid":3,"piid":8}, "filter:filter-life-level": {"siid":4,"piid":1}, "filter:filter-used-time": {"siid":4,"piid":3}, "filter:filter-left-time": {"siid":4,"piid":4}, "alarm:alarm": {"siid":6,"piid":1}, "physical-controls-locked:physical-controls-locked": {"siid":8,"piid":1}, "screen:brightness": {"siid":13,"piid":2}, "custom-service:moto-speed-rpm": {"siid":9,"piid":1}, "custom-service:favorite-speed": {"siid":9,"piid":2}, "custom-service:motor-set-speed": {"siid":9,"piid":4}, "custom-service:favorite-level": {"siid":9,"piid":5}, "aqi:average-aqi": {"siid":11,"piid":2} };

this._propertiesToMonitor = [ "air-purifier:on", "air-purifier:fault", "air-purifier:mode", "air-purifier:fan-level", "air-purifier:anion", "environment:relative-humidity", "environment:pm2.5-density", "environment:temperature", "environment:pm10-density", "filter:filter-life-level", "filter:filter-used-time", "filter:filter-left-time", "alarm:alarm", "physical-controls-locked:physical-controls-locked", "screen:brightness", "custom-service:moto-speed-rpm", "custom-service:favorite-speed", "custom-service:motor-set-speed", "custom-service:favorite-level", "aqi:average-aqi" ];

ONyklicek commented 2 years ago

Could it be related to this?

(node:326) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 properties listeners added to [Xiaomi Smart Air Purifier 4 Pro]. Use emitter.setMaxListeners() to increase limit

stason325 commented 2 years ago

Could it be related to this?

(node:326) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 properties listeners added to [Xiaomi Smart Air Purifier 4 Pro]. Use emitter.setMaxListeners() to increase limit

no idea(

ONyklicek commented 2 years ago

Verified. It returns only 11 values.

stason325 commented 2 years ago

Verified. It returns only 11 values.

image

That's how ca4 humidifier returns 15 values

stason325 commented 2 years ago

Verified. It returns only 11 values.

Maybe this is limitation of exact device?

ONyklicek commented 2 years ago

After much testing I managed to get these features working.

After adding environment:air-quality and custom-service:buttom-door, return is empty.

      "air-purifier:on",
      "air-purifier:mode",
      "air-purifier:fan-level",
      "environment:relative-humidity",
      "environment:pm2.5-density",
      "environment:temperature",
      "environment:pm10-density",
      "filter:filter-life-level",
      "filter:filter-left-time",
      "alarm:alarm",
      "physical-controls-locked:physical-controls-locked",
      "custom-service:moto-speed-rpm",
      "aqi:average-aqi"
stason325 commented 2 years ago

After much testing I managed to get these features working.

After adding environment:air-quality and custom-service:buttom-door, return is empty.


      "air-purifier:on",

      "air-purifier:mode",

      "air-purifier:fan-level",

      "environment:relative-humidity",

      "environment:pm2.5-density",

      "environment:temperature",

      "environment:pm10-density",

      "filter:filter-life-level",

      "filter:filter-left-time",

      "alarm:alarm",

      "physical-controls-locked:physical-controls-locked",

      "custom-service:moto-speed-rpm",

      "aqi:average-aqi"

Thank you so much for your tests👍🏻 I will update defFile according to this.

Moreover, I will add setMaxListeners(100) in devices.js to eliminate limitation in event emitter. (See this: https://nodejs.org/api/events.html#emittersetmaxlistenersn )

I'll try to release 0.5.12 with all these updates in place tomorrow.

ONyklicek commented 2 years ago

I tested again today. These values work and return.

      "air-purifier:on",
      "air-purifier:fault",
      "air-purifier:mode",
      "air-purifier:fan-level",
      "air-purifier:anion",
      "environment:relative-humidity",
      "environment:pm2.5-density",
      "environment:temperature",
      "environment:pm10-density",
      "filter:filter-life-level",
      "filter:filter-used-time",
      "filter:filter-left-time",
      "alarm:alarm",
      "physical-controls-locked:physical-controls-locked",
      "custom-service:moto-speed-rpm",
      "custom-service:favorite-speed",
      "custom-service:motor-set-speed",
      "custom-service:favorite-level",
      "custom-service:buttom-door",
      "custom-service:manual-level",
      "aqi:purify_volume",
      "aqi:average_aqi",
      "aqi:aqi-state",
      "screen:brightness",
      "device-display-unit:temperature-display-unit",

The source code refers to a limit of 15 properties.

values = self.get_properties(properties, max_properties=15)

In documentation python-miio has this function for a complete listing.

 get_properties(properties, *, property_getter='get_prop', max_properties=None)
Request properties in slices based on given max_properties.

This is necessary as some devices have limitation on how many properties can be queried at once.

If max_properties is None, all properties are requested at once.

It would be good to include node-mihome directly in the code and get rid of the dependency. It will simplify development and modifications. Now I have to edit the node-mihome code as well.

stason325 commented 2 years ago

The source code refers to a limit of 15 properties.

`

values = self.get_properties(properties, max_properties=15)

`

Could you give reference on that? I didn't find this in node-mihome code.

stason325 commented 2 years ago

It would be good to include node-mihome directly in the code and get rid of the dependency. It will simplify development and modifications. Now I have to edit the node-mihome code as well.

I though about that, but came to a conclusion that it's against the general idea of my plugin: the idea was to make an implementation of the lib and protocol in NodeRed, but not rewriting the lib.

Maintaining lib + plug-in will take much more time and effort. Unfortunately I cannot afford that.

Moreover, 99% of users do not face the limitations that node-mihome lib has. In that particular case 15 properties is more than enough for HomeKit, Yandex etc.

Regards

ONyklicek commented 2 years ago

I understand. Node-mihome lib hasn't received an update in 2 years. I'm toying with the idea of sequentially calling get_properties to get all values.

stason325 commented 2 years ago

After much testing I managed to get these features working. After adding environment:air-quality and custom-service:buttom-door, return is empty.


      "air-purifier:on",

      "air-purifier:mode",

      "air-purifier:fan-level",

      "environment:relative-humidity",

      "environment:pm2.5-density",

      "environment:temperature",

      "environment:pm10-density",

      "filter:filter-life-level",

      "filter:filter-left-time",

      "alarm:alarm",

      "physical-controls-locked:physical-controls-locked",

      "custom-service:moto-speed-rpm",

      "aqi:average-aqi"

Thank you so much for your tests👍🏻 I will update defFile according to this.

Moreover, I will add setMaxListeners(100) in devices.js to eliminate limitation in event emitter. (See this: https://nodejs.org/api/events.html#emittersetmaxlistenersn )

I'll try to release 0.5.12 with all these updates in place tomorrow.

Updated and released.