diff --git a/GridboxConnectorAddon-dev/CHANGELOG.md b/GridboxConnectorAddon-dev/CHANGELOG.md index f0ea748..047d2f7 100644 --- a/GridboxConnectorAddon-dev/CHANGELOG.md +++ b/GridboxConnectorAddon-dev/CHANGELOG.md @@ -1,5 +1,23 @@ +## 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 diff --git a/GridboxConnectorAddon-dev/GridboxConnector/__main__.py b/GridboxConnectorAddon-dev/GridboxConnector/__main__.py index 224989c..bf23475 100644 --- a/GridboxConnectorAddon-dev/GridboxConnector/__main__.py +++ b/GridboxConnectorAddon-dev/GridboxConnector/__main__.py @@ -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: @@ -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) diff --git a/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_battery.py b/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_battery.py index 4e4430f..0d0525c 100644 --- a/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_battery.py +++ b/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_battery.py @@ -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( diff --git a/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_ev_charging_station.py b/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_ev_charging_station.py index e7c5fcd..a87059b 100644 --- a/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_ev_charging_station.py +++ b/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_ev_charging_station.py @@ -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) diff --git a/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_gridbox_connector.py b/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_gridbox_connector.py index d76a570..584c5e8 100644 --- a/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_gridbox_connector.py +++ b/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_gridbox_connector.py @@ -27,7 +27,7 @@ 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 @@ -35,37 +35,37 @@ def __init__(self, mqtt_settings, device_name="Viessmann Gridbox", device_identi 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="%") @@ -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) diff --git a/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_heater.py b/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_heater.py index 20bdbbd..a43ec9b 100644 --- a/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_heater.py +++ b/GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_heater.py @@ -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) diff --git a/GridboxConnectorAddon-dev/cloudSettings.json b/GridboxConnectorAddon-dev/cloudSettings.json index 2b4935b..badf497 100644 --- a/GridboxConnectorAddon-dev/cloudSettings.json +++ b/GridboxConnectorAddon-dev/cloudSettings.json @@ -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", diff --git a/GridboxConnectorAddon-dev/config.yaml b/GridboxConnectorAddon-dev/config.yaml index 2f0efc9..1b58cbd 100644 --- a/GridboxConnectorAddon-dev/config.yaml +++ b/GridboxConnectorAddon-dev/config.yaml @@ -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" diff --git a/GridboxConnectorAddon-dev/rootfs/share/cloudSettings.json b/GridboxConnectorAddon-dev/rootfs/share/cloudSettings.json index 2b4935b..badf497 100644 --- a/GridboxConnectorAddon-dev/rootfs/share/cloudSettings.json +++ b/GridboxConnectorAddon-dev/rootfs/share/cloudSettings.json @@ -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", diff --git a/GridboxConnectorAddon/CHANGELOG.md b/GridboxConnectorAddon/CHANGELOG.md index f0ea748..047d2f7 100644 --- a/GridboxConnectorAddon/CHANGELOG.md +++ b/GridboxConnectorAddon/CHANGELOG.md @@ -1,5 +1,23 @@ +## 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 diff --git a/GridboxConnectorAddon/GridboxConnector/__main__.py b/GridboxConnectorAddon/GridboxConnector/__main__.py index 224989c..bf23475 100644 --- a/GridboxConnectorAddon/GridboxConnector/__main__.py +++ b/GridboxConnectorAddon/GridboxConnector/__main__.py @@ -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: @@ -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) diff --git a/GridboxConnectorAddon/GridboxConnector/ha_viessmann_battery.py b/GridboxConnectorAddon/GridboxConnector/ha_viessmann_battery.py index 4e4430f..0d0525c 100644 --- a/GridboxConnectorAddon/GridboxConnector/ha_viessmann_battery.py +++ b/GridboxConnectorAddon/GridboxConnector/ha_viessmann_battery.py @@ -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( diff --git a/GridboxConnectorAddon/GridboxConnector/ha_viessmann_ev_charging_station.py b/GridboxConnectorAddon/GridboxConnector/ha_viessmann_ev_charging_station.py index e7c5fcd..a87059b 100644 --- a/GridboxConnectorAddon/GridboxConnector/ha_viessmann_ev_charging_station.py +++ b/GridboxConnectorAddon/GridboxConnector/ha_viessmann_ev_charging_station.py @@ -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) diff --git a/GridboxConnectorAddon/GridboxConnector/ha_viessmann_gridbox_connector.py b/GridboxConnectorAddon/GridboxConnector/ha_viessmann_gridbox_connector.py index d76a570..584c5e8 100644 --- a/GridboxConnectorAddon/GridboxConnector/ha_viessmann_gridbox_connector.py +++ b/GridboxConnectorAddon/GridboxConnector/ha_viessmann_gridbox_connector.py @@ -27,7 +27,7 @@ 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 @@ -35,37 +35,37 @@ def __init__(self, mqtt_settings, device_name="Viessmann Gridbox", device_identi 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="%") @@ -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) diff --git a/GridboxConnectorAddon/GridboxConnector/ha_viessmann_heater.py b/GridboxConnectorAddon/GridboxConnector/ha_viessmann_heater.py index 20bdbbd..a43ec9b 100644 --- a/GridboxConnectorAddon/GridboxConnector/ha_viessmann_heater.py +++ b/GridboxConnectorAddon/GridboxConnector/ha_viessmann_heater.py @@ -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) diff --git a/GridboxConnectorAddon/cloudSettings.json b/GridboxConnectorAddon/cloudSettings.json index 2b4935b..badf497 100644 --- a/GridboxConnectorAddon/cloudSettings.json +++ b/GridboxConnectorAddon/cloudSettings.json @@ -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", diff --git a/GridboxConnectorAddon/config.yaml b/GridboxConnectorAddon/config.yaml index 3ef0a99..1d1cd4f 100644 --- a/GridboxConnectorAddon/config.yaml +++ b/GridboxConnectorAddon/config.yaml @@ -1,6 +1,6 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config name: Viessmann Gridbox Connector -version: "2.11.17" +version: "2.11.22" slug: "gridbox_connector" description: Fetch your live data from your Viessmann Gridbox url: "https://github.com/unl0ck/homeassistant-addon-viessmann-gridbox/tree/main/GridboxConnectorAddon" diff --git a/GridboxConnectorAddon/rootfs/share/cloudSettings.json b/GridboxConnectorAddon/rootfs/share/cloudSettings.json index 2b4935b..badf497 100644 --- a/GridboxConnectorAddon/rootfs/share/cloudSettings.json +++ b/GridboxConnectorAddon/rootfs/share/cloudSettings.json @@ -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",