Aldes Inspirair integration

There is any chance to add into the Home Assistant system an integration with Aldes Inspirair Control?
This ventilation system can be controlled via an app called AldesConnect.
Thank you

Iā€™m interested too if anybody did something.
Thanks.

I have managed to write part of the protocol on python. work still in progress. it will be cool is someone can write a plugin for HA.

from datetime import datetime as dt
import requests
import json

USERNAME = "USERNAME"
PASSWORD = "PASSWORD"
DELIMITER = "##$$%%&&**@@"
AUTO  = ["A"]
BOOST = ["Y"]
DAILY = ["V"]
def changeMode(deviceId,mode,token):
    url = f'https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/products/{deviceId}/commands'
    r = requests.post(
        url,
        json={
            "id": 1,
            "jsonrpc": "2.0",
            "method": "changeMode",
            "params": mode
        },
        headers={
            'Authorization': f'Bearer {token}',
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        }
    )
    if str(r).find("401") > 0:
        print(r)
        return
    parsed = r.json()
    print(json.dumps(parsed, indent=4, sort_keys=True))
    status = parsed["Status"]
    if status == 'SENT':
        print("Command sent successfully")
    else:
        print("command failed")

def getToken(username, password):
    url = 'https://aldesiotsuite-aldeswebapi.azurewebsites.net/oauth2/token/'
    r = requests.post(
        url,
        data={
            "grant_type": "password",
            "username": username,
            "password": password
        },
        headers={'content-type': "application/x-www-form-urlencoded"}
    )
    parsed = r.json()
    #print(json.dumps(parsed, indent=4, sort_keys=True))
    token = parsed["access_token"]
    expires_in = parsed["expires_in"]
    line = "date" + DELIMITER+dt.today().strftime("%m/%d/%Y,%H:%M:%S")+DELIMITER+"expires_in" + DELIMITER + str(expires_in) + DELIMITER + "token"+DELIMITER+token
    with open('token.txt','w') as f:
        f.write(line)
    return parsed["access_token"]


def getInfo(token):
    url = 'https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/notification/preferences'
    r = requests.get(
        url,
        headers={'Authorization': f'Bearer {token}'}
    )
    print(r)
    parsed = r.json()
    with open('userid.txt','w') as f:
        f.write(parsed["userId"])
    with open('deviceid.txt','w') as f:
        f.write(parsed["userProductPreferences"][0]["deviceId"])
    return [parsed["userId"], parsed["userProductPreferences"][0]["deviceId"]]


def getProduct(token):
    url = 'https://aldesiotsuite-aldeswebapi.azurewebsites.net/aldesoc/v5/users/me/products'
    r = requests.get(
        url,
        headers={'Authorization': f'Bearer {token}'}
    )
    parsed = r.json()
    print(json.dumps(parsed, indent=4, sort_keys=True))
    return parsed

def connect():
    with open('token.txt','r') as f:
        contents = f.read()
    line = contents.split(DELIMITER)
    #check if the token is still valid
    date = dt.strptime(line[1].rstrip(),"%m/%d/%Y,%H:%M:%S")
    expires_in = int(line[3].rstrip())
    today = dt.today()
    delta = today - date
    if delta.seconds >= expires_in:
        print("Token have expired, let get new one")
        token = getToken(USERNAME,PASSWORD)
        return token
    else:
        print("Token still valid, let's re-use it")
        token = line[5].rstrip()
        return token

1 Like

Glad to know that something is happening. Hope someone can look after this.

Thanks for posting this! I managed to create a flow in Nodered to control my Aldes Inspirair.
My only comment: ā€˜Aā€™ mode did nothing in my case. I found out that for schedule mode is Z and for guests mode is X (more boosted than boost :slight_smile: ).
Again, thanks!

This sound really interesting! Would you be so kind to share your node-red? I am also trying to look at it, but to a bit to novice to manage itā€¦ :stuck_out_tongue_winking_eye:
Thanks!

2nd that! Thank you

Hi guys,

I think I come a little late but here are you, a custom integration for Aldes :blush:

Check README.md to see features.

Thank @slimhammami for the Aldes API hints.

3 Likes

canā€™t wait to see it working in my place. I didnā€™t find any installation instruction. Should I install it via hacs? thank you

1 Like

Hi @nico1, since this is a custom integration (not an integration supported by HA), you have to install like custom component.

Copy the content of the repository in the directory config/custom_components/aldes and restart HA. Then the integration will be displayed in the list of integration searching by ā€œAldesā€.

Thanks a lot for this integration! :pray: :pray:

Unfortunatelly I am trying to figure out whatā€™s the problemā€¦
Here a couple of screeshoot

Logger: homeassistant.components.select
Source: custom_components/aldes/aldes/product.py:47
Integration: Select (documentation, issues)
First occurred: 14:47:08 (2 occurrences)
Last logged: 14:47:08

Error adding entities for domain select with platform aldes
Error while setting up aldes platform for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 619, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 533, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 571, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 539, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/select/__init__.py", line 93, in state
    if self.current_option is None or self.current_option not in self.options:
  File "/config/custom_components/aldes/select.py", line 27, in current_option
    return self.coordinator.product.get_display_mode()
  File "/config/custom_components/aldes/aldes/product.py", line 47, in get_display_mode
    raise ValueError(f'Mode {self._mode} is not managed, please report.')
ValueError: Mode Z is not managed, please report.

Should I configure anything else other than user name and password??

Hi,
have you solved in some way? Iā€™ve installed this custom integration, works till i change the password. After that even if reset the new password.

Thanks
Matteo

Solved!!!
one mode is missing. According with the android application Iā€™ve modified product.py with

_MODES ={
'Holydays' : HOLIDAY_MODE,
'Daily': 'V'
'Boost' : 'Y'
'Party': 'X'
'Air Prog' : 'Z'
}

Pay attention to the tab, in my code is missing

Bye
Matteo

Hi all and many (very many) thanks to @aalmazan for his amazing job!
Finally I found a way to integrate my InspirAIRĀ® Home S into my HA.

Just a little thing: is it a way to manage translate for the mode selector? I mean without edit ā€œproduct.pyā€ that following @Ueo77 advices for now is:

    _MODES = {
        'Holidays' : HOLIDAYS_MODE,
        'Daily'    : 'V',
        'Boost'    : 'Y',
        'Party': 'X',
        'Air Prog' : 'Z'
    }

    _DISPLAY_NAMES = {
        'INSPIRAIR_HOME_S' : 'InspirAIRĀ® Home S'
    }

Thanks to everyone that can help me.

Paolo

Thank you all, this post started this integration :slight_smile:

@pnet mode selector must be as a code so the fix must be done in this level. I did not know this new mode.

I have fixed the issue and others recently so download the new code from github and update your installations.

Please, for all, open issues in Github project for a better traceability and notifications management. I wil try to fix as soon as possible.

Great news @aalmazan,
as Iā€™m not (yet :laughing:) a guru of home assistant and HACS, how update should be done? completely manually? or from home assistant itself?
Since a couple of weeks it seems something is working wrong: this is the message on my integrations settings page:

Nuovo tentativo di configurazione: Oauth2Token.__init__() got an unexpected keyword argument 'needUpdate'

Iā€™m not sure if this can be an issue so I didnā€™t trace on github, but if you think that can be the case Iā€™ll do so.

Thanks again,

Paolo

I downloaded the whole ā€œaldesā€ folder from github, unzipped and saved in config/custom_component. I deleted the previous ā€œaldesā€ folder and then renamed the new ā€œhassio_aldes-master 4ā€ folder as ā€œaldesā€ likle the previous one. Then I restarted. Now I can see the new ā€œair progā€ mode.
Ciao paolo

Hi, sorry to kind of hijack this thread, but just so you know, Iā€™ve just published my Aldes integration which works so far with the T.One Air: GitHub - guix77/homeassistant-aldes: HomeAssistant Aldes integration - T.One Air

@aalmazan Sorry to create another project, I thought it was easier since we have different products and also I wanted to start from the HACS integration blueprint.

Hi @guix77, this is no the wayā€¦if each member of the comunity creates an integration for each product, the comunity would go crazy to find the solution for their products. Also, HA doesnt do it that way either.

In addition you have use some parts of my code without referencias my repository.

My repository is open for new code and add HACS support it is Ok.

Nevermind, do what you consider.

Hi @aalmazan,

Like I said Iā€™m sorry. It was just more efficient to start from an established template for me and your integration was focused on an other use case anyways.

There are many custom integrations that implement the same vendor in their own way, itā€™s not a problem as long as people donā€™t try to install both at the same time. Of course in Home Assistant Core, it canā€™t happen, but weā€™re not there.

I might have used parts of your code, I canā€™t remember. I just credited you but feel free to point them out in an issue on my repo if you want me to rewrite them.

Anyways, I donā€™t have outstanding interest into maintaining my integration, at least for now because Aldes Connect just sucks, honestly. Feel free to use anything I wrote to extend your integration, if helpful!