Skip to content

Vaseemes/azrouter_HA

Repository files navigation

ko-fi

AZrouter_HA

Two very basic Python scripts that are reading values from AZrouter device and are adding them to HomeAssistant.

!!! THESE SCRIPTS ARE NOT RUNNING IN THE HOMEASSISTANT. YOU CAN START THEM UP ON SEPARATE WINDOWS MACHINE/SERVER AND LEAVE THEM RUNNING !!!

Requirements

Python installed
Python Playwright package installed
Samba Share addon in Home Assistant running

Goal/Scope

Reading values from AZrouter SMART

  • Consumption/production from/to grid
  • Power to boiler
  • Boiler temperature

Installation

Install latest Python
After installing Python, open command line and write:

py -m pip install playwright

You can then close the command line.
Next in HA install Samba Share addon and set it up (username, password)

Now we need to add files to HA

You can put these files in whatever folder in the HA installation you want, but if you do, you need to define that path in the .pyw files.
Access your HA via Windows (Samba share) and in folder "/config/www/" create three empty files:
azrouter.txt
azrouter_bojler_nahrivani.txt
azrouter_bojler.txt

Download and open the .pyw files from this repository. Open the "combined azrouter.pyw" in notepad or IDE of your choice.
Here you need to change these:

username = "YOUR-USERNAME"
password = "YOUR-PASSWORD"

Replace "YOUR-USERNAME" and "YOUR-PASSWORD" with the azrouter.local login details.
In this file you also need to change IP of your HomeAssistant here:

output_file_path = "//YOUR-HA-IP_ADDRESS/config/www/azrouter.txt"
output_file_path2 = "//YOUR-HA-IP_ADDRESS/config/www/azrouter_bojler_nahrivani.txt"

Do the same for the "azrouter_bojler.pyw" file.

Now we need add to these values to HA

Open configuration.yaml and add these:

sensor:

  - platform: file
    name: WHATEVER NAME YOU WANT
    file_path: /config/www/azrouter.txt
    unit_of_measurement: "W"
    scan_interval: 5

  - platform: file
    name: WHATEVER NAME YOU WANT
    file_path: /config/www/azrouter_bojler.txt
    unit_of_measurement: "°C"
    scan_interval: 120

  - platform: file
    name: WHATEVER NAME YOU WANT
    file_path: /config/www/azrouter_bojler_nahrivani.txt
    unit_of_measurement: "W"
    scan_interval: 5
    

The boiler temperature reading and power that is going to the boiler are now ready to use in HA.
But if you want to measure consumption/production from/to the grid you also need to create template sensors and helpers. Here is the idea of the code for template sensors you can use:

template:

  - sensor:
      - name: "Consumption times minus 1"
        unit_of_measurement: "W"
        state_class: measurement
        device_class: power
        unique_id: "sensor.consumption_times_minus_one"
        state: >
          {% set power = (states('sensor.consumption') | float)*-1 %}
          {{ 0 if power < 0 else power }}

  - sensor:
      - name: "Export electricity"
        unit_of_measurement: "W"
        state_class: measurement
        device_class: power
        unique_id: "senzor.export_electricity"
        state: >
          {% set power = (states('sensor.consumption') | float)%}
          {{ 0 if power < 0 else power }}

AZ Router returns both plus and minus values. That's why we need to use times -1 in the first sensor and values only higher than 0. This is the consumption from the grid.

The second sensor gives us value of the power export.

If you want to use these sensors in the Energy card or elsewhere to measure Energy in Wh, kWh you need to create helper Riemann sum integral (https://www.home-assistant.io/integrations/integration/) Setup is pretty straightforward, so I won't go into the detail.

Examples/Use case

Power Flow Card Plus

https://github.com/flixlix/power-flow-card-plus


My Remote Image

Energy Card


My Remote Image

About

Reading values from AZrouter SMART

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages