AMoo-Miki / homebridge-tuya-lan

Homebridge plugin for IoT devices that use Tuya Smart's platform
MIT License
204 stars 52 forks source link

Smart Life Heating/Cooling Air Conditioner #2

Closed EvolvingParty closed 5 years ago

EvolvingParty commented 5 years ago

Hi,

I have an Air Conditioner/Heater that uses the Tuya Smart Life App. It also shows on the app the current room temperature which I would also like to have a Home tile for if possible so I can create actions like turn on AC when temp gets about 30°C. Link to product is here - https://www.kogan.com/au/buy/kogan-smarterhome-41kw-portable-air-conditioner-14000-btu-reverse-cycle/

I successfully added the Smart Life Air Conditioner as a Simple Light as instructed, successfully finding the key and id -

{ "platform": "TuyaLan", "devices": [ { "name": "Air Conditioner", "type": "SimpleLight", "manufacturer": "Kogan", "model": "KAPRA14WFGA", "id": "2800100084f3eb579e9a", "key": "123456abcdef" } ] }

It's successfully showing in Apple Home as 'Air Conditioner' 'No Response'. In the Homebridge logs it shows

Ready to handle Air Conditioner with signature {"1":false,"2":21,"3":29,"4":"COOL","5":"1","19":"C","102":false,"103":0,"104":false,"105":0,"106":0,"110":"0"}

Its got 2 states I guess, on and off. That would be enough to make me happy, I don't change the mode much as I keep it on cool but would be good to be able to change, they are "cool", "fan", "dry" and "heat". They temperature for cool and heat have to be set, but remain the same it the device it just powered on and off. There is a fan setting with three options, low med and high and there is a swing on and off setting.

Let me know if that is possible please. Great work, best regards, Kurt.

EvolvingParty commented 5 years ago

Hey, For some reason after restarting my computer it allows me to turn the device on and off, that's pretty cool. I can't change the little icon to anything but light symbols, when I tap it only gives me 4 options and they are all lights, do you know how to do that? Thanks

AMoo-Miki commented 5 years ago

Hi Kurt,

Gimme a few hours and I will add Air Conditioner for you. ~Does your device have heating and auto modes or does it only cool?~ I went through your post again and .. I got my answer.

EvolvingParty commented 5 years ago

Hi,

Wow that generous of you. It has 4 modes. They are "cool", "fan", "dry" and "heat". There is a fan setting with three options, low med and high and there is a swing on and off setting.

:)

On 28 Nov 2018, at 12:59 pm, Miki notifications@github.com<mailto:notifications@github.com> wrote:

Hi Kurt,

Gimme a few hours and I will add Air Conditioner for you. Does your device have heating and auto modes or does it only cool?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/AMoo-Miki/homebridge-tuya-lan/issues/2#issuecomment-442301043, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEa3Pdkn9IU7s9kCNfTk-RXuqhXusPwbks5uzfv7gaJpZM4Y2uhG.

EvolvingParty commented 5 years ago

Hi,

Im happy to be able to turn the device on and off with SIRI. I tested it a few times shutting down Homebridge , changing the mode manually on the unit and starting it back up again and it put into the log file different results based on the settings. Maybe you can use that to configure the Homekit controls, I'm not sure what HomeKit controls you can include.

The third “true/false” is the swing feature. I think where it says “29” that’s the current room temperature. After the mode is “5” then 1,2 or 3 I think that’s the fan speed. There is also a time that can be set to turn it on or off from 0 to 24 hours

COOL 21°C with FAN SPEED “LOW” & SWING off

Ready to handle Air Conditioner with signature {"1":false,"2":21,"3":29,"4":"COOL","5":"1","19":"C","102":false,"103":0,"104":false,"105":0,"106":0,"110":"0"}

COOL 21°C with FAN SPEED “HIGH” & SWING off

Ready to handle Air Conditioner with signature {"1":false,"2":21,"3":29,"4":"COOL","5":"3","19":"C","102":false,"103":0,"104":false,"105":0,"106":0,"110":"0"}

DRY & SWING off

Ready to handle Air Conditioner with signature {"1":false,"2":21,"3":29,"4":"DRY","5":"1","19":"C","102":false,"103":0,"104":false,"105":0,"106":0,"110":"0"}

HEAT with SWING on

Ready to handle Air Conditioner with signature {"1":false,"2":21,"3":29,"4":"HEAT","5":"1","19":"C","102":false,"103":0,"104":true,"105":0,"106":0,"110":"0"}

FAN & SWING off

Ready to handle Air Conditioner with signature {"1":false,"2":21,"3":29,"4":"FAN","5":"1","19":"C","102":false,"103":0,"104":false,"105":0,"106":0,"110":"0"}

I took one last reading from the log to try to clarify the output Air Conditioner was on to 21°C , indoor temp was 26°C, the Timer was set to 2 hours, Swing on, mode cool, fan speed low.

Ready to handle Air Conditioner with signature {"1":true,"2":21,"3":26,"4":"COOL","5":"1","19":"C","102":false,"103":2,"104":true,"105":119,"106":0,"110":"0"}

Hope that makes sense. Im keen see to learn more about what controls can be included in the home app so I can ask SIRI to set the temperature to 21 or put Air Conditioner in Dry mode.

AMoo-Miki commented 5 years ago

I have published v1.1.0 of the plugin which supports air conditioners; thanks for the definition. I didn't implement the fan speed but I will shortly; is there an off for fan speed in the cool or heat modes?

To update the plugin, run npm i -g homebridge-tuya-lan and then restart Homebridge.

Configuration instructions can be found on the Supported Devices page but this should work for your device:

{
    "name": "Air Conditioner",
    "type": "AirConditioner",
    "manufacturer": "Kogan",
    "model": "KAPRA14WFGA",
    "id": "2800100084f3eb579e9a",
    "key": "--- your key ---",

    "minTemperature": 17,
    "maxTemperature": 30
}

It would be great if you could test the implementation and post back any problems you find; hopefully it will work just fine.

EvolvingParty commented 5 years ago

Hi

Good work you’re amazing. I’ll test it out soon. There is no off for the fan, just low, med and high 1, 2 and 3 I’m guessing.

EvolvingParty commented 5 years ago

Hi,

I updated as per your instructions and typed in the new values but Homebridge won't start, just keeps repeating this

[11/28/2018, 9:03:38 PM] [TuyaLan] Ready to handle Air Conditioner with signature {"1":true,"2":21,"3":25,"4":"COOL","5":"1","19":"C","102":false,"103":0,"104":true,"105":0,"106":0,"110":"0"} /usr/local/lib/node_modules/homebridge-tuya-lan/lib/AirConditionerAccessory.js:47 const characteristicActive = service.getCharacteristic(Characteristic.Active) ^

TypeError: Cannot read property 'getCharacteristic' of undefined at AirConditionerAccessory._registerCharacteristics (/usr/local/lib/node_modules/homebridge-tuya-lan/lib/AirConditionerAccessory.js:47:46) at TuyaAccessory.BaseAccessory.device.once (/usr/local/lib/node_modules/homebridge-tuya-lan/lib/BaseAccessory.js:22:18) at Object.onceWrapper (events.js:273:13) at TuyaAccessory.emit (events.js:182:13) at TuyaAccessory._change (/usr/local/lib/node_modules/homebridge-tuya-lan/lib/TuyaAccessory.js:236:18) at TuyaAccessory._msgHandler (/usr/local/lib/node_modules/homebridge-tuya-lan/lib/TuyaAccessory.js:170:26) at /usr/local/lib/node_modules/homebridge-tuya-lan/node_modules/async/dist/async.js:4096:9 at Object.process (/usr/local/lib/node_modules/homebridge-tuya-lan/node_modules/async/dist/async.js:2344:17) at /usr/local/lib/node_modules/homebridge-tuya-lan/node_modules/async/dist/async.js:2252:19 at Immediate. (/usr/local/lib/node_modules/homebridge-tuya-lan/node_modules/async/dist/async.js:119:16)

AMoo-Miki commented 5 years ago

Odd. Lemme see if I messed up something.

AMoo-Miki commented 5 years ago

Homebridge has cached the old accessory that was defined as a Lighbulb. To clear the cache, delete the file named cachedAccessories which is in a folder named accessories beside your config.json file. Then restart Homebridge.

EvolvingParty commented 5 years ago

Yes That worked.

EvolvingParty commented 5 years ago

68747470733a2f2f692e6962622e636f2f345a466a6254512f494d472d333730392e706e67 68747470733a2f2f692e6962622e636f2f357879714477772f494d472d333730332e706e67 68747470733a2f2f692e6962622e636f2f393867345777342f494d472d333730342e706e67 68747470733a2f2f692e6962622e636f2f547678345a36782f494d472d333730352e706e67 68747470733a2f2f692e6962622e636f2f536635765a66522f494d472d333730362e706e67

AMoo-Miki commented 5 years ago

Perfect. I am done with the fan speed; just testing before I publish it. I will post back in a bit.

EvolvingParty commented 5 years ago

What you have done is incredible, it's really good work.

EvolvingParty commented 5 years ago

When I said to SIRI set the oscillator to on, SIRI didn't know what an oscillator was, but I said set the swing to on and he did it! Thats awesome.

EvolvingParty commented 5 years ago

Amazing work what you have done already. There’s two things in wondering the timer function, is that something that would work in home? And In the automation tab of the home app there is an option for “When a sensor detects something” do another thing, Is the room temperature sensor in the device something that can be configured so that it is included in there? At the moment I have no sensors so that option is greyed out.

AMoo-Miki commented 5 years ago

I am glad I could be of help :)

I just published v1.1.1 which has the fan speed control. To update the plugin, run npm i -g homebridge-tuya-lan.

Since your fan speed has only 3 modes, add "fanSpeedSteps": 3 to the config of your air conditioner. Homebridge will need to be restarted but you don't need to clear its cache.

Apple has many such weird things where what you need to tell Siri is not the same as the label in the Home app.

Apple doesn't implement the builtin timers of devices either and they want you to use their automation which as you found out is very limited; it is incapable of using temperature sensors for automation. People propose doing such automation using the Elgato Eve app or IFTT.

EvolvingParty commented 5 years ago

Thank you,

Updated: Sorry but the fan speed control is in the settings but it doesn't do anything. If I move it up, the speed of the device doesn't change from low to med to high and then if I move it back to its lowest setting, the Air Conditioner shows as off when its still actually on.

49179006-10149700-f39d-11e8-8b94-0403a5cdeab7

AMoo-Miki commented 5 years ago

Thanks for letting me know and sorry for it not working. I'll get to it as soon as I get home; you should hear from me within a few hours.

AMoo-Miki commented 5 years ago

I just pushed the fix in v1.1.2; please update the plugin and restart Homebridge.

npm i -g homebridge-tuya-lan

PS, when the fan speed is at the extreme left, it turns off the AC.

EvolvingParty commented 5 years ago

Hi,

It is working, when using the slide bar the fan does change from Low to Mid to High, then when turning the slide bar all the way down, the unit goes off. its not easy to use, because the slider doesn't "click into place" but the function is there. I played with it a few times and sometime I slid the bar all the way to the top and it only went to Mid, then I had to flick it down and back up a but to get it to high. I would be impossible to do know with certainty what setting it was on unless you are standing near the AC to see. Then sometimes I put it nearly all the way down and its hard to know from just using the app if it worked. I understand it's probably a limitation of Home app? Unless there is another way to set the speed, with a window like the Heat/Cool/Off settings its unclear what setting you are on. Good job on doing everything you have done. it doesn't need to be changed as I hardly use the speed setting and always keep it on Low as its very powerful.

All the work you have done is great. I have been happy to have your expertise. I hope other people find and use the work you have done and are as happy as I am.

AMoo-Miki commented 5 years ago

I am glad you find it useful.

Regarding the speed slider, I feel you. I don't think there is a way to add steps to the slider but I will try to mess with it and see.

Best of luck.

TheHomekitWayFinder commented 5 years ago

Hello,

I own the exact same Air Conditioner from Kogan and homebridge keeps crashing once the device has been discovered and tries to add to homekit but fails and crashes. I will send the log in a bit

EvolvingParty commented 5 years ago

Make sure it’s not a typo in your config file. Works perfectly for me until homebridge on the Mac stops. I only have scenes for heat and cool because HomeKit can’t do fan or dry. But Siri can turn it on and off and make it oscillate and set fan speed to hi and low and set temperatures and tell me what the temperature in the room is currently.

Best regards, Kurt.

Sent from Kurt’s iPhone.

TheHomekitWayFinder commented 5 years ago

Here is the log from homebridge:

`[5/12/2019, 8:32:13 PM] [TuyaLan] Discovered AC (71645600b4e62d215921) C:\Users\xxxxx\AppData\Roaming\npm\node_modules\homebridge-tuya-lan\node_modules\node-forge\lib\aes.js:203 var len = tmp.length(); ^

TypeError: tmp.length is not a function at forge.aes.Algorithm.initialize (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\homebridge-tuya-lan\node_modules\node-forge\lib\aes.js:203:19) at new forge.cipher.BlockCipher (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\homebridge-tuya-lan\node_modules\node-forge\lib\cipher.js:118:18) at Object.forge.cipher.createCipher (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\homebridge-tuya-lan\node_modules\node-forge\lib\cipher.js:42:10) at new TuyaAccessory (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\homebridge-tuya-lan\lib\TuyaAccessory.js:28:36) at EventEmitter.TuyaAccessory.discover.on.config (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\homebridge-tuya-lan\index.js:77:32) at EventEmitter.emit (events.js:182:13) at Socket.server.on.msg (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\homebridge-tuya-lan\lib\TuyaAccessory.js:343:24) at Socket.emit (events.js:182:13) at UDP.onMessage [as onmessage] (dgram.js:628:8)`

here is my config.json file:

`{ "bridge": { "name": "Homebridge", "username": "xx:xx:xx:xx:xx", "port": 51826, "pin": "xxx-xx-xxx" },

"description": "This is an example configuration file.",

"platforms": [{
        "platform": "TplinkSmarthome",
        "name": "TplinkSmarthome"
    },
    {
        "platform": "TuyaLan",
        "devices": [{

            "name": "AC",
            "type": "AirConditioner",
            "manufacturer": "Kogan",
            "model": "SmarterHome Air Conditioner",
            "id": "71645600b4e62d215921",
            "key": "--------key---------"
        }
        ]
    }
],

"accessories": [{
    "accessory": "Xbox",
    "name": "Xbox",
    "ipAddress": "xx.x.x.x",
    "liveId": "xxxxxxxxxxxx"
}]

}`