Integrazione inverter Voltronic su Home Assistant

Prerequisiti

Installazione software necessari

sudo apt install git cmake make build-essential libhidapi-hidraw0 libhidapi-libusb0 libhidapi-dev libserialport0 libserialport-dev pip
pip install inverterd
pip install paho-mqtt

Inverter-tools

Installazione

git clone https://github.com/gch1p/inverter-tools.git
cd inverter-tools/
git submodule update --init
mkdir build
cd build
cmake ..
make
sudo make install
sudo mv /usr/local/bin/bin/inverter* /usr/local/bin/
sudo touch /etc/default/inverterd
cd ..
sudo cp systemd/inverterd.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable inverterd.service
sudo systemctl start inverterd.service

Test

sudo inverterctl --device usb --format json get-protocol-id
{"result":"ok","data":{"id":18}}

sudo inverterctl --device usb --format json get-date-time
{"result":"ok","data":{"year":2022,"month":12,"day":31,"hour":15,"minute":25,"second":41}}

sudo inverterctl --device usb --format json get-total-generated
{"result":"ok","data":{"wh":1310279}}

sudo inverterctl --device usb --format json get-year-generated 2022
{"result":"ok","data":{"wh":1310283}}

sudo inverterctl --device usb --format json get-month-generated 2022 11
{"result":"ok","data":{"wh":236949}}

sudo inverterctl --device usb --format json get-day-generated 2022 12 30
{"result":"ok","data":{"wh":8957}}

sudo inverterctl --device usb --format json get-serial-number
{"result":"ok","data":{"sn":"96132111100444"}}

sudo inverterctl --device usb --format json get-cpu-version
{"result":"ok","data":{"main_v":"05229","slave1_v":"00000","slave2_v":"00000"}}

sudo inverterctl --device usb --format json get-rated
{"result":"error","message":"response is invalid: while parsing p18::response_type::RatedInformation: item 14 is expected to be 2 characters long, got 3 characters"}
#da questo errore presumibilmente perche' e' un sistema parallelo e vanno usati i comandi sotto

sudo inverterctl --device usb --format json get-status
{"result":"ok","data":{"grid_voltage":{"unit":"V","value":226.5},"grid_freq":{"unit":"Hz","value":50.1},"ac_output_voltage":{"unit":"V","value":230.3},"ac_output_freq":{"unit":"Hz","value":49.9},"ac_output_apparent_power":{"unit":"VA","value":1658},"ac_output_active_power":{"unit":"Wh","value":1621},"output_load_percent":{"unit":"%","value":33},"battery_voltage":{"unit":"V","value":45.3},"battery_voltage_scc":{"unit":"V","value":0.0},"battery_voltage_scc2":{"unit":"V","value":0.0},"battery_discharge_current":{"unit":"A","value":12},"battery_charge_current":{"unit":"A","value":0},"battery_capacity":{"unit":"%","value":43},"inverter_heat_sink_temp":{"unit":"°C","value":41},"mppt1_charger_temp":{"unit":"°C","value":0},"mppt2_charger_temp":{"unit":"°C","value":0},"pv1_input_power":{"unit":"Wh","value":1117},"pv2_input_power":{"unit":"Wh","value":0},"pv1_input_voltage":{"unit":"V","value":205.1},"pv2_input_voltage":{"unit":"V","value":0.0},"configuration_status":"Default","mppt1_charger_status":"Charging","mppt2_charger_status":"Abnormal","load_connected":"Connected","battery_power_direction":"Discharge","dc_ac_power_direction":"DC/AC","line_power_direction":"Do nothing","local_parallel_id":1}}

sudo inverterctl --device usb --format json get-p-rated 0
{"result":"ok","data":{"parallel_connection_status":"Existent","serial_number":"96132111100458","charge_source_priority":"Solar-only","max_charge_current":{"unit":"A","value":60},"max_ac_charge_current":{"unit":"A","value":50},"output_mode":"Parallel output"}}

sudo inverterctl --device usb --format json get-p-rated 1
{"result":"ok","data":{"parallel_connection_status":"Existent","serial_number":"96132111100444","charge_source_priority":"Solar-only","max_charge_current":{"unit":"A","value":60},"max_ac_charge_current":{"unit":"A","value":50},"output_mode":"Parallel output"}}

sudo inverterctl --device usb --format json get-p-status 0
{"result":"ok","data":{"parallel_connection_status":"Existent","mode":"Battery mode","fault_code":0,"grid_voltage":{"unit":"V","value":227.4},"grid_freq":{"unit":"Hz","value":50.0},"ac_output_voltage":{"unit":"V","value":229.4},"ac_output_freq":{"unit":"Hz","value":49.9},"ac_output_apparent_power":{"unit":"VA","value":1674},"ac_output_active_power":{"unit":"Wh","value":1619},"total_ac_output_apparent_power":{"unit":"VA","value":3361},"total_ac_output_active_power":{"unit":"Wh","value":3306},"output_load_percent":{"unit":"%","value":33},"total_output_load_percent":{"unit":"%","value":33},"battery_voltage":{"unit":"V","value":45.3},"battery_discharge_current":{"unit":"A","value":9},"battery_charge_current":{"unit":"A","value":0},"total_battery_charge_current":{"unit":"A","value":0},"battery_capacity":{"unit":"%","value":43},"pv1_input_power":{"unit":"Wh","value":1341},"pv2_input_power":{"unit":"Wh","value":0},"pv1_input_voltage":{"unit":"V","value":204.4},"pv2_input_voltage":{"unit":"V","value":0.0},"mppt1_charger_status":"Charging","mppt2_charger_status":"Abnormal","load_connected":"Connected","battery_power_direction":"Discharge","dc_ac_power_direction":"DC/AC","line_power_direction":"Do nothing"}}

sudo inverterctl --device usb --format json get-p-status 1
{"result":"ok","data":{"parallel_connection_status":"Existent","mode":"Battery mode","fault_code":0,"grid_voltage":{"unit":"V","value":225.1},"grid_freq":{"unit":"Hz","value":49.9},"ac_output_voltage":{"unit":"V","value":230.5},"ac_output_freq":{"unit":"Hz","value":50.0},"ac_output_apparent_power":{"unit":"VA","value":1797},"ac_output_active_power":{"unit":"Wh","value":1784},"total_ac_output_apparent_power":{"unit":"VA","value":3665},"total_ac_output_active_power":{"unit":"Wh","value":3536},"output_load_percent":{"unit":"%","value":35},"total_output_load_percent":{"unit":"%","value":35},"battery_voltage":{"unit":"V","value":44.9},"battery_discharge_current":{"unit":"A","value":16},"battery_charge_current":{"unit":"A","value":0},"total_battery_charge_current":{"unit":"A","value":0},"battery_capacity":{"unit":"%","value":39},"pv1_input_power":{"unit":"Wh","value":1150},"pv2_input_power":{"unit":"Wh","value":0},"pv1_input_voltage":{"unit":"V","value":187.0},"pv2_input_voltage":{"unit":"V","value":0.0},"mppt1_charger_status":"Charging","mppt2_charger_status":"Abnormal","load_connected":"Connected","battery_power_direction":"Discharge","dc_ac_power_direction":"DC/AC","line_power_direction":"Do nothing"}}

sudo inverterctl --device usb --format json get-mode
{"result":"ok","data":{"mode":"Battery mode"}}

sudo inverterctl --device usb --format json get-errors
{"result":"ok","data":{"fault_code":0,"line_fail":false,"output_circuit_short":false,"inverter_over_temperature":false,"fan_lock":false,"battery_voltage_high":false,"battery_low":false,"battery_under":false,"over_load":false,"eeprom_fail":false,"power_limit":false,"pv1_voltage_high":false,"pv2_voltage_high":false,"mppt1_overload_warning":false,"mppt2_overload_warning":false,"battery_too_low_to_charge_for_scc1":false,"battery_too_low_to_charge_for_scc2":false}}

sudo inverterctl --device usb --format json get-flags
{"result":"ok","data":{"buzzer":true,"overload_bypass":true,"escape_to_default_screen_after_1min_timeout":true,"overload_restart":false,"over_temp_restart":false,"backlight_on":true,"alarm_on_on_primary_source_interrupt":true,"fault_code_record":true}}

sudo inverterctl --device usb --format json get-rated-defaults
{"result":"ok","data":{"ac_output_voltage":{"unit":"V","value":230.0},"ac_output_freq":{"unit":"Hz","value":50.0},"ac_input_voltage_range":"Appliance","battery_under_voltage":{"unit":"V","value":40.8},"battery_bulk_voltage":{"unit":"V","value":56.4},"battery_float_voltage":{"unit":"V","value":54.0},"battery_recharge_voltage":{"unit":"V","value":46.0},"battery_redischarge_voltage":{"unit":"V","value":54.0},"max_charge_current":{"unit":"A","value":60},"max_ac_charge_current":{"unit":"A","value":30},"battery_type":"AGM","output_source_priority":"Solar-Utility-Battery","charge_source_priority":"Solar-and-Utility","solar_power_priority":"Battery-Load-Utility","machine_type":"Off-Grid-Tie","output_mode":"Single output","buzzer_flag":true,"overload_bypass_flag":true,"escape_to_default_screen_after_1min_timeout_flag":true,"overload_restart_flag":false,"over_temp_restart_flag":false,"backlight_on_flag":true,"alarm_on_on_primary_source_interrupt_flag":true,"fault_code_record_flag":false}}

sudo inverterctl --device usb --format json get-allowed-charge-currents
{"result":"ok","data":[10,20,30,40,50,60,70,80,90,100]}

sudo inverterctl --device usb --format json get-allowed-ac-charge-currents
{"result":"ok","data":[2,10,20,30,40,50,60,70,80,90,100]}

sudo inverterctl --device usb --format json get-ac-charge-time
{"result":"ok","data":{"start_time":"00:00","end_time":"00:00"}}

sudo inverterctl --device usb --format json get-ac-supply-time
{"result":"ok","data":{"start_time":"00:00","end_time":"00:00"}}

Broker MQTT

Installazione mosquitto

sudo apt install mosquitto

Modifica configurazione

sudo nano -w /etc/mosquitto/mosquitto.conf

Aggiungere

listener 1883
per_listener_settings true
allow_anonymous false
password_file /etc/mosquitto/pwfile

Creare l’utente

sudo mosquitto_passwd -c /etc/mosquitto/pwfile mqtt

inserire come password mqttpassword e riavviare il servizio

sudo service mosquitto restart

Script Python

creare il file inverter.py

nano -w inverter.py

e inserire il seguente codice (adattare per un solo inverter)

#!python3
from inverterd import Client, Format
import paho.mqtt.client as mqtt
import time
import json
from datetime import date

today = date.today()
d1 = today.strftime("%Y %m %d")

print("connessione all'inverter")
inverter_host="localhost"
inverter_client = Client(8305, inverter_host)
inverter_client.connect()
inverter_client.format(Format.JSON)
print("lettura dati da inverter")
dati = inverter_client.exec('get-p-status 0')
time.sleep(1)
dati2 = inverter_client.exec('get-p-status 1')
time.sleep(1)
dati3 = inverter_client.exec('get-total-generated')
time.sleep(1)
dati4 = inverter_client.exec('get-day-generated', (d1,))
time.sleep(1)
inverter1_status = json.loads(dati)
inverter2_status = json.loads(dati2)
inverter1_total_generated = json.loads(dati3)
inverter1_day_generated = json.loads(dati4)

def on_message(client, userdata, message):
    print("message received " ,str(message.payload.decode("utf-8")))
    print("message topic=",message.topic)
    print("message qos=",message.qos)
    print("message retain flag=",message.retain)

broker="localhost"
mqtt_client = mqtt.Client("inverter")
mqtt_client.username_pw_set(username="mqtt",password="mqttpassword")
mqtt_client.on_message=on_message
print("connessione al broker")
mqtt_client.connect(broker)
mqtt_client.loop_start()
print("publicazione dati")
mqtt_client.publish("homeassistant/inverter/inverter1/parallel_connection_status",inverter1_status['data']['parallel_connection_status'])
mqtt_client.publish("homeassistant/inverter/inverter1/mode",inverter1_status['data']['mode'])
mqtt_client.publish("homeassistant/inverter/inverter1/fault_code",inverter1_status['data']['fault_code'])
mqtt_client.publish("homeassistant/inverter/inverter1/grid_voltage",inverter1_status['data']['grid_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/grid_freq",inverter1_status['data']['grid_freq']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/ac_output_voltage",inverter1_status['data']['ac_output_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/ac_output_freq",inverter1_status['data']['ac_output_freq']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/ac_output_apparent_power",inverter1_status['data']['ac_output_apparent_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/ac_output_active_power",inverter1_status['data']['ac_output_active_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/total_ac_output_apparent_power",inverter1_status['data']['total_ac_output_apparent_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/total_ac_output_active_power",inverter1_status['data']['total_ac_output_active_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/output_load_percent",inverter1_status['data']['output_load_percent']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/total_output_load_percent",inverter1_status['data']['total_output_load_percent']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/battery_voltage",inverter1_status['data']['battery_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/battery_discharge_current",inverter1_status['data']['battery_discharge_current']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/battery_charge_current",inverter1_status['data']['battery_charge_current']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/total_battery_charge_current",inverter1_status['data']['total_battery_charge_current']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/battery_capacity",inverter1_status['data']['battery_capacity']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/pv1_input_power",inverter1_status['data']['pv1_input_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/pv2_input_power",inverter1_status['data']['pv2_input_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/pv1_input_voltage",inverter1_status['data']['pv1_input_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/pv2_input_voltage",inverter1_status['data']['pv2_input_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter1/mppt1_charger_status",inverter1_status['data']['mppt1_charger_status'])
mqtt_client.publish("homeassistant/inverter/inverter1/mppt2_charger_status",inverter1_status['data']['mppt2_charger_status'])
mqtt_client.publish("homeassistant/inverter/inverter1/load_connected",inverter1_status['data']['load_connected'])
mqtt_client.publish("homeassistant/inverter/inverter1/battery_power_direction",inverter1_status['data']['battery_power_direction'])
mqtt_client.publish("homeassistant/inverter/inverter1/dc_ac_power_direction",inverter1_status['data']['dc_ac_power_direction'])
mqtt_client.publish("homeassistant/inverter/inverter1/line_power_direction",inverter1_status['data']['line_power_direction'])
mqtt_client.publish("homeassistant/inverter/inverter2/parallel_connection_status",inverter2_status['data']['parallel_connection_status'])
mqtt_client.publish("homeassistant/inverter/inverter2/mode",inverter2_status['data']['mode'])
mqtt_client.publish("homeassistant/inverter/inverter2/fault_code",inverter2_status['data']['fault_code'])
mqtt_client.publish("homeassistant/inverter/inverter2/grid_voltage",inverter2_status['data']['grid_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/grid_freq",inverter2_status['data']['grid_freq']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/ac_output_voltage",inverter2_status['data']['ac_output_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/ac_output_freq",inverter2_status['data']['ac_output_freq']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/ac_output_apparent_power",inverter2_status['data']['ac_output_apparent_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/ac_output_active_power",inverter2_status['data']['ac_output_active_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/total_ac_output_apparent_power",inverter2_status['data']['total_ac_output_apparent_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/total_ac_output_active_power",inverter2_status['data']['total_ac_output_active_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/output_load_percent",inverter2_status['data']['output_load_percent']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/total_output_load_percent",inverter2_status['data']['total_output_load_percent']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/battery_voltage",inverter2_status['data']['battery_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/battery_discharge_current",inverter2_status['data']['battery_discharge_current']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/battery_charge_current",inverter2_status['data']['battery_charge_current']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/total_battery_charge_current",inverter2_status['data']['total_battery_charge_current']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/battery_capacity",inverter2_status['data']['battery_capacity']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/pv1_input_power",inverter2_status['data']['pv1_input_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/pv2_input_power",inverter2_status['data']['pv2_input_power']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/pv1_input_voltage",inverter2_status['data']['pv1_input_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/pv2_input_voltage",inverter2_status['data']['pv2_input_voltage']['value'])
mqtt_client.publish("homeassistant/inverter/inverter2/mppt1_charger_status",inverter2_status['data']['mppt1_charger_status'])
mqtt_client.publish("homeassistant/inverter/inverter2/mppt2_charger_status",inverter2_status['data']['mppt2_charger_status'])
mqtt_client.publish("homeassistant/inverter/inverter2/load_connected",inverter2_status['data']['load_connected'])
mqtt_client.publish("homeassistant/inverter/inverter2/battery_power_direction",inverter2_status['data']['battery_power_direction'])
mqtt_client.publish("homeassistant/inverter/inverter2/dc_ac_power_direction",inverter2_status['data']['dc_ac_power_direction'])
mqtt_client.publish("homeassistant/inverter/inverter2/line_power_direction",inverter2_status['data']['line_power_direction'])
mqtt_client.publish("homeassistant/inverter/inverter1/total-generated",(inverter1_total_generated['data']['wh']/1000))
mqtt_client.publish("homeassistant/inverter/inverter1/day-generated",(inverter1_day_generated['data']['wh']/1000))
time.sleep(4)
mqtt_client.loop_stop()
print("fine")

Modificare cron per l’esecuzione automatica

crontab -e

* * * * * ( /usr/bin/python3 ~/inverter.py )
* * * * * ( sleep 10 ; /usr/bin/python3 ~/inverter.py )
* * * * * ( sleep 20 ; /usr/bin/python3 ~/inverter.py )
* * * * * ( sleep 30 ; /usr/bin/python3 ~/inverter.py )
* * * * * ( sleep 40 ; /usr/bin/python3 ~/inverter.py )
* * * * * ( sleep 50 ; /usr/bin/python3 ~/inverter.py )

Home Assistant

configuration.yaml


mqtt:
  sensor:
    - name: "Fotovoltaico Inverter 1 Stato Parallelo"
      state_topic: "homeassistant/inverter/inverter1/parallel_connection_status"
    - name: "Fotovoltaico Inverter 1 Modo"
      state_topic: "homeassistant/inverter/inverter1/mode"
    - name: "Fotovoltaico Inverter 1 Codice Errore"
      state_topic: "homeassistant/inverter/inverter1/fault_code"
    - name: "Fotovoltaico Inverter 1 Tensione Rete"
      state_topic: "homeassistant/inverter/inverter1/grid_voltage"
      unit_of_measurement: V
      device_class: Voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Frequenza Rete"
      state_topic: "homeassistant/inverter/inverter1/grid_freq"
      unit_of_measurement: Hz
      device_class: Frequency
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Tensione"
      state_topic: "homeassistant/inverter/inverter1/ac_output_voltage"
      unit_of_measurement: V
      device_class: Voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Frequenza"
      state_topic: "homeassistant/inverter/inverter1/ac_output_freq"
      unit_of_measurement: Hz
      device_class: Frequency
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Potenza Apparente"
      state_topic: "homeassistant/inverter/inverter1/ac_output_apparent_power"
      unit_of_measurement: VA
      device_class: apparent_power
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Potenza Attiva"
      state_topic: "homeassistant/inverter/inverter1/ac_output_active_power"
      unit_of_measurement: W
      device_class: power
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Potenza Apparente Totale"
      state_topic: "homeassistant/inverter/inverter1/total_ac_output_apparent_power"
      unit_of_measurement: VA
      device_class: apparent_power
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Potenza Attiva Totale"
      state_topic: "homeassistant/inverter/inverter1/total_ac_output_active_power"
      unit_of_measurement: W
      device_class: power
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Percentuale Carico"
      state_topic: "homeassistant/inverter/inverter1/output_load_percent"
      unit_of_measurement: "%"
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Percentuale Carico Totale"
      state_topic: "homeassistant/inverter/inverter1/total_output_load_percent"
      unit_of_measurement: "%"
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Tensione Batteria"
      state_topic: "homeassistant/inverter/inverter1/battery_voltage"
      unit_of_measurement: V
      device_class: Voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Corrente Scarica Batteria"
      state_topic: "homeassistant/inverter/inverter1/battery_discharge_current"
      unit_of_measurement: A
      device_class: current
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Corrente Carica Batteria"
      state_topic: "homeassistant/inverter/inverter1/battery_charge_current"
      unit_of_measurement: A
      device_class: current
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Corrente Carica Batteria Totale"
      state_topic: "homeassistant/inverter/inverter1/total_battery_charge_current"
      unit_of_measurement: A
      device_class: current
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Capacità Batteria"
      state_topic: "homeassistant/inverter/inverter1/battery_capacity"
      unit_of_measurement: "%"
      device_class: battery
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Potenza Stringa 1"
      state_topic: "homeassistant/inverter/inverter1/pv1_input_power"
      unit_of_measurement: W
      device_class: power
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Potenza Stringa 2"
      state_topic: "homeassistant/inverter/inverter1/pv2_input_power"
      unit_of_measurement: W
      device_class: power
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Tensione Stringa 1"
      state_topic: "homeassistant/inverter/inverter1/pv1_input_voltage"
      unit_of_measurement: V
      device_class: voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Tensione Stringa 2"
      state_topic: "homeassistant/inverter/inverter1/pv2_input_voltage"
      unit_of_measurement: V
      device_class: voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 1 Stato Carica Stringa 1"
      state_topic: "homeassistant/inverter/inverter1/mppt1_charger_status"
    - name: "Fotovoltaico Inverter 1 Stato Carica Stringa 2"
      state_topic: "homeassistant/inverter/inverter1/mppt2_charger_status"
    - name: "Fotovoltaico Inverter 1 Carico Connesso"
      state_topic: "homeassistant/inverter/inverter1/load_connected"
    - name: "Fotovoltaico Inverter 1 Stato Batteria"
      state_topic: "homeassistant/inverter/inverter1/battery_power_direction"
    - name: "Fotovoltaico Inverter 1 Stato Inverter"
      state_topic: "homeassistant/inverter/inverter1/dc_ac_power_direction"
    - name: "Fotovoltaico Inverter 1 Stato Rete"
      state_topic: "homeassistant/inverter/inverter1/line_power_direction"
    - name: "Fotovoltaico Inverter 2 Stato Parallelo"
      state_topic: "homeassistant/inverter/inverter2/parallel_connection_status"
    - name: "Fotovoltaico Inverter 2 Modo"
      state_topic: "homeassistant/inverter/inverter2/mode"
    - name: "Fotovoltaico Inverter 2 Codice Errore"
      state_topic: "homeassistant/inverter/inverter2/fault_code"
    - name: "Fotovoltaico Inverter 2 Tensione Rete"
      state_topic: "homeassistant/inverter/inverter2/grid_voltage"
      unit_of_measurement: V
      device_class: Voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Frequenza Rete"
      state_topic: "homeassistant/inverter/inverter2/grid_freq"
      unit_of_measurement: Hz
      device_class: Frequency
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Tensione"
      state_topic: "homeassistant/inverter/inverter2/ac_output_voltage"
      unit_of_measurement: V
      device_class: Voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Frequenza"
      state_topic: "homeassistant/inverter/inverter2/ac_output_freq"
      unit_of_measurement: Hz
      device_class: Frequency
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Potenza Apparente"
      state_topic: "homeassistant/inverter/inverter2/ac_output_apparent_power"
      unit_of_measurement: VA
      device_class: apparent_power
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Potenza Attiva"
      state_topic: "homeassistant/inverter/inverter2/ac_output_active_power"
      unit_of_measurement: W
      device_class: power
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Potenza Apparente Totale"
      state_topic: "homeassistant/inverter/inverter2/total_ac_output_apparent_power"
      unit_of_measurement: VA
      device_class: apparent_power
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Potenza Attiva Totale"
      state_topic: "homeassistant/inverter/inverter2/total_ac_output_active_power"
      unit_of_measurement: W
      device_class: power
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Percentuale Carico"
      state_topic: "homeassistant/inverter/inverter2/output_load_percent"
      unit_of_measurement: "%"
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Percentuale Carico Totale"
      state_topic: "homeassistant/inverter/inverter2/total_output_load_percent"
      unit_of_measurement: "%"
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Tensione Batteria"
      state_topic: "homeassistant/inverter/inverter2/battery_voltage"
      unit_of_measurement: V
      device_class: Voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Corrente Scarica Batteria"
      state_topic: "homeassistant/inverter/inverter2/battery_discharge_current"
      unit_of_measurement: A
      device_class: current
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Corrente Carica Batteria"
      state_topic: "homeassistant/inverter/inverter2/battery_charge_current"
      unit_of_measurement: A
      device_class: current
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Corrente Carica Batteria Totale"
      state_topic: "homeassistant/inverter/inverter2/total_battery_charge_current"
      unit_of_measurement: A
      device_class: current
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Capacità Batteria"
      state_topic: "homeassistant/inverter/inverter2/battery_capacity"
      unit_of_measurement: "%"
      device_class: battery
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Potenza Stringa 1"
      state_topic: "homeassistant/inverter/inverter2/pv1_input_power"
      unit_of_measurement: W
      device_class: power
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Potenza Stringa 2"
      state_topic: "homeassistant/inverter/inverter2/pv2_input_power"
      unit_of_measurement: W
      device_class: power
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Tensione Stringa 1"
      state_topic: "homeassistant/inverter/inverter2/pv1_input_voltage"
      unit_of_measurement: V
      device_class: voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Tensione Stringa 2"
      state_topic: "homeassistant/inverter/inverter2/pv2_input_voltage"
      unit_of_measurement: V
      device_class: voltage
      state_class: measurement
    - name: "Fotovoltaico Inverter 2 Stato Carica Stringa 1"
      state_topic: "homeassistant/inverter/inverter2/mppt1_charger_status"
    - name: "Fotovoltaico Inverter 2 Stato Carica Stringa 2"
      state_topic: "homeassistant/inverter/inverter2/mppt2_charger_status"
    - name: "Fotovoltaico Inverter 2 Carico Connesso"
      state_topic: "homeassistant/inverter/inverter2/load_connected"
    - name: "Fotovoltaico Inverter 2 Stato Batteria"
      state_topic: "homeassistant/inverter/inverter2/battery_power_direction"
    - name: "Fotovoltaico Inverter 2 Stato Inverter"
      state_topic: "homeassistant/inverter/inverter2/dc_ac_power_direction"
    - name: "Fotovoltaico Inverter 2 Stato Rete"
      state_topic: "homeassistant/inverter/inverter2/line_power_direction"
    - name: "Fotovoltaico Inverter 1 Energia Generata Totale"
      state_topic: "homeassistant/inverter/inverter1/total-generated"
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing
    - name: "Fotovoltaico Inverter 1 Energia Generata Giornaliera"
      state_topic: "homeassistant/inverter/inverter1/day-generated"
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing

template:
  - sensor:
    - name: "Inverter 1 Potenza Carica Batteria"
      device_class: power  
      unit_of_measurement: W
      state_class: measurement
      state: >-
        {{ states('sensor.fotovoltaico_inverter_1_tensione_batteria') | float * states('sensor.fotovoltaico_inverter_1_corrente_carica_batteria') | float}}
    - name: "Inverter 2 Potenza Carica Batteria"
      device_class: power
      unit_of_measurement: W
      state_class: measurement
      state: >-
        {{ states('sensor.fotovoltaico_inverter_2_tensione_batteria') | float * states('sensor.fotovoltaico_inverter_2_corrente_carica_batteria') | float}} 
    - name: "Inverter 1 Potenza Scarica Batteria"
      device_class: power
      unit_of_measurement: W
      state_class: measurement
      state: >-
        {{ states('sensor.fotovoltaico_inverter_1_tensione_batteria') | float * states('sensor.fotovoltaico_inverter_1_corrente_scarica_batteria') | float}}      
    - name: "Inverter 2 Potenza Scarica Batteria"
      device_class: power
      unit_of_measurement: W
      state_class: measurement
      state: >-
        {{ states('sensor.fotovoltaico_inverter_2_tensione_batteria') | float * states('sensor.fotovoltaico_inverter_2_corrente_scarica_batteria') | float}}

sensor:
  - platform: integration
    source: sensor.inverter_1_potenza_carica_batteria
    name: Inverter 1 Energia Carica Batteria
    unit_prefix: k
    round: 2
    unit_time: h
    method: trapezoidal
  - platform: integration
    source: sensor.inverter_1_potenza_scarica_batteria
    name: Inverter 1 Energia Scarica Batteria
    unit_prefix: k
    round: 2
    unit_time: h
    method: trapezoidal
  - platform: integration
    source: sensor.inverter_2_potenza_carica_batteria
    name: Inverter 2 Energia Carica Batteria
    unit_prefix: k
    round: 2
    unit_time: h
    method: trapezoidal
  - platform: integration
    source: sensor.inverter_2_potenza_scarica_batteria
    name: Inverter 2 Energia Scarica Batteria
    unit_prefix: k
    round: 2
    unit_time: h
    method: trapezoidal

Plancia

Plancia
title: Fotovoltaico
views:
  - badges: []
    cards:
      - type: entities
        entities:
          - entity: sensor.fotovoltaico_inverter_1_stato_parallelo
            name: Stato Parallelo
          - entity: sensor.fotovoltaico_inverter_1_modo
            name: Modo
          - entity: sensor.fotovoltaico_inverter_1_codice_errore
            name: Codice Errore
          - entity: sensor.fotovoltaico_inverter_1_tensione_rete
            name: Tensione Rete
          - entity: sensor.fotovoltaico_inverter_1_frequenza_rete
            name: Frequenza Rete
          - entity: sensor.fotovoltaico_inverter_1_tensione
            name: Tensione
          - entity: sensor.fotovoltaico_inverter_1_frequenza
            name: Frequenza
          - entity: sensor.fotovoltaico_inverter_1_potenza_apparente
            name: Potenza Apparente
          - entity: sensor.fotovoltaico_inverter_1_potenza_attiva
            name: Potenza Attiva
          - entity: sensor.fotovoltaico_inverter_1_potenza_apparente_totale
            name: Potenza Apparente Totale
          - entity: sensor.fotovoltaico_inverter_1_potenza_attiva_totale
            name: Potenza Attiva Totale
          - entity: sensor.fotovoltaico_inverter_1_percentuale_carico
            name: Percentuale Carico
          - entity: sensor.fotovoltaico_inverter_1_percentuale_carico_totale
            name: Percentuale Carico Totale
          - entity: sensor.fotovoltaico_inverter_1_tensione_batteria
            name: Tensione Batteria
          - entity: sensor.fotovoltaico_inverter_1_corrente_scarica_batteria
            name: Corrente Scarica Batteria
          - entity: sensor.fotovoltaico_inverter_1_corrente_carica_batteria
            name: Corrente Carica Batteria
          - entity: sensor.fotovoltaico_inverter_1_corrente_carica_batteria_totale
            name: Corrente Carica Batteria Totale
          - entity: sensor.fotovoltaico_inverter_1_capacita_batteria
            name: Capacità Batteria
          - entity: sensor.fotovoltaico_inverter_1_potenza_stringa_1
            name: Potenza Stringa 1
          - entity: sensor.fotovoltaico_inverter_1_potenza_stringa_2
            name: Potenza Stringa 2
          - entity: sensor.fotovoltaico_inverter_1_tensione_stringa_1
            name: Tensione Stringa 1
          - entity: sensor.fotovoltaico_inverter_1_tensione_stringa_2
            name: Tensione Stringa 2
          - entity: sensor.fotovoltaico_inverter_1_stato_carica_stringa_1
            name: Stato Carica Stringa 1
          - entity: sensor.fotovoltaico_inverter_1_stato_carica_stringa_2
            name: Stato Carica Stringa 2
          - entity: sensor.fotovoltaico_inverter_1_carico_connesso
            name: Carico Connesso
          - entity: sensor.fotovoltaico_inverter_1_stato_batteria
            name: Stato Batteria
          - entity: sensor.fotovoltaico_inverter_1_stato_inverter
            name: Stato Inverter
          - entity: sensor.fotovoltaico_inverter_1_stato_rete
            name: Stato Rete
        title: Inverter 1
      - type: entities
        entities:
          - entity: sensor.fotovoltaico_inverter_2_stato_parallelo
            name: Stato Parallelo
          - entity: sensor.fotovoltaico_inverter_2_modo
            name: Modo
          - entity: sensor.fotovoltaico_inverter_2_codice_errore
            name: Codice Errore
          - entity: sensor.fotovoltaico_inverter_2_tensione_rete
            name: Tensione Rete
          - entity: sensor.fotovoltaico_inverter_2_frequenza_rete
            name: Frequenza Rete
          - entity: sensor.fotovoltaico_inverter_2_tensione
            name: Tensione
          - entity: sensor.fotovoltaico_inverter_2_frequenza
            name: Frequenza
          - entity: sensor.fotovoltaico_inverter_2_potenza_apparente
            name: Potenza Apparente
          - entity: sensor.fotovoltaico_inverter_2_potenza_attiva
            name: Potenza Attiva
          - entity: sensor.fotovoltaico_inverter_2_potenza_apparente_totale
            name: Potenza Apparente Totale
          - entity: sensor.fotovoltaico_inverter_2_potenza_attiva_totale
            name: Potenza Attiva Totale
          - entity: sensor.fotovoltaico_inverter_2_percentuale_carico
            name: Percentuale Carico
          - entity: sensor.fotovoltaico_inverter_2_percentuale_carico_totale
            name: Percentuale Carico Totale
          - entity: sensor.fotovoltaico_inverter_2_tensione_batteria
            name: Tensione Batteria
          - entity: sensor.fotovoltaico_inverter_2_corrente_scarica_batteria
            name: Corrente Scarica Batteria
          - entity: sensor.fotovoltaico_inverter_2_corrente_carica_batteria
            name: Corrente Carica Batteria
          - entity: sensor.fotovoltaico_inverter_2_corrente_carica_batteria_totale
            name: Corrente Carica Batteria Totale
          - entity: sensor.fotovoltaico_inverter_2_capacita_batteria
            name: Capacità Batteria
          - entity: sensor.fotovoltaico_inverter_2_potenza_stringa_1
            name: Potenza Stringa 1
          - entity: sensor.fotovoltaico_inverter_2_potenza_stringa_2
            name: Potenza Stringa 2
          - entity: sensor.fotovoltaico_inverter_2_tensione_stringa_1
            name: Tensione Stringa 1
          - entity: sensor.fotovoltaico_inverter_2_tensione_stringa_2
            name: Tensione Stringa 2
          - entity: sensor.fotovoltaico_inverter_2_stato_carica_stringa_1
            name: Stato Carica Stringa 1
          - entity: sensor.fotovoltaico_inverter_2_stato_carica_stringa_2
            name: Stato Carica Stringa 2
          - entity: sensor.fotovoltaico_inverter_2_carico_connesso
            name: Carico Connesso
          - entity: sensor.fotovoltaico_inverter_2_stato_batteria
            name: Stato Batteria
          - entity: sensor.fotovoltaico_inverter_2_stato_inverter
            name: Stato Inverter
          - entity: sensor.fotovoltaico_inverter_2_stato_rete
            name: Stato Rete
        title: Inverter 2
      - type: entities
        entities:
          - entity: sensor.fotovoltaico_inverter_1_energia_generata_giornaliera
            name: Inverter 1 Giornaliera
            icon: mdi:counter
          - entity: sensor.fotovoltaico_inverter_1_energia_generata_totale
            name: Inverter 1 Totale
            icon: mdi:counter
        title: Energia
      - type: entities
        entities:
          - entity: sensor.inverter_1_potenza_carica_batteria
            name: Inverter 1 Potenza Carica Batteria
          - entity: sensor.inverter_1_potenza_scarica_batteria
            name: Inverter 1 Potenza Scarica Batteria
          - entity: sensor.inverter_2_potenza_carica_batteria
            name: Inverter 2 Potenza Carica Batteria
          - entity: sensor.inverter_2_potenza_scarica_batteria
            name: Inverter 2 Potenza Scarica Batteria
        title: Calcolo Potenza Batterie
      - type: entities
        entities:
          - entity: sensor.inverter_1_energia_carica_batteria
            icon: mdi:counter
          - entity: sensor.inverter_1_energia_scarica_batteria
            icon: mdi:counter
          - entity: sensor.inverter_2_energia_carica_batteria
            icon: mdi:counter
          - entity: sensor.inverter_2_energia_scarica_batteria
            icon: mdi:counter
        title: Calcolo Energia Batterie
    icon: mdi:grid
    title: Fotovoltaico

3 commenti

  1. Son riuscito ad installare il servizio, ma quando interrogo sia via seriale che usb ottengo errore di timeout. Stessa porta USB con solpiplog funziona senza problemi. Qualche suggerimento?
    Grazie mille.

  2. Molto interessante anche se macchinoso. Ma non si riesce usare un ESP32 per fare da MQTT? Qui stai usando un raspberry con docker?

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *