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
17 stars 7 forks source link

Model list empty #16

Closed calania closed 1 year ago

calania commented 1 year ago

Hello! I have an air purifier 2s that I would want to control through node red but have sadly run into some issues adding the device using this node. I have selected the device type "air purifier" and inputted the correct ip and token but when I press the refresh button the model list is completely empty.

I tried adding the device to home assistant to make sure that the token was correct and there it worked without issues.

I also tried downloading the def file "zhimi.airpurifier.mc1.js" and placed it in the following directory "/home/pi/.node-red/node_modules/node-mihome/lib/devices" and even after rebooting the raspberry pi it is still not shown in the list. Any ideas why it might not be working?

stason325 commented 1 year ago

Hello! I have an air purifier 2s that I would want to control through node red but have sadly run into some issues adding the device using this node. I have selected the device type "air purifier" and inputted the correct ip and token but when I press the refresh button the model list is completely empty.

I tried adding the device to home assistant to make sure that the token was correct and there it worked without issues.

I also tried downloading the def file "zhimi.airpurifier.mc1.js" and placed it in the following directory "/home/pi/.node-red/node_modules/node-mihome/lib/devices" and even after rebooting the raspberry pi it is still not shown in the list. Any ideas why it might not be working?

Hello there. No ideas at the moment, unfortunately🤷‍♂️ ... maybe your NR works as a companion in HA and the whole issue is somewhere there. I've heard that combination could work unstable quite often

calania commented 1 year ago

I don't even run home assistant on the same pi so I doubt that it's home assistant causing the issue. Does your node have a logging function? Maybe the log could show what the problem is?

Edit: Also if I understand correctly, it doesn't matter what I type in the MI_id right? I currently just have it as "12345"

stason325 commented 1 year ago

I don't even run home assistant on the same pi so I doubt that it's home assistant causing the issue. Does your node have a logging function? Maybe the log could show what the problem is?

Edit: Also if I understand correctly, it doesn't matter what I type in the MI_id right? I currently just have it as "12345"

Hi, logs can be seen in debug node in NR (all possible errors are thrown as messages). But here ... I don't see any event to log here. What can suppose here: if you've got a clear NR on your PI, then the problem is somewhere else. List of devices is located in devtypesLib.js, but your config-node strangely does not see it. Try to delete and re-install the whole package once again. don't forget to reboot NR after that.

As for MI_id: you are correct type any big number you want. It is critical, that these ids are different for different devices.

calania commented 1 year ago

Hello thanks for the reply. I just managed to solve it. I missed that you had to close the node by pressing done after inputting the ip, token and device type. I just tried pressing the refresh button directly after inputting all the details.

It seems to be working fine now but I am not entirely sure what the msg.payload should contain to switch between the different modes. When I send "auto" to the mode node I get an error saying "auto is not defined". Do you know what I should send it?

stason325 commented 1 year ago

For commands follow the devices.md table.

And don't forget to copy-paste defFile if needed (in your case it is needed I suppose). it's written in read how to do it.

calania commented 1 year ago

I looked in the device.md and have copied the def file but I still get a "not defined" error. It only seems to be the mode that is not working, turning it on/off works fine. This is my very basic setup. Do you see anything wrong with it?

[ { "id": "364bda157a30e951", "type": "MIIOsendcommand", "z": "a93551d4.0ad2e8", "name": "", "devices": "hidden", "command": "Mode", "command_state": "payload", "x": 490, "y": 2420, "wires": [ [] ] }, { "id": "331ade2a632d7e40", "type": "change", "z": "a93551d4.0ad2e8", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "auto", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 320, "y": 2420, "wires": [ [ "364bda157a30e951" ] ] }, { "id": "b9ba463bf8a6f4a1", "type": "inject", "z": "a93551d4.0ad2e8", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 160, "y": 2420, "wires": [ [ "331ade2a632d7e40" ] ] }, { "id": "hidden", "type": "MIIOdevices", "name": "Air-purifer", "room": "", "MI_id": "123", "device_type": "purif", "model": "zhimi.airpurifier.mc1", "address": "192.168.0.201", "token": "hidden", "isMIOT": false, "username": "", "password": "", "isPolling": true, "pollinginterval": "30" } ]

stason325 commented 1 year ago

Try 0,1 or 2 instead of string "auto", "sleep" or "favourite"

stason325 commented 1 year ago

If it works, then I will update description in devices.md and the defFile for your device in next version of my nodes

calania commented 1 year ago

I tried that (both as a string and as a number) but then get an " invaild_arg" error. I can add that it does however report the current_mode as "auto", "sleep" etc.

stason325 commented 1 year ago

I tried that (both as a string and as a number) but then get an " invaild_arg" error. I can add that it does however report the current_mode as "auto", "sleep" etc.

could you please show here debug msg on that.

According to Xiaomi specs 0,1,2 or "auto", "sleep", "favorite" should work https://home.miot-spec.com/spec/zhimi.airpurifier.mc1

calania commented 1 year ago

When I send 0,1 or 2 (I tried both as a string and as a number) the debug node says

"Mihome Exception. IP: 192.168.0.201 -> invaild_arg"

When I send auto, sleep or favorite it first says "command sent" under the SendCommand node but nothing happens on my purifer. If I however try sending the same mode again I get an error saying

"Mihome Exception. IP: 192.168.0.201 -> favorite is not defined"

stason325 commented 1 year ago

When I send 0,1 or 2 (I tried both as a string and as a number) the debug node says

"Mihome Exception. IP: 192.168.0.201 -> invaild_arg"

When I send auto, sleep or favorite it first says "command sent" under the SendCommand node but nothing happens on my purifer. If I however try sending the same mode again I get an error saying

"Mihome Exception. IP: 192.168.0.201 -> favorite is not defined"

Maybe you should identify favourite level first through "Favorite Level" set-node, and only then turn this mode on

calania commented 1 year ago

Can try but I get the exact same message when I send auto and sleep to it. For example when sending auto I get

"Mihome Exception. IP: 192.168.0.201 -> auto is not defined"

stason325 commented 1 year ago

Can try but I get the exact same message when I send auto and sleep to it. For example when sending auto I get

"Mihome Exception. IP: 192.168.0.201 -> auto is not defined"

"Not defined" answer means that function works on the device, but the device doesn't understand the value you push to it.

Everything I can advice you here is keep searching for right spelling of the values. I don't have this device so I can hardly help you here...🤷‍♂️

... in miot-specs values should start with capital letters: you can try this for example

stason325 commented 1 year ago

@calania hi. Any progress in your findings?😊

calania commented 1 year ago

Sorry for not answering. Been a busy few days. I actually sort of made some progress. I found another script (using the python library python-miio) that I was able to control my air purifiers mode with. I however looked through the source code for it and the library and it seems to be sending the exact same commands as your node (auto, favorite etc) so I don't know why I couldn't get your node working. I assume it's an error I am making since it's the exact same string. This is the script I got working if you wonder https://github.com/kofec/domoticz-AirPurifier/blob/master/MyAir.py

I'm closing this issue since I'm able to control it with the other script and since it's most likely an issue due to me misconfiguering the node rather than a bug