Add Support for Fujitsu wireless Air Conditioning control app - FGLair

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?

That’s right - only >= 0.96. Beta testers are appreciated.

First version is fully working now on my AC with Home Assistant 0.97. Had to do a complete rewrite of the custom component.

Now some code cleanup is left. I plan to deliver first PR on the weekend latest.

1 Like

@beta testers: PRs are out. Feedback is appreciated.


Hi @philwilldo, I have downloaded your version and updated HA to 0.97.1. I am getting a “Integration fujitsu_general_heatpump not found when trying to verify its climate platform.” error when I try to restart HA.

I see you also updates the pyjujitsu code. Does that need to be installed manually for it to use your version?

Hi @philwilldo, Have gotten a bit further. Install hassio 0.97.1 on a spare RPi and did a fresh install of your version of the component. I also installed your pyfujitseu in /config/deps/lib/python3.7/site-packages/pyfujitseu/. HA doesn’t give the above error here, but the component fails to load with the follwing error in the log.

Error while setting up platform fujitsu_general_heatpump
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 149, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 84, in setup_platform
    add_entities(FujitsuClimate(fglairapi, dsn) for dsn in devices)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 198, in _schedule_add_entities
    list(new_entities),
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 84, in <genexpr>
    add_entities(FujitsuClimate(fglairapi, dsn) for dsn in devices)
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 106, in __init__
    self._swing_mode = self.swing_mode
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 195, in swing_mode
    return self._fujitsu_device.get_swing_mode_desc()
  File "/config/deps/lib/python3.7/site-packages/pyfujitseu/splitAC.py", line 141, in get_swing_mode_desc
    return SWING_LIST_DICT[self.af_vertical_direction['value']]
TypeError: 'NoneType' object is not subscriptable

I skipped a step. I had to create a token.txt file as I was getting an error related to that, but the file is empty. What is the token data that should be in there?

I get the following error without a tokenpath set:

Error while setting up platform fujitsu_general_heatpump
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 149, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 77, in setup_platform
    if not fglairapi._authenticate():
  File "/config/deps/lib/python3.7/site-packages/pyfujitseu/api.py", line 118, in _authenticate
    f = open(self._ACCESS_TOKEN_FILE, "w")
TypeError: expected str, bytes or os.PathLike object, not NoneType

Hi @Justin_Young, thanks for the feedback. Lets go through it step by step.

#1) Installation of pyfujitseu works automatically on my RPi, but I use a github source instead of PyPi, which is recommended for dev only. So this will be not an issue anymore, when we are merged to the original pyfujitsu PyPi package.

#2) Seems like this is a resulting error of not existing token file. Will add a NoneType-check.

#3) So now it’s about the token file again. This made problems before as you can read above. That’s why I added an optional config-entry for the tokenpath. I used an absolute path and added the file to the homeassistant users home dir, as you can see in the example in my README.
For me it looks like that the file is detected, but your home assistant user doesn’t have a write-right for the file. Depending on what installation (virtual env, docker, …) you have, this might not be the best way for you too. You might use your current file, but chown the file with your home assistant user or set chmod to 666 for this file. I does not need to have any content, home assistent will fill it, if configured correctly.

Hope that helps!

Hi @philwilldo, I have got the token file working, HA has written an access token to it. That was just my lack of understanding that HA would create the token.

Am I right in my thinking that I need to (for now, until the code is merged) put the pyfujitseu/ folder at /config/deps/lib/python3.7/site-packages/pyfujitseu/? Without it I get the following error:

Error while setting up platform fujitsu_general_heatpump
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 149, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 68, in setup_platform
    import pyfujitseu.api as fgapi
ModuleNotFoundError: No module named 'pyfujitseu'

with it there I get:

Error while setting up platform fujitsu_general_heatpump
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 149, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 84, in setup_platform
    add_entities(FujitsuClimate(fglairapi, dsn) for dsn in devices)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 198, in _schedule_add_entities
    list(new_entities),
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 84, in <genexpr>
    add_entities(FujitsuClimate(fglairapi, dsn) for dsn in devices)
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 106, in __init__
    self._swing_mode = self.swing_mode
  File "/config/custom_components/fujitsu_general_heatpump/climate.py", line 195, in swing_mode
    return self._fujitsu_device.get_swing_mode_desc()
  File "/config/deps/lib/python3.7/site-packages/pyfujitseu/splitAC.py", line 141, in get_swing_mode_desc
    return SWING_LIST_DICT[self.af_vertical_direction['value']]
TypeError: 'NoneType' object is not subscriptable

I coul;d be doing completely the wrong thing there, just following my nose.