A/C with wifi module integration


I am trying to integrate a Johnson A/C that uses the TFIAC android app.

There is another thread in the config section at:

But I do not get any feedback there so I am posting here to see if any experienced home assistant developer could help me to create a custom component for this.

I would need to know first if the Home Assistant core listen to broadcast packets inside the network and how to use it to get some info in those packets.

Thanks in advance,




After almost one week of reverse engineering the TFIAC application I figure it out how to control this Air Conditioner units over wifi with UDP packets and XML strings!!!
For testing purposes try to use some software like “Packet Sender” and send some commands to the unit IP on the port 7777 (UDP).
Use some of this commands (ASCII)
To Turn off:
<msg msgid="SetMessage" type="Control" seq="12345"><SetMessage><TurnOn>off</TurnOn></SetMessage></msg>

To Turn on:
<msg msgid="SetMessage" type="Control" seq="1"><SetMessage><TurnOn>on</TurnOn></SetMessage></msg>

To get actual state:
<msg msgid="SyncStatusReq" type="Control" seq="12345"><SyncStatusReq></SyncStatusReq></msg>

To raise temperature (in Fº)
<msg msgid="SetMessage" type="Control" seq="12345"><SetMessage><SetTemp>74</SetTemp></SetMessage></msg>

to down temperature (in Fº)
<msg msgid="SetMessage" type="Control" seq="1"><SetMessage><SetTemp>74</SetTemp></SetMessage></msg>

Now I’m trying to figure it out why sometimes the seq must be 1 and another times needs to be 12345.

I’m not a developer but I hope that someone can test this and help me make a module for use this im HA or OpenHab.


Thanks for the response!!

I will do also tests with the XML messages that you found and try to solve the seq problem you talked about.

I have some experience programming in Python but none with Home Assistant modules, anyway we can try to create something.

Dear @phenriques3000,

I think I got the seq mistery solved.

If you send something like the following to turn the system on:

<msg msgid="SetMessage" type="Control" seq="999">

Then you get a response like:

<msg msgid="ACKSetMessage" type="Control" seq="999">

And again if you send:

<msg msgid="SyncStatusReq" type="Control" seq="555">

Then again you get:

<msg msgid="statusUpdateMsg" type="Control" seq="555">
    <DeviceName>Katie AC</DeviceName>

Therefore my conclusion is that the seq number is only an id of the message that is then used in the response. Apparently you can set that seq to anything you want, and then you can check if the response have the same seq to be sure that is the answer to your message.

I did not find the need to set the seq 12345 or 1, like you said in your previous message.

By the way, Packet Sender is a very useful tool I didn’ t know about.

Therefore we may start developing a custom component for Home Assistant and this way contribute to this awesome project.



Note: I formatted the XML messages for a better reading experience. But they are sent and received in a single line.

Hello pavlo,
Sorry for my late response.
About the seq number if I turn on the AC with seq 12345 I can’t turn it off with the same seq number.
Another test I did is, if I turn on AC with seq 12345 I can rise the temperature using the same seq but if I want to lower the temperature I need to change the seq, otherwise nothing happens.
If you can do some more tests as I say.
I’m not a professional developer but I think I can help you in some tasks, talk to me in PM :wink:
Thanks mate.

Suggestions for building a new climate component.

I would suggest that you start simple and look at this early version of the daikin climate component (developed by @robhuls and me): https://github.com/robhuls/home-assistant/blob/dev/homeassistant/components/climate/daikin.py#L79

As you can see is the requests made directly in the code and according to the findings here https://community.home-assistant.io/t/a-c-app-named-tfiac-anyone-ever-heard-of-it/58169/5 you need to change requests to socket. Also, since your device communicates with XML (are we still in the '90s :confused:) you probably can use https://docs.python.org/3/library/pyexpat.html#module-xml.parsers.expat.

The two important parts are update where you read the status of your ac-model. And set_state where you set the new state to your ac.

Thanks @fredrike !

I will check the tips and links you suggest and I will get back to you if I have any doubt.

I’ve built an initial working version that can be found here.

Place the file under /config/custom_components/climate and make sure to add the following to your configuration.yaml.

    platform: tfiac

It’s not really clear how seq is used so I just used epoc (seconds since 1970). Also I need help to figure out which modes (OPERATION_LIST, FAN_LIST, SWING_LIST) that are supported and how the swing mode should be set (I guess this is what is called WindDirection).

According to statusUpdateMsg there seems to be an Opt_super and an Opt_ECO mode, is that something we should strive for to also support?

There is still quite a bit to get this in a stage where it can be added as an official component but it is a good start. It would for instance be great if we could support the UDP-broadcasts, both for auto discovery but also to update the state by local push instead of polling.

1 Like

Hi fredrike and pavlo,
For my unit and TFIAC app I figure out this:

Parameter Value Obs.
BaseMode heat Min temp: 61F (16C) - Max temp: 88F (31C)
BaseMode selfFeel Called AUTO mode in the TFIAC app
BaseMode dehumi When this mode is set it’s not possible to set the temp
BaseMode fan When this mode is set it’s not possible to set the temp
BaseMode cool Min temp: 61F (16C) - Max temp: 88F (31C)
WindSpeed Low
WindSpeed Middle
WindSpeed High
WindSpeed Auto Cannot be used when BaseMode is fan
WindDirection_V on
WindDirection_V off
WindDirection_H on
WindDirection_H off
Opt_super on Called Turbo in the TFIAC app
Opt_super off Called Turbo in the TFIAC app
Opt_ECO on Can only be used with BaseMode cool, heat and selfFeel. Can’t be used when Opt_sleepMode is on
Opt_ECO off Can only be used with BaseMode cool, heat and selfFeel. Can’t be used when Opt_sleepMode is on
Opt_sleepMode sleepMode1:0:0:0:0:0:0:0:0:0:0 Don’t know why the zeros… Can’t be used when Opt_Eco is on
Opt_sleepMode off:0:0:0:0:0:0:0:0:0:0 Don’t know why the zeros… Can’t be used when Opt_Eco is on

If we consider all this modes I think (except the timer funcion) we cover all the TFIAC app options.
There is also some other cool options that the App don’t use, like BeepEnable on or off but I think it’s not a must have option :smiley:

1 Like

Thank you for summarizing it.

To set 3D swing mode, can you send this:

<msg msgid="SetMessage" type="Control" seq="20190129">

Also, what is sent when going from Off to heat?

Edit1: Home-Assistant does not have a eco mode but it could be implemented as heat eco, cool eco, selfFeel eco, is that ok? What happens to WindSpeed Auto if BaseMode is switched to fan? What does Opt_super/Turbo mean, is that a fan-mode or a special heat mode? Home-Assistant does not support sleep_mode (if it’s not a special fan mode)? Here are the currently supported modes for ha: https://www.home-assistant.io/components/climate#services

Edit2: I’ve updated the file on gist, please test so the different modes work while deciding on my questions on edit1.

I test to send this after my unit is turned off:
<msg msgid="SetMessage" type="Control" seq="1355"><SetMessage><BaseMode>heat</BaseMode><TurnOn>on</TurnOn><SetTemp>69</SetTemp><BeepEnable>off</BeepEnable></SetMessage></msg>
And the result is my unit turns on and the basemode and temp was correctly set.

I think it’s ok, in the end the parameter sended for the unit will be the same.

The WindSpeed is changed to low automatically, so I think the best is to not send the WindSpeed parameter when the BaseMode is set to fan.

In the reality is more a kind of a shortcut key because when I activate it the fan in the splitter works at maximum speed (WindSpeed sets to High) and the heat goes to max (88ºF), in case the BaseMode is set to heat. If the BaseMode is set to cool then the WindSpeed sets to High too but the temp is set to the minimum (61ºF).


I’ll wait with eco and WindSpeed Auto as it requires some more logic in set mode…

Would it be ok to implement Climate - Home Assistant as the Opt_super mode?

@phenriques3000, @pavlo please make sure to test all the different combinations i the code now and I’ll make sure all that features works well before I’ll add the ones discussed above.

For what I read this is more likely to be the ECO mode right?

Yes, but we are out of options for a toggle to enable this and I don’t feel like creating a separate switch for it.
Perhaps it could be a service call so it can be added as a button. But I think I’m done with features now so make sure that the current implementation works and we’ll see how the rest can be implemented.

Ok @fredrike, now I’m installing HA for the first time because until now i’m a OH user :smiley:
Maybe @pavlo can test it before I. But we will keep you updated. Very thanks! :smiley:

1 Like

Hi @fredrike,
Already test the component.
So far what I see to work:
If I toggle On/Off button nothing happens.
If I change the operation mode AC turns on but don’t set the selected operation mode and temp.
Currently temperature shows fine.
Everything else is not working… how can I do some debug? Can I see anywhere the output everytime I change something?

Oh, so the commands I’m sending is not correct…

Could you please send some commands via the app and send me the xml the app is sending for each commamd. We must have missed something in the api format.

I can add some debug information to the home assistant code, but first tomorrow.

Edit: added debug output to the code on gist. Perhaps we need to send a more complete message (BaseMode+SetTemp+TurnOn) as your example above @phenriques3000.

I can’t because the app don’t use this type of communication, it send some kind of data over UDP to port 80, until now I can’t decrypt what is sent by this packets.

I discover this xml method because I decompile the apk and I figured out this

What I do for test purposes is send the ASCII string (the xml) packets with Packet Sender and next I see the result using the TFIAC app or viewing the current status in my unit.

I don’t think you do it bad… But if you put something to help viewing each xml string that results for any interaction in HA I can test and say what is wrong :smiley:

@phenriques3000, you may have not noticed but you can also get the result in the Packet Sender app. Once you sent an XML command, you get back a packet with same seq number and “Return Ok”, and you can then send another XML command requesting status, and you will get the XML with the whole status.

My point is that do not need the TFIAC app to see the result.