maximkulkin / esp-ir-thermostat

Example of HomeKit smart thermostat that controls AC via IR
MIT License
4 stars 2 forks source link

Can it work with other IR library and using homekit_accessory_category_air_conditioner? #5

Open royfocker19 opened 5 years ago

royfocker19 commented 5 years ago

Hi Maxim, I was able to send commands to my AC using a single line or creating the the state needed like this:

include

include

include

include

const uint16_t kIrLed = 4; // ESP8266 GPIO pin to use

IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message. IRCoolixAC ac(kIrLed); // Set the GPIO used for sending messages.

void setup() { irsend.begin();

if ESP8266

Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);

else // ESP8266

Serial.begin(115200, SERIAL_8N1);

endif // ESP8266

}

void loop() { delay(4000); Serial.println("Carrier"); ac.begin(); ac.setPower(true); ac.setTemp(29); ac.setMode(kCoolixHeat); ac.setFan(kCoolixFanMin); ac.send(1); // Send with a single repeat. i.e. two messages sent.

delay(4000); Serial.println("off"); irsend.sendCOOLIX(0xB27BE0, kCoolixBits, 1); // with 1 repeat. i.e. two messages sent. }

How can I modify your accessory to use commands like this to send the data? Also, I was wondering, are you using thermostat instead of AC because is not implemented yet?

royfocker19 commented 5 years ago

I think my question was a stupid one, sorry. If this is not possible I'm gonna try to implement codes like you did (sending the twice, because if not, it doesn't work), instead of rawdata. Even in your code I see Dry and Fan modes, I can't see that on my phone, I don't know if that has something to do with ios13. Regards Fede

maximkulkin commented 5 years ago

Ok, first, you can not use Arduino libraries with esp-homekit since Arduino libraries are not designed to work in FreeRTOS (which esp-homekit is based on). I have written a library that can - esp-ir.

Second, an accessory category that you use does not affect anything, just the icon your accessory will have when you will try to pair with it. Sure, you can change it, but the real deal is which services you implement inside your accessory. For that, there is not much information available in Homekit spec, I have implemented this one as best as I could. It would be nice if anybody who has commercial HomeKit enabled ACs posted a dump of those accessory database.

Third, fan mode is a bit tricky. In HomeKit fan is a separate service and I tried to make it work this way: if you turn on fan while thermostat is off, it turn on fan mode on AC, otherwise it will just change fan speed without changing AC mode.

Has nothing to do with iOS13.

maximkulkin commented 5 years ago

If this is not possible I'm gonna try to implement codes like you did (sending the twice, because if not, it doesn't work), instead of rawdata.

It feels that this repeat functionality was added there because this implementation is not reliable. My library should be better in this regard.

royfocker19 commented 5 years ago

in fact, the AC needs the command to be sent twice to work. That's why it didn't work with your library using hex codes but worked with raw data. Regarding the other question, is Dry and Fan options missing on AC or thermostat?

maximkulkin commented 5 years ago

I think what you’re referring to is some common protocol where data is intentionally repeated twice.. wonder what will happen if repeat command does not match.

royfocker19 commented 5 years ago

Yes, the protocol works that way. I'll try that. Regarding dry option, even if it's mentioned in your code Homekit doesn't have that option, right? only Auto, Cool, Heat and Off. Regards Fede

On Mon, Jul 29, 2019 at 4:57 PM Maxim Kulkin notifications@github.com wrote:

I think what you’re referring to is some common protocol where data is intentionally repeated twice.. wonder what will happen if repeat command does not match.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/maximkulkin/esp-ir-thermostat/issues/5?email_source=notifications&email_token=AJL4PCG3NBR2GA7NVIJRPMDQB5DUFA5CNFSM4IHNM4MKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3B2TDA#issuecomment-516139404, or mute the thread https://github.com/notifications/unsubscribe-auth/AJL4PCGJD7LUD6ZGCSIL7Z3QB5DUFANCNFSM4IHNM4MA .

maximkulkin commented 5 years ago

Well, I think dry mode is just running fan without neither heating nor cooling. My code does support that.

royfocker19 commented 5 years ago

In fact dry is cool mode with fan very low and no chance to move it. So it should have a separate option to work as intended.

royfocker19 commented 5 years ago

in that case, should it be modified so the dry option activates only if FAN is off and cool option is on at specific temperature (based on the AC)? another question, what does FAN=4 means on the serial console? It never changes.

HomeKit: [Client 4] Update Characteristics State: command=1 mode=1 fan=4 swing=0 temperature=24 Got readings: temperature 18, humidity 22

maximkulkin commented 5 years ago

Fan=4 means QUIET. There is a bug in firmware that leaves fan in quiet mode when you turn on AC/heater (so you need to manually set it to high after turning AC on). I still need to revisit it for a better implementation.

maximkulkin commented 5 years ago

Ok, I have fixed quiet fan always being set, although I decided to sacrifice fan-only mode.

royfocker19 commented 5 years ago

Hi Maxim, is it possible to link a Fan accessory so if you turn it on it can disable the Air conditioner? I think it could be a possible solution to have that extra accessory on the device so if you want to enable fan mode it would disable the AC. It could be done with automations also, right?