Atrea ventilation - Custom component

Hey there,

I have an Atrea ventilation unit at my home with an RD5 ethernet controller.

After a bit of reverse engineering the communication between rd5 and web commands, I created a python library to make issuing commands a lot easier.
Later on, I built a HomeAsssistant custom component which I am now sharing with you after a month or two of testing.

I tried to follow all the guidelines to create a properly written component that could be eventually merged into the core of home assistant (I will appreciate any tips here :slight_smile: ). I consider myself to be still pretty new to python though :slight_smile:

I tested this with Atrea ECV 280 and multiple FW versions up to the most recent available for my RD5 controller, 2.01.32.

Please let me know what you think and any tips on how to improve!

Juraj

3 Likes

Hi Juraj,

I am testing your component on RA5 (with heaitng). Everything works! Great job and big thanks! I have a minor difference, my unit sends temperature value of the heat exchanger instead of indoor temperature sensor.

Is it possible to control the HVAC unti in HA automations?
Is it possible to get the value readings as sensors (to be recorded in InfluxDb)?

Hey, sorry for the late response, didn’t notice your post. I am glad to hear everything is working for you.

There are 3 temperatures reported by the unit:

  • outside_temp
  • inside_temp
  • supply_air_temp
    Does that mean that your supply_air_temp is the same as inside_temp?

Is it possible to control the HVAC unti in HA automations?

Yes, you can use climate. entities as on any other climate unit. Supported services are:

  • climate.set_hvac_mode
  • climate.set_preset_mode
  • climate.set_temperature
  • climate.turn_off
  • climate.turn_on

Is it possible to get the value readings as sensors (to be recorded in InfluxDb)?

Sure, you can export any climate property as usual in Home Assistant, an example in configuration.yaml:

sensor:
  - platform: template
    sensors:
      atrea_outside_temp:
        friendly_name: "Atrea Outside Temperature"
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('climate.atrea', 'outside_temp') }}"

Thanks for reply and sorry for silly questions, I am a noob :). Your direction for the services and sensors helped me a lot!

I have checked the status of the entity and this is what I get:

hvac_modes:
  - 'off'
  - auto
  - fan_only
min_temp: 10
max_temp: 40
fan_modes:
  - 12%
  - 20%
  - 30%
  - 40%
  - 50%
  - 60%
  - 70%
  - 80%
  - 90%
  - 100%
preset_modes:
  - 'Off'
  - Automat
  - Ventilation
  - Circulation and Ventilation
  - Circulation
  - Night precooling
  - Disbalance
  - Overpressure
current_temperature: 38.8
temperature: 23
fan_mode: 33%
preset_mode: Circulation
outside_temp: 3.5
inside_temp: 126
supply_air_temp: 38.8
requested_temp: 23
requested_power: 33
warnings: []
unit_of_measurement: Status
friendly_name: Atrea
icon: 'mdi:alert-decagram'
supported_features: 25

current_temperature shows the same value as supply_air_temp and also as the component’s visual (the big number inside the circle).
I believe that supply_air_temp is measured inside the unit. So if the unit comes with heating feature, that will not correspond to the real ambient temperature, when the unit is heating.
For ambient temperature measurement, there is a sensor inside the unit’s touch screen. Perhaps it should be reported by inside_temp, but in the posted status it shows 126 :thinking: (unit’s touchscreen shows 22.2).

Seems like your unit uses a different memory address for the temperature. There is no official documentation for the API so I am basically reverse-engineering it all. What is the exact model of the unit?

I might be able to fix this but I need some more information for debugging from you.

Please do the following on your PC (not Home Assistant):

  • Install python3
  • Install pyatrea module with console/terminal pip “pip install pyatrea” or “pip3 install pyatrea”
  • Create a new file, debug.py with following content (please change IP and password to your atrea unit):
import pyatrea

atrea = pyatrea.Atrea("atrea IP","your atrea password")

status = atrea.getStatus()
if(status == False):
    exit("Authentication failed")

for id, value in status.items():
    print(id + " - " + atrea.getTranslation(id) + ":" + value)
  • Sign in to your atrea web interface through web browser
  • Turn on the unit and let it start so that you can see the temperatures via UI on the webpage

The script above outputs everything that is currently saved/provided by the unit, we are trying to figure out the correct addresses for the outside, inside and supply air temperatures.

Now the important step:
Run the script by executing “python3 debug.py” and note down the temperatures shown in the user interface of the unit.

There should be a memory address which has the same value as temperature shown in the UI, multiplied by 10. (Example: I10202 - The TEa temperature sensor value - the air temperature of the outside or indoor air (according the unit orientation setting):82 - this corresponds to 8.2 outside temperature on my unit)

When you are done, please send me all the reported temperatures you noted down (ideally also a screenshot) and the output of the script. This will help me figure out the difference between our units.

Ahoj Juraj :slight_smile:

I have managed to get the output from the unit. The model is Duplex RA5. Here is the text file: Atrea_output.txt


The temperatures are easy to find it in the output since there are also explanations to different sensors.

I10207 - The indoor temperature - measured by the inbuilt sensor in theCP Touch controller:219

The temperature “Teplota pirvodu” has fluctuated between taking a screenshot and running the script

I10200 - The TU1 temperature sensor value - the air temperature after the heat exchanger - supply or exhaust air according to the unit orientation.:381

Thank you for your info and research, it was very useful.
Thanks to the output you shared I compared it with my unit output and have determined an address of which value determines which address to read for indoor temp.

It’s a bit more complicated with those descriptions, they depend on the unit type, how is it installed and depending on values of different addresses, different addresses are read for data like indoor temperature.

Your unit should now be supported in the newest version 4.2 https://github.com/JurajNyiri/HomeAssistant-Atrea/releases/tag/4.2 . Please let me know how it goes.

Sorry for my late reply Juraj, the new version works perfectly. Thanks a lot for your great work!

Hi Juraj,

Have you noticed as well that Atrea handles negative temperature values in a pretty strange way? When it is minus outside, temperature sensor shows values above 6550.

I have compared the history of the sensor with weather service history and found out the following pattern:
CorrectTemp = (TempValue - 6550) * (-1)

I guess temperatures below -10, -20 etc. will have different constants than 6550 but I can’t figure that out since it was never below -10 this winter.

That’s really interesting.

I am not using the outside sensor for anything in the UI or automations so I did not notice. I have no way to test it now since it is never freezing anymore over here, I will check it out in the next winter, if I remember :slight_smile:

That being said, I just rolled out a fix that hopefully works, using your formula.

Thanks for help!

Thanks for the update!

I have figured out the weird temperature trying to create some Grafana charts :slight_smile:

BTW I admire your work of reverse engineering, I have accumulation tank which is on network and I would love create a component for it like you did for Atrea but I have no experience at all. Could you advise if it’s worth for total noob to start digging into it and if so where to start? :slight_smile:

Thank you :blush:

There are many ways how to approach reverse engineering. The first step is always to check if there is any api or a communication standard available from manufacturer, if not, see if anyone else has reverse engineered the service. If none of those are available, then its time for some reverse engineering:

Most common methods I use are (from the easiest to the hardest):

  1. In a case of webpage like Atrea, you can open network tab in chrome, do an action like setting a temperature and see what request has been done. Check the post data etc and try to figure out the logic behind it. Reading source code, for example in js files (if available) might be helpful too.
  2. Inspecting network traffic through fiddler as an example. If set up properly, you can also (most of the time) decrypt https traffic too. Another popular but more complicated method is doing this through wireshark.
  3. In a case of a mobile app, you can use method 2, unless an app uses certificate pinning. If that is the case, you need to decompile an app and edit byte code directly to disable certificate pinning. That gets a lot more complicated. You can also try using some automatic tools for this if your phone is rooted, but from my experience it does not work well.

Thanks for the advice, I will try out some stuff :slight_smile:

Unfortunatelly the formula for minus temperatures was not correct. This night it was freezing and the first value after 0 was -5989 (I guess that must have been when it was -1 outside). What would mean that the original value by reverse calculation was (-5989)*(-1)+6550=12448. That is completely different number than what I was getting a month ago. I am really puzzled now. Only that I figured out for sure is that the value shall not be multiplied by -1 as that reversed the trend… :frowning:

Hi Juraj,

I am quite new to HomeAssistant so my question might be lame, but I have installed yours atrea component, started it and set the IP and password in configuration.yaml but I dont see the atrea component anywhere. Could you give me some advice what to do to see dialogs as shown on your pictures, please?

Thanks,
Pavel

Hello Pavel,

All questions are very welcome :slight_smile:

After adding atrea to configuration.yaml and restarting your Home Assistant instance, you should be able to see climate.atrea inside Developer Tools -> States.

If it is there, you can add a new Thermostat card to your Lovelace by either using UI or YAML editor (https://www.home-assistant.io/lovelace/ or https://www.home-assistant.io/lovelace/yaml-mode/ - I highly recommend editing through UI). When adding that card, just choose climate.atrea as the entity and you should be good to go!

If you do not see atrea inside Developer Tools -> States or something is not working make sure to check Developer Tools -> Logs for any mention of Atrea.

Hello Juraj,

Thanks a lot for sharing this component! I’ve tried to set it up, but it does not seem to work with my Atrea unit. I don’t have RD5 controller, but the Atrea Duplex 390 that I have has an ethernet port directly in the main unit and hosts a simple web server.

I’ve done a bit of debugging around your Python library and it looks to me that the format of /config/xml.xml of your unit is completely different from mine. I’m judging that based on the fact that the Python library is specifically looking for nodes named “RD5” in the response (init.py:75) and there are none in /config/xml.xml of my unit.

Could you please paste here an example /config/xml.xml response from your unit? I would like to compare it to mine to determine whether it makes sense to try to tweak the code you’ve already implemented or whether I’ll need to start reverse engineering from scratch.

Thank you.

Hey,

this is how my web interface looks like:

The data inside XML are encapsulated within these RD5 tags:

Then inside those there are the values with registers, example:

<O I="I00000" V="90"/>

How does your look like? Maybe you just need to change that?

Interesting. My web UI looks the same (except that the logo on top left says “Commercial line Vario” instead of “Duplex”).

However the contents of /config/xml.xml have this general format:

<?xml version="1.0" encoding="UTF-8"?>
<PCOWEB t="2010-03-22 11:48 ">
    <PCO>
        <INTEGER_R>
            <O I="I00000" V="73"/>
            <!-- ... -->
        </INTEGER_R>
        <INTEGER_RW>
            <O I="H00200" V="0"/>
            <!-- ... -->
        </INTEGER_RW>
        <DIGITAL_R>
            <O I="D00000" V="0"/>
            <!-- ... -->
        </DIGITAL_R>
        <DIGITAL_RW>
            <O I="C00200" V="0"/>
            <!-- ... -->
        </DIGITAL_RW>
    </PCO>
</PCOWEB>

Since the format seems to be the same beside the names of top 2 nodes, I’ll try modifying your implementation and report back on whether I could get it to work.

Thanks!

In addition to different nodes in xml.xml, my Atrea unit also provides translations compressed using LZW.
I have made a PR to support both, while keeping the compatibility with previously already supported formats: https://github.com/JurajNyiri/pyatrea/pull/2

This adds at least a basic support for Duplex 390. I will need to do more testing to confirm that all values are correctly represented for my unit.

Thank you, this is truly awesome work!

I have added a comment to the PR there, lets continue discussion there :slight_smile: