Add Support for Fujitsu wireless Air Conditioning control app - FGLair

After you have changed the directory structure, modify climate.py (old fujitsu_general_heatpump.py) and remove lines (near the top):

from homeassistant.components.climate import (
    PLATFORM_SCHEMA, SUPPORT_FAN_MODE,
    SUPPORT_OPERATION_MODE, SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_ON_OFF,
    ClimateDevice, SUPPORT_AUX_HEAT)

Then add the following where you removed the above lines:

from homeassistant.components.climate import (
    PLATFORM_SCHEMA,
    ClimateDevice
)

from homeassistant.components.climate.const import (
    SUPPORT_FAN_MODE,
    SUPPORT_OPERATION_MODE,
    SUPPORT_SWING_MODE,
    SUPPORT_TARGET_TEMPERATURE,
    SUPPORT_ON_OFF,
    SUPPORT_AUX_HEAT
)

Restart Home Assistant…

1 Like

That worked! Thanks!

Worked like a charm.
Thanks!

Glad it worked!

I upgraded HA just after midnight, and had to fix my heatpump integration before my wife and kids woke up…so I had motivation

Did you solve the european server issue,

i’m installing a similar unit in Malta europe and wanted to know if this can be integrated.

thanks

Not sure if this helps but I decompiled the APK and there are different secrets, app ids and urls based on region - which is why you would be having issues in EU. These are set on https://github.com/Mmodarre/pyfujitsu/blob/master/pyfujitsu/api.py

Secrets:
EU
"FGLair-eu-gpFbVBRoiJ8E3QWJ-QRULLL3j3U"
US
"CJIOSP-Vb8MQL_lFiYQ7DKjN0eCFXznKZE"
CH
"FGLairField-cn-zezg7Y60YpAvy3HPwxvWLnd4Oh4"

App Ids:
EU
"FGLair-eu-id"
US
"CJIOSP-id"
CH
"FGLairField-cn-id"

Urls change too:

would be
API_BASE_URL = "https://ads-eu.aylanetworks.com/apiv1/"

API_GET_ACCESS_TOKEN_URL = "https://user-field.aylanetworks.com/users/sign_in.json"
would be
API_GET_ACCESS_TOKEN_URL = "https://user-field-eu.aylanetworks.com/users/sign_in.json"

I don’t have access to another region one so can’t help more than the above but hopefully that helps someone.

China domains are (in case anyone ever wants it)

"https://ads-field.ayla.com.cn/"
"https://user-field.ayla.com.cn/"

3 Likes

Sweet! Thank you so much! I got it working!!

The server info worked once I found that I had to edit the correct api.py file.
This: c:\Users\OleAndor\AppData\Roaming.homeassistant\deps\Python36\site-packages\pyfujitsu
Not this: c:\Windows\SysWOW64\homeassistant\Lib\site-packages\pyfujitsu\

I also had to tweak the climate.py in:
c:\Users\OleAndor\appdata\Roaming.homeassistant\custom_components\fujitsu_general_heatpump'

Since I got a lot of errors. For now I just commented out some code.

Typical error:

Traceback (most recent call last):
File “C:\Users\OleAndor\AppData\Local\Programs\Python\Python36\lib\site-packages\homeassistant\helpers\service.py”, line 291, in handle_service_platform_call
await func(entity, data)
File "C:\Users\OleAndor\AppData\Local\Programs\Python\Python36\lib\site-packages\homeassistant\components\climate_init
.py", line 556, in async_service_aux_heat
await entity.async_turn_aux_heat_on()
File “C:\Users\OleAndor\AppData\Local\Programs\Python\Python36\lib\site-packages\homeassistant\components\climate_init_.py”, line 482, in async_turn_aux_heat_on
return self.hass.async_add_job(self.turn_aux_heat_on)
File “C:\Users\OleAndor\AppData\Roaming.homeassistant\custom_components\fujitsu_general_heatpump\climate.py”, line 177, in turn_aux_heat_on
self._fujitsu_device.powerfull_mode_on()
File “C:\Users\OleAndor\AppData\Roaming.homeassistant\deps\Python36\site-packages\pyfujitsu\splitAC.py”, line 69, in powerfull_mode_on
self.powerful_mode = 1
File “C:\Users\OleAndor\AppData\Roaming.homeassistant\deps\Python36\site-packages\pyfujitsu\splitAC.py”, line 233, in powerful_mode
self._api._set_device_property(self.powerful_mode[‘key’],properties)
TypeError: ‘NoneType’ object is not subscriptable

Awesome! Good to hear - I almost didn’t share those details as wasn’t sure it would help anyone so glad to know it did.

I’m getting the same issues you describe (US unit) and did something similar so I assume it’s an issue introduced recently with HA as no one else appears to have reported it.

1 Like

Great to see this progressing so well!

On a semi-related tangent, has anyone had any success with hard wiring their Fujitsu ducted air into Home Assistant? We have the wall controller for our one, and the installer said we can’t have both that and the wifi controller as the unit can’t handle both. So, I’m looking at the other options - IR being a fallback, but they seem to have a connector kit (UTD-ECS5A) that I thought I might be able to connect to a Raspberry Pi or something…

But that’s as far as I’ve got. :slight_smile:

I’m so glad you did! And also, you helped me understand how you got to the info. I’ve never decompiled an APK before, but maybe I’ll give it a try.
I’ll let you know if I can fix the nonetype errors.

I also have a similar case for which I want to connect my Electrolux washing machine. The washing machine is connected to an electrolux app. I want to be able to get a notification when the washer is done. Maybe I can decompile the electrolux app to get similar info. I’ve done some packet sniffing, so I know there are some json files flying around. However some of the packets are SSL encrypted, so I guess that means that I have to log in somehow.

Talking about Raspberry Pi… I just bought one.

I added the + after w just for testing. Same error without the +. Does anyone know what is causing this?

File “/srv/homeassistant/lib/python3.5/site-packages/pyfujitsu/api.py”, line 115, in _authenticate
f = open(ACCESS_TOKEN_FILE, “w+”)
PermissionError: [Errno 13] Permission denied: ‘token.txt’

Too me premissions should be ok.

Also trried to change owner (chown command) so the owner is homeassistant for the two marked files… still the same error…

Finally!! I got it working on the Raspberry Pi.
I found that I had to give the homeassistant user access to the /usr/lib/python3.5/ folder.

sudo chown -R homeassistant:homeassistant /usr/lib/python3.5/

Hmm… didnt work the second time (after sd card crash)

This made it work now:
Edit the tolken.txt in the api file to the a full path and give the all users read/write access to the path according to the link below:

e class="onebox stackexchange" data-onebox-src="https://stackoverflow.com/questions/29331872/ioerror-errno-13-permission-denied">
stackoverflow.com

Could do with some pointers to run Mmodarre’s excellent code, to be able to at least for the time being switch on and off my (New Zealand based) Fujitsu WiFi heat pump initially without HASS!

FGLair is currently working with the pump, no problems.

I tried running this Python code (apologies re spacing):

import logging
import pyfujitsu.api as fgapi
from pyfujitsu import splitAC

fglairapi = fgapi.Api(“email”,“pass”)
if not fglairapi._authenticate():
_LOGGER.error(“Unable to authenticate with Fujistsu General”)
devices = fglairapi.get_devices_dsn()
for dsn in devices:
print(dsn)
mydsn = dsn
myhp = splitAC.splitAC(mydsn,fglairapi)
print (myhp.device_name[0][‘property’][‘key’])
myhp.turnOn()

To get this to run I have to change line 46 (or so) in splitAC.py from:
datapoints = self._get_device_property_history(self.operation_mode[‘key’])
(which tries to get a key from a list rather than a dictionary) to:
datapoints = self._get_device_property_history(self.operation_mode[5][‘property’][‘key’])

Then the code appears to run ok, no errors, prints everything ok (key etc), but doesn’t turn the heat pump on.
Looks like nothing is being executed to actually apply the properties over the air.

What else do I need to do to turn it on? Any ideas?

Thanks, tried quite a few things to no avail.

Figured it out eventually, e.g. to switch on:

#!/media/sam/venvs/homeassistant/bin/python3
from pyfujitsu import api, splitAC
myapi = api.Api("username","password")
dsn = myapi.get_devices_dsn()
print ("dsn = " + dsn[0])
myheatpump = splitAC.splitAC(dsn[0], myapi)
myheatpump.turnOn()

The full path to token.txt also needs to be provide in api.py as described in oleandor’s post above.

1 Like

Please help 0.96 change the climate setting. Need some update please.

Yes since 0.96 when I check config I get this error

“Integration fujitsu_general_heatpump not found when trying to verify its climate platform.”

Just checked the github and looks like Dev is aware. Meanwhile I’ll roll back to previous version of HA. Thanks for this component it’s great.

I‘m using a modified version of this wonderful plugin for some time now.

I nearly finished updates for changes in 0.96, fixes for swing modes and update for localization. For the last point countries with URLs, Secrets and App-Ids as posted by @kyonz appreciated.

@Mmodarre will you accept pull requests?

2 Likes

Hey,

Thanks a lot for taking the time to do it. please send a pull request and I will review and merge it.

Regards,
Mehdi

1 Like

Looking forward it seeing this update. Would you guys want some Beta testers for the updated version? I am assuming it will only work on 0.96 and above?