Skip to content

Commit

Permalink
🐛 FIX: added prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
unl0ck committed Dec 9, 2024
1 parent b6bd735 commit ec2e22d
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .bumpversion-edge.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "2.11.20"
current_version = "2.11.21"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
Expand Down
6 changes: 6 additions & 0 deletions GridboxConnectorAddon-edge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 2.11.21

### 🔨 Fixed

- historical prefix

## 2.11.19

### 🔨 Fixed
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/GridboxConnector/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,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, unit_of_power="Wh")
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")


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,51 +27,51 @@ 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", logger=logging.getLogger(__name__), unit_of_power="W"):
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__), 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", device=self.device_info, unit_of_measurement=unit_of_power)
production_sensor_info = SensorInfo(name="Production", device_class="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", device=self.device_info, unit_of_measurement=unit_of_power)
grid_sensor_info = SensorInfo(name="Grid", device_class="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", device=self.device_info, unit_of_measurement=unit_of_power)
photovoltaic_sensor_info = SensorInfo(name="Photovoltaic", device_class="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", device=self.device_info, unit_of_measurement=unit_of_power)
consumption_household_sensor_info = SensorInfo(name="Consumption", device_class="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", device=self.device_info, unit_of_measurement=unit_of_power)
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=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", device=self.device_info, unit_of_measurement=unit_of_power)
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=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", device=self.device_info, unit_of_measurement=unit_of_power)
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=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", device=self.device_info, unit_of_measurement=unit_of_power)
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=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", device=self.device_info, unit_of_measurement="%")
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", device=self.device_info, unit_of_measurement=unit_of_power)
self_supply_sensor_info = SensorInfo(name="SelfSupply", device_class="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", device=self.device_info, unit_of_measurement="%")
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="%")
self_consumption_rate_settings = Settings(mqtt=mqtt_settings, entity=self_consumption_rate_sensor_info)

self_sufficiency_rate_sensor_info = SensorInfo(name="SelfSufficiencyRate", device_class="power_factor", unique_id="gridbox_self_sufficiency_rate", device=self.device_info, unit_of_measurement="%")
self_sufficiency_rate_sensor_info = SensorInfo(name="SelfSufficiencyRate", device_class="power_factor", unique_id="gridbox_self_sufficiency_rate"+prefix, device=self.device_info, unit_of_measurement="%")
self_sufficiency_rate_settings = Settings(mqtt=mqtt_settings, entity=self_sufficiency_rate_sensor_info)

# Instantiate the sensors
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", "")
self.battery_sum = HAViessmannBattery(mqtt_settings, self.device_info, "sum", "", prefix)

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

# EV
self.ev_sum = HAViessmannEVChargingStation(mqtt_settings, self.device_info, "sum", "")
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-edge/cloudSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.11.20",
"version": "2.11.21",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
---
name: Viessmann Gridbox Connector (edge)
version: "2.11.20"
version: "2.11.21"
slug: "gridbox_connector_edge"
description: "Viessmann Gridbox Connector (edge)"
url: "https://github.com/unl0ck/homeassistant-addon-viessmann-gridbox/tree/main/GridboxConnectorAddon-edge"
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/rootfs/share/cloudSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.11.20",
"version": "2.11.21",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down

0 comments on commit ec2e22d

Please sign in to comment.