-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Fan controllers #148
base: master
Are you sure you want to change the base?
Conversation
Added fan: SimpleFanAccessory (for fan only control) fanlight: SimpleFanLightAccessory (for fan controllers that also control a light)
Adjusted the code from SimpleHeaterAccessory.js Tested on Brilliant Wifi Ceiling Fan Controller. I initially only did the fan first, but then added in the light later. For me, controller can control the light, but I have not wired that functionality it in, as I already have Hue lighting installed and didn't want to stuff that up.
I forgot to add some other code changes I made to get this to work how I like it.
Add an entry called SPEED. /lib/node_modules/homebridge/node_modules/hap-nodejs/lib/gen/HomeKitTypes.js (around line 1696)
Change unit to SPEED. Be aware that any updates you do to homebridge will reset this back to default and you'll have to change it back again. |
Hi @murch1 Just wanted to say thanks very much for making this update. I incorporated the two new files and one changed file into my setup, and my Brilliant fan controller is working great in HomeKit! I haven’t changed the Characteristics.js just yet, but as a fan percentage control, it’s working really well. |
Hi again @murch1 Still using your update with my Brilliant controllers and its working perfectly. I’m wondering if there is any chance you could update it or give me some direction on how to get it working for these new Deta fan controllers: https://www.bunnings.com.au/deta-grid-connect-smart-fan-speed-controller-with-touch-light-switch_p0098815 I have my ID and Key, but using the updated files as-is gives a undefined response in the Homebridge logs. I’m assuming the schema must be different, but have no idea how to get the relevant schema or update your files to support it. I’d love to get these switches working, if you had any advice or could look into it, that’d be fantastic. Mark. |
Hi @stibbzy ,
I hope that helps. Good luck. |
Hi @murch1 I've actually made some progress with this. I now have it semi-working, and managed to get the new schema, which looks very similar to the Brilliant one: The issue is, I have the issue described here: iRayanKhan/homebridge-tuya#118 That is, if you try to set the fan speed, it always runs at 100%. I've figured out it is because the script, when setting characteristic.On, sets dp.Active to 1, after setting dp.RotationSpeed to whatever value is requested. That was no issue with the Brilliant fan controller, but the Deta controller operates this way: Whenever the Fan On button is presses, speed 3 (100%) is selected. Then you press the speed button to select the speed. But it will always select speed 3 when the Fan On button is pressed. So, when the code is running, the speed is selected (say 2), but then dp.Active is set true, which sets the Fan speed back to 3. I can actually get the speed slider to work if I comment out the .on('set', this.setActive.bind(this)); line 37. But then you can't use the Home app tile to turn the fan on and off. I've tried doing things like this, but it always wants to set dp.Active true after I select the speed: setActive(value, callback) {
I've never really coded anything before, so I have no real idea about what I am doing. It would be great to get this working though! |
The good news is, the settings from this thread seem to mostly work with my newly purchased TREATLIFE DS03 Fan/Light combo switch. The bad news is, I'm seeing some similar issues with fan speed control, and light dimming as mentioned here and elsewhere. Light: Turning the light on/off in Home app works ok, as long as you have not manipulated the brightness level in Home app (so, using just the main button in the Room). If you adjust the brightness, no matter the value, the switch seems to always move to the minimum value. Wonder if this has something to do with the value range itself (maybe setting 1-10 for brightness rather than 1-100 or something like that). Setting the brightness to maximum never (visibly) changes the intensity level, and it must be corrected using the hardware switch). Fan: Adjusting the speed mostly works, but, there are 4 speeds on the switch, and when you adjust the speed % using the app, it will only ever go to a maximum level of 3 on the switch (it actually shows that it goes to 4 briefly with the indicator lights on the switch, but settles on 3 in the end). Only way to get the fan back to full speed is to set it back to speed 4 using the hardware switch. I'm an intermediate user of Homebridge, but very new to these Tuya devices. Been doing lots of spelunking on google, but still feeling very novice and uninformed as to the specifics of manipulating these devices via Homebridge config.json. config.json:
|
For what its worth, this has been my experience with the TreatLife DS-03 ceiling fans. I've been able to install them and get them working with the device id's and keys. They have 4 speeds (if controlled by the Tuya app or the wall switch), but HomeKit only shows 3 speeds (33%, 66% and 100%). There is no way of accessing the highest speed through the Home app. I've updated the following files based on @murch1 instructions. I couldn't find the HomeKitTypes.js file anywhere but this file seems to have the same contents: /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/HomeKit.js fan_speed | Enum | {"range":["1","2","3","4"]} However, I can still only access 3 speeds through the Home app. Any ideas? Thanks. |
Thanks for doing your work on this! I'm wondering how easy it would be change the fan light to display as a switch and not a dimmer? |
How do you get the schema nowadays when tuya-lan-find --schema is not working, I was able to get ID/Keys from iot.tuya.com |
T uya-lan-find --schema seems to have worked fine for me, at least when I was working on this a few months ago. In the end, I flashed the units with Tasmota and loaded them up into HomeKit via Home Assistant. |
Here is the schema for the deta fan controller schema: '[{"mode":"rw","code":"switch","name":"\u98ce\u6247\u5f00\u5173","property":{"type":"bool"},"iconname":"icon-power","id":1,"type":"obj","desc":""},{"mode":"rw","code":"fan_speed","name":"\u98ce\u901f\u6863\u4f4d","property":{"range":["1","2","3"],"type":"enum"},"iconname":"icon-a_fan_low","id":3,"type":"obj","desc":"1\u30012\u30013\u5206\u522b\u4ee3\u8868\u4f4e\u3001\u4e2d\u3001\u9ad8\u98ce\u901f\u6863"},{"mode":"rw","code":"light","name":"\u706f\u5f00\u5173","property":{"type":"bool"},"iconname":"icon-tcl_function_light","id":9,"type":"obj","desc":""},{"mode":"rw","code":"master","name":"\u603b\u5f00\u5173","property":{"type":"bool"},"id":101,"type":"obj","desc":"\u706f\u548c\u98ce\u6247\u7684\u603b\u5f00\u5173"},{"mode":"rw","code":"timer_fan","name":"\u98ce\u6247\u5012\u8ba1\u65f6","property":{"range":["1","2","3","4","5"],"type":"enum"},"id":102,"type":"obj","desc":"1 \u8868\u793a\u65e0\u6548\uff0c2\u30013\u30014\u30015 \u5206\u522b\u8868\u793a\u5012\u8ba1\u65f6 1h\u30012h\u30014h\u30018h"},{"mode":"rw","code":"timer_light","name":"\u706f\u5012\u8ba1\u65f6","property":{"range":["1","2","3","4","5"],"type":"enum"},"id":103,"type":"obj","desc":"1 \u8868\u793a\u65e0\u6548\uff0c2\u30013\u30014\u30015 \u5206\u522b\u8868\u793a\u5012\u8ba1\u65f6 1h\u30012h\u30014h\u30018h"}]', |
I am attempting to get DS03 dimming function working. With the tuya-lan branch + ID/Key from iot, I can get everything shows up in Homekit, only issue is both fan/light in binary, no dimmer/speed capability. But at least I am super happy that light and fan showing up. Previous tuya-web on the DS03 only has fan capability only... |
I'd like to try this schema. I new to using Homebridge and I'm actually using a Hoobs device. How to I add this schema so that my Deta Fan Switch will work correctly in HomeKit? |
I have recently bought a Brilliant Wifi Ceiling Fan Controller.
The controller does both fan (power and 3 speeds) and light control (power and brightness).
I initially did the stand alone fan (SimpleFanAccessory), because I'm not using the light control (I have the lights wired straight to the power, as I already have Hue lights installed). The fan & light accessory (SimpleFanLightAccessory) was just to see if I could get it to work - which it seems to.
You will notice in the schema there are a few more functions, including:
* Mode
* Sleep timer
I have left these out, as there is no characteristic in the the Fan service to allow for them.
Schema:
Sample config.json for Fanlight:
Sample config.json for Fan: