Add Support for Fujitsu wireless Air Conditioning control app - FGLair

Hi @Justin_Young,
no worries, your nose points in the right direction:

  1. You’re absolutely right: For now you need to have pyfujitseu folder in site-packages.
  2. The pyfujitseu-package is starting to load on your system, but breaks within my new swing mode implementation. We seem to have different types of Fujitsu-ACs with different swing mode APIs. I added a fallback to the pyfujitseu code and created a new release for you here:
    https://github.com/xerxes87/pyfujitseu/releases/tag/0.9.2.8

Hopefully you can get this one working :smiley:

Hi @philwilldo,
I think my nose isn’t quite as good as @Justin_Young.

I added the code into /config/deps/lib/python3.7/site-packages/pyfujitsu/ and as far as I can tell everything else appears to work if I change the region I receive a logon error which would be expected as I’m in Australia which uses the US settings I believe.

I’m stuck on the token.txt which appears is not created automatically and I cannot find where to place a blank token.txt file.

Any help would be appreciated.

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/pyfujitsu/api.py", line 118, in _authenticate
    f = open(self._ACCESS_TOKEN_FILE, "w")
FileNotFoundError: [Errno 2] No such file or directory: '/home/homeassistant/token.txt'

Hi @qwackers,

Just create it at the location you defined:
‘/home/homeassistant/token.txt’
(See last line of your log)

Don’t forget to chown / chmod so that your HomeAssistant user can write into it.

Thanks for beta testing!

Thanks @philwilldo,

Got past the token.txt which no matter how many times I looked at it was stuffing it up, I removed the path and bam token.txt created automatically :slight_smile:

Config.yaml for reference

- platform: fujitsu_general_heatpump
  username: !secret fglair_username
  password: !secret fglair_password
  region: 'us'
  tokenpath: 'token.txt'

Same as @Justin_Young I now get the following errors

Log Details (ERROR)
Wed Aug 14 2019 08:10:12 GMT+1000 (Australian Eastern Standard Time)
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/pyfujitsu/splitAC.py", line 141, in get_swing_mode_desc
    if not isinstance(self.af_vertical_direction['value'],int):
TypeError: 'NoneType' object is not subscriptable

Hi @philwilldo,

Just tested the new code. Still getting an error, but it’s a bit different.

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/pyfujitsu/splitAC.py", line 141, in get_swing_mode_desc
    if not isinstance(self.af_vertical_direction['value'],int):
TypeError: 'NoneType' object is not subscriptable
1 Like

Hi @Justin_Young and @qwackers,

First fallback seemes to be insufficiant. Sorry about that.

I added an additional fallback. Please try again with new release:

Hi @philwilldo,

A new error now as below.

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/pyfujitsu/splitAC.py", line 145, in get_swing_mode_desc
    if self.af_vertical_direction['value'] is not None:
TypeError: 'NoneType' object is not subscriptable

@qwackers New shot:

@philwilldo you legend its getting closer, have been able to start the A/C via HA. All functions appear to work except swing mode which generates an error.

Wed Aug 14 2019 18:05:15 GMT+1000 (Australian Eastern Standard Time)
'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 128, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 334, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 356, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 424, in async_set_swing_mode
    await self.hass.async_add_executor_job(self.set_swing_mode, swing_mode)
  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 204, in set_swing_mode
    self._fujitsu_device.changeSwingMode(swing_mode)
  File "/config/deps/lib/python3.7/site-packages/pyfujitsu/splitAC.py", line 125, in changeSwingMode
    self.af_vertical_direction = 1
  File "/config/deps/lib/python3.7/site-packages/pyfujitsu/splitAC.py", line 335, in af_vertical_direction
    self._api._set_device_property(self.af_vertical_direction['key'],properties)
TypeError: 'NoneType' object is not subscriptable

@qwackers awesome - you did it!

The swing mode function was part of my new implementation and perfectly works perfectly well with my AC model, but produced (most of) the errors you and @Justin_Young had.

I can not give you much more support here, because the swing mode interface on your model seems to be different than mine.
But I will add an config option here to disable swing mode on UI for all users having a unsupported model.

Hi @philwilldo,

It’s now working for me as well. Initially it did seem that there were some issues changing the operation mode, but that seems to have come right for me. I found that once I had turned on the unit with a particular operation mode it wouldn’t let me change it, but this morning on a different browser it seems to be working okay.

Regarding the swing mode, that was not working for me in the old version either. We may need some input from @Mmodarre about how he reverse engineered the API.

@philwilldo,

Not sure if it helps or not but the unit I have seems to have 9 settings (1-8 & swing) as follows.

image

@Justin_Young @qwackers I might provide the postman set I created and used for reverse engineering to you?

@qwackers This is a valuable information but unfortunately does not help much in terms of technical API names.

Hi @philwilldo, would it be possible to include the postman set in the github repo so anyone interested could take a look? I haven’t messed around with Postman to know if this is possible.

Hi @philwilldo same question as @Justin_Young , any chance you can share the postman set and we may be able to crack this for more A/C units.

Hi @Justin_Young & @qwackers,
sorry for the delay. Had a hard time at work. I dont like to publish the postman collections publicly but I’d love to share in private with you both if you are still interested?

Hi Phil,
I know the feeling slammed at work myself :slight_smile: I would love to give it a go so sure if you can share privately that would be great.

Hey Fujitsu users,

Has the FGLair app stopped working for you?

Not asking on the integration just the FGLair App in general - which has stopped for me since days now.

Thanks Simon

Hi @qwackers,

My one is working.

My FGlair app is working. (EU - NL)

My airco has been installed this week, so trying everything out at the moment

Can’t get it fglair connected in google home app :frowning:

Tried to get the platform to work on the lattest hassio version.
I used https://github.com/Mmodarre/pyfujitsu_for_homeassistant

But i always get the next error.

Platform error climate.fujitsu_general_heatpump - Integration fujitsu_general_heatpump not found.