MyAir AC Zoning System, climate and Room Association for Components

Awesome, if you’re happy with the API then that sounds good enough for me. Even if its not home assistant, a decent API is important.

I’ll make it happen :wink:

I have continued working on getting my system into HA… whilst @smallsam’s library is a great start, the lack of a zone-aware climate component really makes it difficult to integrate.

So I took the easy way out and used switches and sliders backed by curl commands, and a modified RESTful sensor by @mad_ady that stores multiple values from a REST call (jsonrest.py) to stitch it together.

And I do mean stitch: it probably isn’t the best way to do it, and sometimes my API requests timeout (unsure if it’s my wifi or not), but it’s a base that someone can build on…

I used a single shell command and build the JSON in the automations, so in future I can make an automation to turn on all bedrooms (for example), and send all zone open requests in the one JSON string, as opposed to multiple requests, which may overwhelm the tablet. Also, consistent naming of sensors/switches/input_number entities is important, as some string replacements are executed to reduce the number of automations required.

So, in configuration.yaml:

shell_command:
  myair_setcmd: 'curl -X GET http://192.168.0.97:2025/setAircon?json={{json}}'

sensor:
  - platform: jsonrest
    resource: http://192.168.0.97:2025/getSystemData
    name: myair
  - platform: template
    sensors:
      myair_state:
        friendly_name: AC State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.info["state"] }}'
      myair_fanspeed:
        friendly_name: AC Fan Speed
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.info["fan"] }}'
      myair_mode:
        friendly_name: AC Mode
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.info["mode"] }}'
      myair_settemp:
        friendly_name: AC Set Temperature
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.info["setTemp"] }}'
      myair_zone1_state:
        friendly_name: Zone 1 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z01["state"] }}'
      myair_zone1_cover:
        friendly_name: Zone 1 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z01["value"] }}'
      myair_zone2_state:
        friendly_name: Zone 2 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z02["state"] }}'
      myair_zone2_cover:
        friendly_name: Zone 2 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z02["value"] }}'
      myair_zone3_state:
        friendly_name: Zone 3 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z03["state"] }}'
      myair_zone3_cover:
        friendly_name: Zone 3 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z03["value"] }}'
      myair_zone4_state:
        friendly_name: Zone 4 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z04["state"] }}'
      myair_zone4_cover:
        friendly_name: Zone 4 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z04["value"] }}'
      myair_zone5_state:
        friendly_name: Zone 5 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z05["state"] }}'
      myair_zone5_cover:
        friendly_name: Zone 5 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z05["value"] }}'
      myair_zone6_state:
        friendly_name: Zone 6 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z06["state"] }}'
      myair_zone6_cover:
        friendly_name: Zone 6 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z06["value"] }}'
      myair_zone7_state:
        friendly_name: Zone 7 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z07["state"] }}'
      myair_zone7_cover:
        friendly_name: Zone 7 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z07["value"] }}'
      myair_zone8_state:
        friendly_name: Zone 8 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z08["state"] }}'
      myair_zone8_cover:
        friendly_name: Zone 8 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z08["value"] }}'
      myair_zone9_state:
        friendly_name: Zone 9 A/C Zone State
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z09["state"] }}'
      myair_zone9_cover:
        friendly_name: Zone 9 A/C Zone Airflow
        value_template: '{{ states.sensor.myair.attributes.aircons.ac1.zones.z09["value"] }}'

switch:
  - platform: command_line
    switches:
      myair_power:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22info%22:%7B%22state%22:%22on%22%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22info%22:%7B%22state%22:%22off%22%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_state', 'on') }}"
      myair_zone1:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z01%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z01%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone1_state', 'open') }}"
      myair_zone2:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z02%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z02%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone2_state', 'open') }}"
      myair_zone3:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z03%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z03%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone3_state', 'open') }}"
      myair_zone4:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z04%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z04%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone4_state', 'open') }}"
      myair_zone5:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z05%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z05%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone5_state', 'open') }}"
      myair_zone6:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z06%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z06%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone6_state', 'open') }}"
      myair_zone7:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z07%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z07%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone7_state', 'open') }}"
      myair_zone8:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z08%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z08%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone8_state', 'open') }}"
      myair_zone9:
        command_on: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z09%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
        command_off: 'curl -X GET http://192.168.0.97:2025/setAircon?json=%7B%22ac1%22:%7B%22zones%22:%7B%22z09%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
        command_state: '/bin/true'
        value_template: "{{ is_state('sensor.myair_zone9_state', 'open') }}"

input_select:
  myair_modeselect:
    name: Aircon Mode
    options:
     - cool
     - heat
     - vent
     - dry
    icon: mdi:air-conditioner
  myair_fanselect:
    name: Aircon Fan
    options:
     - low
     - medium
     - high
    icon: mdi:fan

input_number:
  myair_inputsettemp:
    name: Aircon Temp
    min: 16
    max: 32
    unit_of_measurement: ºC
    icon: mdi:thermometer
  myair_zone1:
    name: Zone 1 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone2:
    name: Zone 2 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone3:
    name: Zone 3 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone4:
    name: Zone 4 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone5:
    name: Zone 5 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone6:
    name: Zone 6 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone7:
    name: Zone 7 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone8:
    name: Zone 8 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone9:
    name: Zone 9 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan

And the automations to tie it all together (including updating H-A switch/slider states if changes are made using the MyPlace app), automations.yaml:

- id: setmyairmodeselector
  alias: Set MyAir Mode Selector
  initial_state: True
  trigger:
    platform: state
    entity_id: sensor.myair_mode
  action:
    service: input_select.select_option
    entity_id: input_select.myair_modeselect
    data_template:
      option: '{{ states.sensor.myair_mode.state }}'
- id: setmyairacmode
  alias: Set MyAir AC mode
  initial_state: True
  trigger:
    entity_id: input_select.myair_modeselect
    platform: state
  action:
    service: shell_command.myair_setcmd
    data_template:
      json: '%7B%22ac1%22:%7B%22info%22:%7B%22mode%22:%22{{ states.input_select.myair_modeselect.state }}%22%7D%7D%7D'
- id: setmyairfanselector
  alias: Set MyAir Fan Selector
  initial_state: True
  trigger:
    platform: state
    entity_id: sensor.myair_fanspeed
  action:
    service: input_select.select_option
    entity_id: input_select.myair_fanselect
    data_template:
      option: '{{ states.sensor.myair_fanspeed.state }}'
- id: setmyairacfan
  alias: Set MyAir AC fan
  initial_state: True
  trigger:
    entity_id: input_select.myair_fanselect
    platform: state
  action:
    service: shell_command.myair_setcmd
    data_template:
      json: '%7B%22ac1%22:%7B%22info%22:%7B%22fan%22:%22{{ states.input_select.myair_fanselect.state }}%22%7D%7D%7D'
- id: setmyairtempselector
  alias: Set MyAir Temp Selector
  initial_state: True
  trigger:
    platform: state
    entity_id: sensor.myair_settemp
  action:
    service: input_number.set_value
    entity_id: input_number.myair_inputsettemp
    data_template:
      value: '{{ states.sensor.myair_settemp.state }}'
- id: setmyairacTemp
  alias: Set MyAir AC Temp
  initial_state: True
  trigger:
    entity_id: input_number.myair_inputsettemp
    platform: state
  action:
    service: shell_command.myair_setcmd
    data_template:
      json: '%7B%22ac1%22:%7B%22info%22:%7B%22setTemp%22:%22{{ states.input_number.myair_inputsettemp.state }}%22%7D%7D%7D'
- id: setmyairzoneairflow
  alias: Set MyAir Zone Airflow
  trigger:
    entity_id: input_number.myair_zone1,input_number.myair_zone2,input_number.myair_zone3,input_number.myair_zone4,input_number.myair_zone5,input_number.myair_zone6,input_number.myair_zone7,input_number.myair_zone8,input_number.myair_zone9
    platform: state
  action:
    service: shell_command.myair_setcmd
    data_template:
      json: '%7B%22ac1%22:%7B%22zones%22:%7B%22{{ trigger.entity_id|replace("input_number.myair_zone","z0") }}%22:%7B%22value%22:%22{{ trigger.to_state.state | int }}%22%7D%7D%7D%7D'
- id: setmyairzoneflowselector
  alias: Set MyAir Zone Airflow Selector
  trigger:
    entity_id: sensor.myair_zone1_cover,sensor.myair_zone2_cover,sensor.myair_zone3_cover,sensor.myair_zone4_cover,sensor.myair_zone5_cover,sensor.myair_zone6_cover,sensor.myair_zone7_cover,sensor.myair_zone8_cover,sensor.myair_zone9_cover
    platform: state
  action:
    service: input_number.set_value
    data_template:
      entity_id: '{{ trigger.entity_id | replace("sensor.","input_number.") | replace("_cover","") }}'
      value: >
        {% if trigger.entity_id == "sensor.myair_zone1_cover" %}
          {{ states.sensor.myair_zone1_cover.state|float }}
        {% elif trigger.entity_id == "sensor.myair_zone2_cover" %}
          {{ states.sensor.myair_zone2_cover.state|float }}
        {% elif trigger.entity_id == "sensor.myair_zone3_cover" %}
          {{ states.sensor.myair_zone3_cover.state|float }}
        {% elif trigger.entity_id == "sensor.myair_zone4_cover" %}
          {{ states.sensor.myair_zone4_cover.state|float }}
        {% elif trigger.entity_id == "sensor.myair_zone5_cover" %}
          {{ states.sensor.myair_zone5_cover.state|float }}
        {% elif trigger.entity_id == "sensor.myair_zone6_cover" %}
          {{ states.sensor.myair_zone6_cover.state|float }}
        {% elif trigger.entity_id == "sensor.myair_zone7_cover" %}
          {{ states.sensor.myair_zone7_cover.state|float }}
        {% elif trigger.entity_id == "sensor.myair_zone8_cover" %}
          {{ states.sensor.myair_zone8_cover.state|float }}
        {% elif trigger.entity_id == "sensor.myair_zone9_cover" %}
          {{ states.sensor.myair_zone9_cover.state|float }}
        {% endif %}

This is the base configuration to get it all in to HA, I haven’t hidden sensors, grouped entities into panels, started group automations etc. yet.

As for what it looks like… (blacked out zone names and unrelated sensors)
image

3 Likes

It seems that the jsonrest example I’m using may no longer be necessary. There’s a way to preserve JSON attributes with the stock RESTful plugin: https://home-assistant.io/components/sensor.rest/#fetch-multiple-json-values-and-present-them-as-attributes
You may want to look into it for future compatibility.

Thanks for sharing. is it also possible to set the turn off timer as well ? (eg- turn off in 30 minutes)

I’m sure it is, I haven’t implemented it though.

Awesome work on getting all that integrated! I’ve only just installed hass and have this same system so looking at something similar. A quick question on your comprehensive solution:

I was under the impression that the system’s airflow was managed automatically based on which zones you had active at any one time, so manually altering this would not be needed?

For my preferred type of use, it would be nice to simplify this down to perhaps a single input select with modes like ‘morning, weekend day, weekday, work from home day, evening, off’ that set all the zones and temperatures accordingly (kind of like manually triggering the ‘Plan’ functionality from the MyAir controller which is primarily how we use the system today). I will certainly have a go at this!

@mad_ady I’ve stopped using jsonrest, and querying the tablet directly from H-A due to timeouts causing all the sensors to go offline then come back. Now I have a script running on my H-A Pi that makes a request every 10s to the tablet and writes the JSON output to a file. My H-A is now using file senors to read the data in.

#!/bin/bash

while [ 1 ];
do
        MYAIRDATA=`curl http://192.168.0.97:2025/getSystemData 2>/dev/null`

        if [ $MYAIRDATA ];
        then
                echo $MYAIRDATA > /home/homeassistant/.homeassistant/myair.log
        fi

        sleep 10
done

@ricochet - airflow may be managed automatically if you have temperature sensors in each zone. My install doesn’t ($100 per zone for the sensor - ridiculous!), so it has one setpoint for the whole system and you can adjust the flow manually. Those Xiaomi Mijia temperature/humidity sensors seem cheap enough so my plan is to investigate integrating a bunch of them and let H-A perform that airflow automation function.

You could certainly set a plan/scene using what I have done as a base - I have two custom switches called “Turn on bedrooms” and “Living zones only”, which turn a group of zones on/off as specified. You can bundle multiple settings in the one API request. For example, the switches

input_boolean:
  myair_livingzones:
    name: Living zones only
    initial: off
    icon: mdi:sofa
  myair_bedroomzones:
    name: Turn on bedrooms
    initial: off
    icon: mdi:hotel

And the automations they drive:

- id: setmyairlivingzones
  alias: Set Living Zones only
  initial_state: true
  hide_entity: true
  trigger:
    entity_id: input_boolean.myair_livingzones
    platform: state
    to: 'on'
  action:
    - service: shell_command.myair_setcmd
      data_template:
        json: '%7B%22ac1%22:%7B%22zones%22:%7B%22z01%22:%7B%22state%22:%22open%22%7D,%22z02%22:%7B%22state%22:%22close%22%7D,%22z03%22:%7B%22state%22:%22open%22%7D,%22z04%22:%7B%22state%22:%22close%22%7D,%22z05%22:%7B%22state%22:%22open%22%7D,%22z06%22:%7B%22state%22:%22close%22%7D,%22z07%22:%7B%22state%22:%22close%22%7D,%22z08%22:%7B%22state%22:%22open%22%7D,%22z09%22:%7B%22state%22:%22close%22%7D%7D%7D%7D'
    - service: homeassistant.turn_off
      entity_id: input_boolean.myair_livingzones
- id: setmyairbedrooms
  alias: Set Bedrooms on
  initial_state: true
  hide_entity: true
  trigger:
    entity_id: input_boolean.myair_bedroomzones
    platform: state
    to: 'on'
  action:
    - service: shell_command.myair_setcmd
      data_template:
        json: '%7B%22ac1%22:%7B%22zones%22:%7B%22z04%22:%7B%22state%22:%22open%22%7D,%22z06%22:%7B%22state%22:%22open%22%7D,%22z09%22:%7B%22state%22:%22open%22%7D%7D%7D%7D'
    - service: homeassistant.turn_off
      entity_id: input_boolean.myair_bedroomzones

Hope this helps!

1 Like

Perfect - thanks for the extra information, that’s very handy!

Re: temperature sensors, I didn’t even realise they were optional. When we got it quoted for install it wasn’t broken down by component so we did get one per zone as you suggested. $100 each is crazy though, I would have saved the $800 if I knew that!

Cheers

@speedst3r how or where do you run the script in your first step?

#!/bin/bash

while [ 1 ];
do
MYAIRDATA=curl http://192.168.0.97:2025/getSystemData 2>/dev/null

    if [ $MYAIRDATA ];
    then
            echo $MYAIRDATA > /home/homeassistant/.homeassistant/myair.log
    fi

    sleep 10

done

I run it with cron, on bootup of my RPi. (Running hassbian, script runs as the homeassistant user)

homeassistant@hass:~ $ crontab -l
@reboot /home/homeassistant/get-myair.sh &

Hey @speedst3r

Trying to get what you’ve done working on my newly installed system. Thanks for your work.

I’m getting stuck on the 255 character limit using either the jsonrest or the file method. I see a fair bit of talk about it in other threads and github issues that I’ve found, but haven’t found a solution for it (nor why such a small limit even exists).

How did you get around that issue?

Thanks

@ShonkyCH, I’m now using file-based sensors - as above, using a bash script with a loop to output the JSON to a file and then reading the values directly into individual sensors…

sensor:
  - platform: file
    name: myair_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.info["state"] }}'
  - platform: file
    name: myair_fanspeed
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.info["fan"] }}'
  - platform: file
    name: myair_mode
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.info["mode"] }}'
  - platform: file
    name: myair_settemp
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.info["setTemp"] }}'
  - platform: file
    name: myair_zone1_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z01["state"] }}'
  - platform: file
    name: myair_zone1_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z01["value"] }}'
  - platform: file
    name: myair_zone2_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z02["state"] }}'
  - platform: file
    name: myair_zone2_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z02["value"] }}'
  - platform: file
    name: myair_zone3_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z03["state"] }}'
  - platform: file
    name: myair_zone3_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z03["value"] }}'
  - platform: file
    name: myair_zone4_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z04["state"] }}'
  - platform: file
    name: myair_zone4_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z04["value"] }}'
  - platform: file
    name: myair_zone5_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z05["state"] }}'
  - platform: file
    name: myair_zone5_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z05["value"] }}'
  - platform: file
    name: myair_zone6_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z06["state"] }}'
  - platform: file
    name: myair_zone6_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z06["value"] }}'
  - platform: file
    name: myair_zone7_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z07["state"] }}'
  - platform: file
    name: myair_zone7_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z07["value"] }}'
  - platform: file
    name: myair_zone8_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z08["state"] }}'
  - platform: file
    name: myair_zone8_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z08["value"] }}'
  - platform: file
    name: myair_zone9_state
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z09["state"] }}'
  - platform: file
    name: myair_zone9_cover
    file_path: /home/homeassistant/.homeassistant/myair.log
    value_template: '{{ value_json.aircons.ac1.zones.z09["value"] }}'

Thanks. It was trying to parse the whole thing (I think). I have the sensors working including measured temp as I have the individual temperature sensors. It seems the value_json.aircons.ac1.info.setTemp doesn’t apply in that case.

So you need to look at the “value_json.aircons.ac1.info.myZone” and then pick value_json.aircons.ac1.zones.zxx.setTemp based on that.

Whilst the interface is fairly simple, getting all the values switches etc into HA might be a little complicated.

Can I ask what aircons you guys are controlling with this?

I have a Toshiba with the RBC-AMS54E-ES controller and a seperate zone controller.
Had looked at the Intesis wifi controllers but I would have to replace the existing wall controller… so sussing other options, and the MyAir system seems like a winner (if I can find a dealer in SA).

I have a ducted 14kW single phase Panasonic unit connected to a MyAir 5. I had it installed with MyAir straight away along with the individual temperature sensors.

You’ll have to ask your local MyAir installers if they’d be happy to retrofit to your existing system, I’m sure they would though. In terms of sheer compatibility, probably easiest to contact Advantage Air support. I’ve called them on the phone once about some functionality (enabling economy mode, fyi not possible via myair) and they were quite helpful.

We’re still not there on great integration with Home Assistant yet. Aside from the pymyair python library and cli tool (which I hope still works) this commit is the sum total of my work to date on the home assistant integration: https://github.com/smallsam/home-assistant/commit/e346b6e4e339c350a4d3d6c26e65f09dc3ef7977
that I spent time on last year. Too little time to code these days and little motivation as it’s Winter…

1 Like

I’m not sure if you found the solution for the 255 character limitations. here is what i did:

  • platform: rest
    resource: http://192.168.8.104:2025/getSystemData
    name: myair
    json_attributes:
    • aircons
      value_template: ‘OK’
  • platform: template
    sensors:
    myair_state:
    friendly_name: AC State
    value_template: ‘{{ states.sensor.myair.attributes.aircons.ac1.info[“state”] }}’
    myair_fanspeed:
    friendly_name: AC Fan Speed
    value_template: ‘{{ states.sensor.myair.attributes.aircons.ac1.info[“fan”] }}’
    myair_mode:
    friendly_name: AC Mode
    value_template: ‘{{ states.sensor.myair.attributes.aircons.ac1.info[“mode”] }}’
    […]

I have tried above code, but it doesnt look like it’s working. i still get error in my automation jobs saying that we have exceeded character limitations. @dennis-au - did you get this to work in your own myair system ?

Hi All

Interesting reading about the integration of MyAir5 into HA. I’m looking at investing in an Advantage Air solution and potentially picking up the MyPlace solution with integrations into MyAir and MyLight.

I’ve just registered for the forum and keen to start looking at the API.

Great to see lots of interest and passion integrating the solution into HA.

I just thought I’d touch base and see if there is any recent progress with a component for HA from either @smallsam or @speedst3r? Great work guys on your efforts to date!!!

So if it helps anyone, this is my setup for my six zone MyAir system. This is based heavily on the work of @speedst3r with some modifications to get around the REST 255 character limit and so on. *EDIT corrected missing shell_command for Configuration.yaml.

Configuration.yaml:

input_select:
  myair_modeselect:
    name: Mode
    options:
     - cool
     - heat
     - vent
     - dry
    icon: mdi:air-conditioner
  
  myair_fanselect:
    name: Fan
    options:
     - low
     - medium
     - high
    icon: mdi:fan

input_number:
  myair_inputsettemp:
    name: Temp
    min: 16
    max: 32
    step: 1
    unit_of_measurement: C
    icon: mdi:thermometer
  myair_zone1:
    name: Zone 1 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone2:
    name: Zone 2 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone3:
    name: Zone 3 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone4:
    name: Zone 4 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone5:
    name: Zone 5 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan
  myair_zone6:
    name: Zone 6 Airflow
    min: 5
    max: 100
    unit_of_measurement: "%"
    step: 5
    icon: mdi:fan

#    Shell command for air conditioner control
shell_command:
  myair_setcmd: 'curl -X GET http://your_unit's_ip_address:2025/setAircon?json={{json}}'

Sensors.yaml:

- platform: rest
  resource: http://192.168.0.140:2025/getSystemData
  name: ac_json
  scan_interval: 10
  json_attributes:
    - aircons
  value_template: '{{ value_json.value }}'
- platform: template
  sensors:
    ac_power:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.info.state }}"
    ac_temp:
      value_template: "{{ '%.0f'%(states.sensor.ac_json.attributes.aircons.ac1.info.setTemp) | float }}"
    ac_mode:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.info.mode }}"
    ac_fan:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.info.fan }}"
    ac_vent_master_state:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.zones.z01.state }}"
    ac_vent_front_state:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.zones.z02.state }}"
    ac_vent_middle_state:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.zones.z03.state }}"
    ac_vent_rear_state:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.zones.z04.state }}"
    ac_vent_theatre_state:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.zones.z05.state }}"
    ac_vent_living_state:
      value_template: "{{ states.sensor.ac_json.attributes.aircons.ac1.zones.z06.state }}"

Switches.yaml:

- platform: template
  switches:
    ac_power:
      friendly_name: AC Power
      value_template: "{{ is_state('sensor.ac_power', 'on') }}"
      turn_on:
        service: shell_command.myair_setcmd
        data_template:
          json: '%7B%22ac1%22:%7B%22info%22:%7B%22state%22:%22on%22%7D%7D%7D'
      turn_off:
        service: shell_command.myair_setcmd
        data_template:
          json: '%7B%22ac1%22:%7B%22info%22:%7B%22state%22:%22off%22%7D%7D%7D'

Automations.yaml:

- id: setmyairmodeselector
  alias: Set MyAir Mode Selector
  initial_state: true
  trigger:
    platform: state
    entity_id: sensor.ac_mode
  action:
    service: input_select.select_option
    entity_id: input_select.myair_modeselect
    data_template:
      option: '{{ states.sensor.ac_mode.state }}'
- id: setmyairacmode
  alias: Set MyAir AC mode
  initial_state: true
  trigger:
    entity_id: input_select.myair_modeselect
    platform: state
  action:
  - service: homeassistant.update_entity
    entity_id: sensor.ac_mode
  - service: shell_command.myair_setcmd
    data_template:
      json: '%7B%22ac1%22:%7B%22info%22:%7B%22mode%22:%22{{ states.input_select.myair_modeselect.state
        }}%22%7D%7D%7D'
  - delay: 00:00:07
  - service: homeassistant.update_entity
    entity_id: sensor.ac_mode
- id: setmyairfanselector
  alias: Set MyAir Fan Selector
  initial_state: true
  trigger:
    platform: state
    entity_id: sensor.ac_fan
  action:
    service: input_select.select_option
    entity_id: input_select.myair_fanselect
    data_template:
      option: '{{ states.sensor.ac_fan.state }}'
- id: setmyairacfan
  alias: Set MyAir AC fan
  initial_state: true
  trigger:
    entity_id: input_select.myair_fanselect
    platform: state
  action:
  - service: homeassistant.update_entity
    entity_id: sensor.ac_fan
  - service: shell_command.myair_setcmd
    data_template:
      json: '%7B%22ac1%22:%7B%22info%22:%7B%22fan%22:%22{{ states.input_select.myair_fanselect.state
        }}%22%7D%7D%7D'
  - delay: 00:00:07
  - service: homeassistant.update_entity
    entity_id: sensor.ac_fan
- id: setmyairtempselector
  alias: Set MyAir Temp Selector
  initial_state: true
  trigger:
    platform: state
    entity_id: sensor.ac_temp
  action:
    service: input_number.set_value
    entity_id: input_number.myair_inputsettemp
    data_template:
      value: '{{ states.sensor.ac_temp.state }}'
- id: setmyairacTemp
  alias: Set MyAir AC Temp
  initial_state: true
  trigger:
    entity_id: input_number.myair_inputsettemp
    platform: state
  action:
  - service: homeassistant.update_entity
    entity_id: sensor.ac_temp
  - service: shell_command.myair_setcmd
    data_template:
      json: '%7B%22ac1%22:%7B%22info%22:%7B%22setTemp%22:%22{{ states.input_number.myair_inputsettemp.state
        }}%22%7D%7D%7D'
  - delay: 00:00:07
  - service: homeassistant.update_entity
    entity_id: sensor.ac_temp
- id: ac_power
  alias: AC Power
  trigger:
    entity_id: switch.ac_power
    platform: state
  action:
  - service: homeassistant.update_entity
    entity_id: sensor.ac_power
  - delay: 00:00:07
  - service: homeassistant.update_entity
    entity_id: sensor.ac_power

It’s taken me some time to get this working and, as others have mentioned, this setup suffers from lag when updating states, however I’m happy to live with this until I can look at doing something better - and that will take some learning. In the meantime, my biggest issue has been locating everything I need in one post so thought I should share.

4 Likes

This is helpful, thanks. Good to see this thread has survived for a while. I have an eZone which is Advantage Air’s entry level platform… I was wondering if it would offer any of the same API capability as their higher end MyAir tools. Not sure yet but i’m keen to have a play around. I’ve set a MAC address reservation for my A/C on my router and I see the output when I navigate to the device on port 2025. Hopefully it’ll take on/off and zone fan speed commands as i’m not trying to do anything fancy!

Edit: Just had a look through the API document on the Advantage Air forum and I managed to switch my AC off and on via the URL using the commands there. This is my first step into a larger world! :open_mouth: