acc-ua / homebridge-xiaomi-humidifier

Xiaomi Humidifier plugin for HomeBridge.
8 stars 9 forks source link

Act as humidifier #8

Open fenway062213 opened 6 years ago

fenway062213 commented 6 years ago

Anyone know of a way to get it to act as a humidifier instead of a fan now that Homekit supports humidifiers?

leoneleone commented 6 years ago

Now that the plugin has been updated, what do I put in the config file as ‘type’ to get the Humidifier Service? type: “Fan” for Fan Service Type: ?? For Humidifier Service

??

fenway062213 commented 6 years ago

I have no idea...I was hoping someone else would know actually!

boganov commented 6 years ago

"type" is optional, "Fan" value means that device will be displayed as Fan device, otherwise - as Humidifier/Dehumidifier device (iOS 11 and above)

So you don't have to type anything. It worked for me but humidifier is pretty buggy and not very useful right now in my opinion. I can see only "set to" without number so I don't know what is actual speed in Home app until I tap on device. I moved back to fan.

fenway062213 commented 6 years ago

@boganov where does this go? I don’t have anything in either the main Homebridge config or the humidifier config that says “type” for the humidifier...

fenway062213 commented 6 years ago

@boganov Never mind, figured it out. I didn’t realize the plugin had been updated. Now my issue is that the new update won’t work - I keep getting the “typeerror miio.device is not a constructor” error message. I rolled back to 0.14.1 and that seems to have fixed it, although the device type is still a fan. I already have another fan in the same room so I’d prefer this to display as a humidifier. So, you have the newest update working? How may I ask did you do that?

leoneleone commented 6 years ago

@boganov Try my recent Pull Request. I'm attempting to fix the Humidifier Service functionality in the Home.app

Please try it and let me know if functionality has improved when using the Home app

boganov commented 6 years ago

@fenway062213 Yep, seems like miio also updates with this plugin, had the same issue. Well, I'm not sure what to do in your case. I simply switch between fan and humidifier with type:"Fan" line in config and it works for me now. Probably deleting cachedAccessories may help, the file is in .homebridge/accessories folder. Don't know where is it in Linux since I use Windows machine as homebridge server. Warning: If you have many devices in homebridge (especially from aqara) this may force you to setup everything again, but maybe this is only Windows or simply my newbie problem and in your case everything will be fine.

boganov commented 6 years ago

@leoneleone Tried your commit, not much changed for me, only "set to" changed to "rising to". I can't see current value: img_2dc27269c728-1 But I never had real homekit humidifier, so maybe this is how it should be...

Edit: Oops, "Set to" is for Auto mode, "Rising to" is for Humidify mode. So nothing really changed in this. Probably it is working better and as it should but I prefer to see what current speed is, so will return to Fan right now.

fenway062213 commented 6 years ago

@boganov Thanks for your help...for some reason I just can’t get past getting the new update installed. I keep getting the same “not a constructor” error message and having to roll back to the older version. I’m running Homebridge on a Mac with High Sierra. You’re using Windows, right? Maybe it’s a Mac specific problem...

leoneleone commented 6 years ago

@fenway062213 Downgrade miio version to fix your ‘not a constructor’ problem

fenway062213 commented 6 years ago

@leoneleone that’s what I ended up doing...I’d like to be able to update the plugin though, since I’d prefer my humidifier to act as a humidifier in the app and not a fan...for now I’m back on 0.14.1.

leoneleone commented 6 years ago

@fenway062213 You need remove (type) from your config file I believe.

@boganov All I did was use the correct Characteristics for the Humidifier according to the HomeKit Protocol. Unfortunately, since the humidifier can only be set to low, medium, and high (the target humidity of which is actually set on the humidifier unit itself via the Mi app), the Fan Speed percentage in the Home.app wouldn’t really be respresentative of the actual humidity setting on the humidifier itself. In any case, the lack of a graphical readout is dictated by ’s design of the Home.app. We could link the added Target Humidity characteristic to the Fan Speed, but I think that would ultimately get confusing. If you want to set the target humidity precisely, try using a Siri command like “Set the target humidity on my humidifier to xx “ Alternatively to see a readout, maybe use another HomeKit app like Eve.app

fenway062213 commented 6 years ago

@leoneleone I did do that...unfortunately, since the latest update isn’t working for me, I had to revert back to 0.14.1, where it won’t display as a humidifier either way, right? Just wanted to make sure I wasn’t missing anything...

leoneleone commented 6 years ago

@fenway062213 The miio version (0.14.1) makes little difference. If you want the device to appear as a Humidifier in the Home.app:

  1. Go to your config.json file for your homebridge setup.
  2. In the section where you entered the plugin’s details, delete the line - “type” : “fan” - (make sure to delete the comma (,) at the end of the line just above the (type: Fan) line you deleted in step 1
  3. Restart homebridge

@boganov If I am mistaken about the steps above, please feel free to chip in with instructions on how you got it working as a Humidifier on your homebridge setup😊

boganov commented 6 years ago

Yep, I have exactly the same config for this platform as tutorial says, nothing special. If I remove "type": "Fan" it acts as humidifier but since I don't like it I keep using it as a fan.

leoneleone commented 6 years ago

@boganov The only other thing I can do is submit a bug report/request to  indicating they should add TargetHumidity settings to the Humidifier device UI in the Home.app (It makes sense to do so). Feedback does help in my opinion. Feel free to submit your feedback to  about your experience when using a humidifier device in the Home.app

@fenway062213 Please close this issue once you are satisfied 😊

fenway062213 commented 6 years ago

@leoneleone thanks again for the help with this. I just want to make sure I’m getting this right. So, running 0.14.1, this is what my Homebridge config looks like for the humidifier: 003642ca-e63e-420e-971c-c2fbe1047cbd

There is no “type” section, and yet the device is still showing as a fan...am I missing something obvious? (Sorry if I am...)

leoneleone commented 6 years ago

@fenway062213 Not really sure what’s happening there. Your config looks fine to me. It seems that homebridge didn’t “remove” the original Fan Accessory after the Humidifier change...? You could try deleting the Accessories folder under .homebridge (where your config.json file is). This will delete all HomeKit Accessory setups you’ve made for all Accessories in that homebridge instance. The Accessories will still spear in HomeKit, but you will have to setup room allocations and Automation allocation for those devices.

@boganov Have you experienced this when switching between types?

@acc-ua Maybe implementing “Remove Accessory” would rectify this Accessory cache issue?

boganov commented 6 years ago

@leoneleone no, not right now. I was making changes to other homebridge devices as well and deleted accessories/cachedAccessories file in the folder you are talking about. Maybe this helped but as I said earlier this can reset aqara devices if you have them.

leoneleone commented 6 years ago

@boganov Thanks

@fenway062213 Deleting the folder mentioned is probably your best solution.

@acc-ua Correct HAP “Remove Accessory” implantation is needed...

fenway062213 commented 6 years ago

@leoneleone thanks again for the help. I went ahead and did that, and the humidifier is still showing as a fan. I also tried deleting both the accessories and the persist folders, deleting Homebridge, and reinstalling, and again it’s displaying as a fan. Very strange...

Edited to add: I definitely feel like I’m missing a step here. So, the way it should work as i understand it, is that running 0.14.1, and not having the “type: fan” line included in the json, means that it should show up as a humidifier and not a fan. And no other steps are needed at all? I can see that you updated some files a few days ago. I haven’t touched those at all...is there anything I should be doing with them? Downloading and saving them somewhere on my computer?

Again, sorry if I’m being dense...

donatelloth commented 6 years ago

@fenway062213 i'm quite new in a theme of npm and other package managers. But may be the main problem that NPM still install old version of plugin? For me that was the problem. I just look into plugin directory and didn't find there new files from git. So i just copy files physically, restart homebridge and mi-humidifier started work as humidifier.

fenway062213 commented 6 years ago

Hi @donatelloth, thanks for chiming in!

Sorry, as you can probably see above I’m new to this stuff too...so when you say that you just copied the files physically, which files did you copy - from where, and to where?

Thanks again...

donatelloth commented 6 years ago

@fenway062213 for me these steps were the solution:

  1. download the repo https://github.com/acc-ua/homebridge-xiaomi-humidifier (green button in the top right corner)
  2. open the folder of the installed plugin (it should be here /usr/local/lib/node_modules or here /home/pi/.npm-global/lib/node_modules)
  3. copy all files inside of the repo to the plugin folder
  4. restart homebridge

May be this is the real direct and dumb approach but it helped for me

fenway062213 commented 6 years ago

@donatelloth That worked!! Thank you very much!! I feel so silly...I definitely downloaded the repo, and could have sworn I’d installed it, but apparently, I did not...

Such a minor thing but it was bugging the crap out of me, and it’s way better not having two “fans” int the same room. @boganov and @leoneleone, thanks as well for helping with this issue too.

fenway062213 commented 5 years ago

Hello again everyone...I'm back yet again and have the same exact problem. Long story short, I recently moved into a new home, and got a new Mac mini to act as my Homebridge server (among other things). I set it up from a Time Machine backup of my old Mac mini, so I could give that one to family. Seemed simple at first...

Somewhere along the way of getting Homebridge up and running, I'm encountering the same issue - my humidifier will only show up in the Home app as a fan. I've reread through this thread and tried following all the same steps again, but I think moving has turned my brain to mush. So, if you kind people could just bear with me one more time...

I have downloaded the repo from the link provided by @donatelloth above, and copied its contents into the humidifier folder in /usr/local/lib/node_modules. I'm running miio@0.14.2 and homebridge-xiaomi-humidifier@1.0.2. My Homebridge config.json has no "type" line, but I've also experienced with added a "type: humidifier" line, both to no avail. Whenever I add Homebridge to the Home app, the humidifier shows as a fan, which is super annoying since I already have a fan in the room that it's in...

So, I hate to bug you guys yet again, but am I missing something obvious again this time?? Again, the recent move has done me in...

Thank you, as always, for any help and suggestions you might have!

fenway062213 commented 5 years ago

Wanted to add that this is the error message I'm now getting...

/usr/local/lib/node_modules/miio/lib/createDevice.js:7 if(! options.address) throw new Error('Address to device is required'); ^

Error: Address to device is required at module.exports (/usr/local/lib/node_modules/miio/lib/createDevice.js:7:30) at Object.module.exports [as device] (/usr/local/lib/node_modules/miio/lib/connectToDevice.js:6:15) at new MiHumidifier2 (/usr/local/lib/node_modules/homebridge-xiaomi-humidifier/Devices/MiHumidifier2.js:17:10) at Object.accessories (/usr/local/lib/node_modules/homebridge-xiaomi-humidifier/index.js:87:21) at Server._loadPlatformAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:385:20) at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:329:16) at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:85:36) at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:43:10) at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:383:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:496:3

Edited to add that this error message occurs when I start up Homebridge after copying @donatelloth instructions above, exactly (ie, copying the files from the downloaded repo into the usr/local/lib/node_modules plugin folder). Those instructions worked before but now I'm getting this darn error message. I then go and sudo npm install -g homebridge-xiaomi-humidifier and the error message goes away, and Homebridge starts normally, but the device shows up as a fan.