Skip to content

Commit

Permalink
🚀 RELEASE: v2.11.22
Browse files Browse the repository at this point in the history
  • Loading branch information
unl0ck committed Dec 10, 2024
1 parent d9ebb2f commit af75aa3
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 90 deletions.
18 changes: 18 additions & 0 deletions GridboxConnectorAddon-dev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 2.11.22

### 🔨 Fixed

- historical devices now energy not power devices

## 2.11.21

### 🔨 Fixed

- historical prefix

## 2.11.19

### 🔨 Fixed

- historical data now support Wh

## 2.11.17

### 🔨 Fixed
Expand Down
14 changes: 1 addition & 13 deletions GridboxConnectorAddon-dev/GridboxConnector/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ def load_gridbox_config():
data = json.load(json_file)
return data

def run_telemetry():
telemetry = None
try:
enable_telemetry = get_bool_env('ENABLE_TELEMETRY', False)
if enable_telemetry:
otel_server = os.getenv('TELEMETRY_SERVER', "https://otel.helming.xyz")
telemetry = Telemetry(otel_server, "homeassistant-addon-viessmann-gridbox-edge")
telemetry.log_as_span("Telemetry enabled", level=logger.level)
except Exception as e:
logger.error(f"Error while setting up telemetry: {e}")
return telemetry

def live_data_task(gridboxConnector:GridboxConnector, ha_viessmann_device:HAViessmannGridboxConnector, WAIT):
one_time_print = True
while True:
Expand Down Expand Up @@ -130,7 +118,7 @@ def run_addon():


viessmann_gridbox_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, logger=logger)
viessmann_gridbox_historical_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, device_name="Viessmann Gridbox Historical",device_identifiers="viessmann_gridbox_historical",logger=logger, prefix="historical")
viessmann_gridbox_historical_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, device_name="Viessmann Gridbox Historical", device_identifiers="viessmann_gridbox_historical", prefix="historical", logger=logger, unit_of_power="Wh", device_class_of_power="energy")


gridboxConnector = GridboxConnector(gridbox_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ class HAViessmannBattery:
set_states(level, capacity, power, remaining_charge): Sets the states of the four sensors.
"""

def __init__(self, mqtt_settings, device_info, name, id):
def __init__(self, mqtt_settings, device_info, name, id, prefix=""):
self.id: str = id
self.name: str = name
self.device_info: DeviceInfo = device_info
self.mqtt_settings: Settings.MQTT = mqtt_settings

self.battery_sensor_info = SensorInfo(
name=f"Battery {name} Level", device_class="battery", unique_id=f"gridbox_battery_{name}", device=device_info, unit_of_measurement="%")
name=f"Battery {name} Level", device_class="battery", unique_id=f"gridbox_battery_{name}"+prefix, device=device_info, unit_of_measurement="%")
self.battery_settings = Settings(
mqtt=mqtt_settings, entity=self.battery_sensor_info)
self.battery_level = Sensor(self.battery_settings)

self.battery_sensor_capacity = SensorInfo(
name=f"Battery {name} Capacity", device_class="energy", unique_id=f"gridbox_battery_level_{name}", device=device_info, unit_of_measurement="Wh")
name=f"Battery {name} Capacity", device_class="energy", unique_id=f"gridbox_battery_level_{name}"+prefix, device=device_info, unit_of_measurement="Wh")
self.battery_settings_capacity = Settings(
mqtt=mqtt_settings, entity=self.battery_sensor_capacity)
self.battery_capacity = Sensor(self.battery_settings_capacity)

self.battery_sensor_power = SensorInfo(
name=f"Battery {name} Power", device_class="battery", unique_id=f"gridbox_battery_power_{name}", device=device_info, unit_of_measurement="W")
name=f"Battery {name} Power", device_class="battery", unique_id=f"gridbox_battery_power_{name}"+prefix, device=device_info, unit_of_measurement="W")
self.battery_settings_power = Settings(
mqtt=mqtt_settings, entity=self.battery_sensor_power)
self.battery_power = Sensor(self.battery_settings_power)

self.battery_sensor_remaining_charge = SensorInfo(
name=f"Battery {name} Remaining Charge", device_class="energy", unique_id=f"gridbox_remaining_charge_{name}", device=device_info, unit_of_measurement="Wh")
name=f"Battery {name} Remaining Charge", device_class="energy", unique_id=f"gridbox_remaining_charge_{name}"+prefix, device=device_info, unit_of_measurement="Wh")
self.battery_settings_remaining_charge = Settings(
mqtt=mqtt_settings, entity=self.battery_sensor_remaining_charge)
self.battery_remaining_charge = Sensor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,50 @@ class HAViessmannEVChargingStation:
device_info: DeviceInfo
mqtt_settings: Settings.MQTT

def __init__(self, mqtt_settings, device_info, name, appliance_id):
def __init__(self, mqtt_settings, device_info, name, appliance_id, prefix=""):
self.appliance_id = appliance_id
self.name = name
self.device_info = device_info
self.mqtt_settings = mqtt_settings

self.power_sensor_info = SensorInfo(
name=f"{name} Power", device_class="power", unique_id=f"gridbox_ev_charging_station_power_{name}", device=device_info, unit_of_measurement="W")
name=f"{name} Power", device_class="power", unique_id=f"gridbox_ev_charging_station_power_{name}"+prefix, device=device_info, unit_of_measurement="W")
self.power_settings = Settings(
mqtt=mqtt_settings, entity=self.power_sensor_info)
self.power_sensor = Sensor(self.power_settings)

self.state_of_charge_sensor_info = SensorInfo(
name=f"{name} State of Charge", device_class="battery", unique_id=f"gridbox_ev_charging_station_state_of_charge_{name}", device=device_info, unit_of_measurement="%")
name=f"{name} State of Charge", device_class="battery", unique_id=f"gridbox_ev_charging_station_state_of_charge_{name}"+prefix, device=device_info, unit_of_measurement="%")
self.state_of_charge_settings = Settings(
mqtt=mqtt_settings, entity=self.state_of_charge_sensor_info)
self.state_of_charge = Sensor(self.state_of_charge_settings)

self.plug_state_sensor_info = SensorInfo(
name=f"{name} Plug State", device_class="plug", unique_id=f"gridbox_ev_charging_station_plug_state_{name}", device=device_info)
name=f"{name} Plug State", device_class="plug", unique_id=f"gridbox_ev_charging_station_plug_state_{name}"+prefix, device=device_info)
self.plug_state_settings = Settings(
mqtt=mqtt_settings, entity=self.plug_state_sensor_info)
self.plug_state = Sensor(self.plug_state_settings)

self.current_l1_sensor_info = SensorInfo(
name=f"{name} Current L1", device_class="current", unique_id=f"gridbox_ev_charging_station_current_l1_{name}", device=device_info, unit_of_measurement="A")
name=f"{name} Current L1", device_class="current", unique_id=f"gridbox_ev_charging_station_current_l1_{name}"+prefix, device=device_info, unit_of_measurement="A")
self.current_l1_settings = Settings(
mqtt=mqtt_settings, entity=self.current_l1_sensor_info)
self.current_l1 = Sensor(self.current_l1_settings)

self.current_l2_sensor_info = SensorInfo(
name=f"{name} Current L2", device_class="current", unique_id=f"gridbox_ev_charging_station_current_l2_{name}", device=device_info, unit_of_measurement="A")
name=f"{name} Current L2", device_class="current", unique_id=f"gridbox_ev_charging_station_current_l2_{name}"+prefix, device=device_info, unit_of_measurement="A")
self.current_l2_settings = Settings(
mqtt=mqtt_settings, entity=self.current_l2_sensor_info)
self.current_l2 = Sensor(self.current_l2_settings)

self.current_l3_sensor_info = SensorInfo(
name=f"{name} Current L3", device_class="current", unique_id=f"gridbox_ev_charging_station_current_l3_{name}", device=device_info, unit_of_measurement="A")
name=f"{name} Current L3", device_class="current", unique_id=f"gridbox_ev_charging_station_current_l3_{name}"+prefix, device=device_info, unit_of_measurement="A")
self.current_l3_settings = Settings(
mqtt=mqtt_settings, entity=self.current_l3_sensor_info)
self.current_l3 = Sensor(self.current_l3_settings)

self.reading_total_sensor_info = SensorInfo(
name=f"{name} Reading Total", device_class="energy", unique_id=f"gridbox_ev_charging_station_reading_total_{name}", device=device_info, unit_of_measurement="Wh")
name=f"{name} Reading Total", device_class="energy", unique_id=f"gridbox_ev_charging_station_reading_total_{name}"+prefix, device=device_info, unit_of_measurement="Wh")
self.reading_total_settings = Settings(mqtt=mqtt_settings, entity=self.reading_total_sensor_info)
self.reading_total = Sensor(self.reading_total_settings)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,45 @@ class HAViessmannGridboxConnector:
heater_sensor: HAViessmannHeater
logger: logging.Logger

def __init__(self, mqtt_settings, device_name="Viessmann Gridbox", device_identifiers="viessmann_gridbox", device_manufacturer="Viessmann", device_model="Vitocharge 2.0",prefix="", logger=logging.getLogger(__name__)):
def __init__(self, mqtt_settings, device_name="Viessmann Gridbox", device_identifiers="viessmann_gridbox", device_manufacturer="Viessmann", device_model="Vitocharge 2.0", prefix="", logger=logging.getLogger(__name__),device_class_of_power="power", unit_of_power="W"):
self.battery_sensor_dict = {}
self.ev_sensor_dict = {}
self.logger = logger
self.mqtt_settings = mqtt_settings
self.device_info = DeviceInfo(
name=device_name, identifiers=device_identifiers, manufacturer=device_manufacturer, model=device_model)
self.logger.info(f"Device Info: {self.device_info}")
production_sensor_info = SensorInfo(name="Production", device_class="power", unique_id="gridbox_production"+prefix, device=self.device_info, unit_of_measurement="W")
production_sensor_info = SensorInfo(name="Production", device_class=device_class_of_power, unique_id="gridbox_production"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
production_settings = Settings(mqtt=mqtt_settings, entity=production_sensor_info)

grid_sensor_info = SensorInfo(name="Grid", device_class="power", unique_id="gridbox_grid"+prefix, device=self.device_info, unit_of_measurement="W")
grid_sensor_info = SensorInfo(name="Grid", device_class=device_class_of_power, unique_id="gridbox_grid"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
grid_settings = Settings(mqtt=mqtt_settings, entity=grid_sensor_info)

photovoltaic_sensor_info = SensorInfo(name="Photovoltaic", device_class="power", unique_id="gridbox_photovoltaic"+prefix, device=self.device_info, unit_of_measurement="W")
photovoltaic_sensor_info = SensorInfo(name="Photovoltaic", device_class=device_class_of_power, unique_id="gridbox_photovoltaic"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
photovoltaic_settings = Settings(mqtt=mqtt_settings, entity=photovoltaic_sensor_info)

# consumption
consumption_household_sensor_info = SensorInfo(name="Consumption", device_class="power", unique_id="gridbox_consumption_household"+prefix, device=self.device_info, unit_of_measurement="W")
consumption_household_sensor_info = SensorInfo(name="Consumption", device_class=device_class_of_power, unique_id="gridbox_consumption_household"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
consumption_household_settings = Settings(mqtt=mqtt_settings, entity=consumption_household_sensor_info)

total_consumption_household_sensor_info = SensorInfo(name="Total Consumption", device_class="power", unique_id="total_consumption_household"+prefix, device=self.device_info, unit_of_measurement="W")
total_consumption_household_sensor_info = SensorInfo(name="Total Consumption", device_class=device_class_of_power, unique_id="total_consumption_household"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
total_consumption_household_settings = Settings(mqtt=mqtt_settings, entity=total_consumption_household_sensor_info)

# Direct Consumption
direct_consumption_household_sensor_info = SensorInfo(name="DirectConsumptionHousehold", device_class="power", unique_id="gridbox_direct_consumption_household"+prefix, device=self.device_info, unit_of_measurement="W")
direct_consumption_household_sensor_info = SensorInfo(name="DirectConsumptionHousehold", device_class=device_class_of_power, unique_id="gridbox_direct_consumption_household"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
direct_consumption_household_settings = Settings(mqtt=mqtt_settings, entity=direct_consumption_household_sensor_info)

direct_consumption_heatpump_sensor_info = SensorInfo(name="DirectConsumptionHeatPump", device_class="power", unique_id="gridbox_direct_consumption_heatpump"+prefix, device=self.device_info, unit_of_measurement="W")
direct_consumption_heatpump_sensor_info = SensorInfo(name="DirectConsumptionHeatPump", device_class=device_class_of_power, unique_id="gridbox_direct_consumption_heatpump"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
direct_consumption_heatpump_settings = Settings(mqtt=mqtt_settings, entity=direct_consumption_heatpump_sensor_info)

direct_consumption_ev_sensor_info = SensorInfo(name="DirectConsumptionEV", device_class="power", unique_id="gridbox_direct_consumption_ev"+prefix, device=self.device_info, unit_of_measurement="W")
direct_consumption_ev_sensor_info = SensorInfo(name="DirectConsumptionEV", device_class=device_class_of_power, unique_id="gridbox_direct_consumption_ev"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
direct_consumption_ev_settings = Settings(mqtt=mqtt_settings, entity=direct_consumption_ev_sensor_info)

direct_consumption_rate_sensor_info = SensorInfo(name="DirectConsumptionRate", device_class="power_factor", unique_id="gridbox_direct_consumption_rate"+prefix, device=self.device_info, unit_of_measurement="%")
direct_consumption_rate_settings = Settings(mqtt=mqtt_settings, entity=direct_consumption_rate_sensor_info)

# Self Consumption
self_supply_sensor_info = SensorInfo(name="SelfSupply", device_class="power",unique_id="gridbox_self_supply"+prefix, device=self.device_info, unit_of_measurement="W")
self_supply_sensor_info = SensorInfo(name="SelfSupply", device_class=device_class_of_power,unique_id="gridbox_self_supply"+prefix, device=self.device_info, unit_of_measurement=unit_of_power)
self_supply_settings = Settings(mqtt=mqtt_settings, entity=self_supply_sensor_info)

self_consumption_rate_sensor_info = SensorInfo(name="SelfConsumptionRate", device_class="power_factor", unique_id="gridbox_self_consumption_rate"+prefix, device=self.device_info, unit_of_measurement="%")
Expand All @@ -81,13 +81,13 @@ def __init__(self, mqtt_settings, device_name="Viessmann Gridbox", device_identi
self.photovoltaic_sensor = Sensor(photovoltaic_settings)

# Battery sum
self.battery_sum = HAViessmannBattery(mqtt_settings, self.device_info, "sum", ""+prefix)
self.battery_sum = HAViessmannBattery(mqtt_settings, self.device_info, "sum", "", prefix)

# Heater
self.heater_sensor = HAViessmannHeater(mqtt_settings, self.device_info, "", ""+prefix)
self.heater_sensor = HAViessmannHeater(mqtt_settings, self.device_info, "", "", prefix)

# EV
self.ev_sum = HAViessmannEVChargingStation(mqtt_settings, self.device_info, "sum", ""+prefix)
self.ev_sum = HAViessmannEVChargingStation(mqtt_settings, self.device_info, "sum", "", prefix)

# Consumption
self.consumption_household_sensor = Sensor(consumption_household_settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@


class HAViessmannHeater:
def __init__(self, mqtt_settings, device_info, name, id):
def __init__(self, mqtt_settings, device_info, name, id, prefix=""):
self.id: str = id
self.name: str = name
self.device_info: DeviceInfo = device_info
self.mqtt_settings: Settings.MQTT = mqtt_settings

self.heater_sensor_power = SensorInfo(
name=f"Heater {name} Power", device_class="energy", unique_id=f"gridbox_heater_power_{name}", device=device_info, unit_of_measurement="W")
name=f"Heater {name} Power", device_class="energy", unique_id=f"gridbox_heater_power_{name}"+prefix, device=device_info, unit_of_measurement="W")
self.heater_power_settings = Settings(
mqtt=mqtt_settings, entity=self.heater_sensor_power)
self.heater_power = Sensor(self.heater_power_settings)

self.heater_sensor_temperature = SensorInfo(
name=f"Heater {name} Temperature", device_class="temperature", unique_id=f"gridbox_heater_temperature_{name}", device=device_info, unit_of_measurement="C")
name=f"Heater {name} Temperature", device_class="temperature", unique_id=f"gridbox_heater_temperature_{name}"+prefix, device=device_info, unit_of_measurement="C")
self.heater_temperature_settings = Settings(
mqtt=mqtt_settings, entity=self.heater_sensor_temperature)
self.heater_temperature = Sensor(self.heater_temperature_settings)
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-dev/cloudSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.11.17",
"version": "2.11.22",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-dev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
name: Viessmann Gridbox Connector (dev)
version: "2.11.17"
version: "2.11.22"
slug: "gridbox_connector_dev"
description: Development version of Viessmann Gridbox Connector
url: "https://github.com/unl0ck/homeassistant-addon-viessmann-gridbox/tree/main/GridboxConnectorAddon-dev"
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-dev/rootfs/share/cloudSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.11.17",
"version": "2.11.22",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down
18 changes: 18 additions & 0 deletions GridboxConnectorAddon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 2.11.22

### 🔨 Fixed

- historical devices now energy not power devices

## 2.11.21

### 🔨 Fixed

- historical prefix

## 2.11.19

### 🔨 Fixed

- historical data now support Wh

## 2.11.17

### 🔨 Fixed
Expand Down
14 changes: 1 addition & 13 deletions GridboxConnectorAddon/GridboxConnector/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ def load_gridbox_config():
data = json.load(json_file)
return data

def run_telemetry():
telemetry = None
try:
enable_telemetry = get_bool_env('ENABLE_TELEMETRY', False)
if enable_telemetry:
otel_server = os.getenv('TELEMETRY_SERVER', "https://otel.helming.xyz")
telemetry = Telemetry(otel_server, "homeassistant-addon-viessmann-gridbox-edge")
telemetry.log_as_span("Telemetry enabled", level=logger.level)
except Exception as e:
logger.error(f"Error while setting up telemetry: {e}")
return telemetry

def live_data_task(gridboxConnector:GridboxConnector, ha_viessmann_device:HAViessmannGridboxConnector, WAIT):
one_time_print = True
while True:
Expand Down Expand Up @@ -130,7 +118,7 @@ def run_addon():


viessmann_gridbox_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, logger=logger)
viessmann_gridbox_historical_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, device_name="Viessmann Gridbox Historical",device_identifiers="viessmann_gridbox_historical",logger=logger, prefix="historical")
viessmann_gridbox_historical_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, device_name="Viessmann Gridbox Historical", device_identifiers="viessmann_gridbox_historical", prefix="historical", logger=logger, unit_of_power="Wh", device_class_of_power="energy")


gridboxConnector = GridboxConnector(gridbox_config)
Expand Down
Loading

0 comments on commit af75aa3

Please sign in to comment.