Skip to content

Commit

Permalink
🚀 RELEASE: 2.11.40
Browse files Browse the repository at this point in the history
  • Loading branch information
unl0ck committed Jan 2, 2025
1 parent e99a90a commit bdc283e
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 58 deletions.
18 changes: 17 additions & 1 deletion GridboxConnectorAddon-dev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 2.11.38
## 2.11.40

### 🔨 Fixed

- fixed more step by step good to be test it first on edge

## 2.11.39

### 🔨 Fixed

- last_reset should now working 🙈 🤷

### 🔄 Changed

- bump ha-mqtt-discoverable 0.16.4

## 2.11.35

### 🔨 Fixed

Expand Down
4 changes: 1 addition & 3 deletions GridboxConnectorAddon-dev/GridboxConnector/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def historical_data_task(gridboxConnector:GridboxConnector, ha_viessmann_histori
if len(measurement) > 0:
result = measurement[0]
total = result["total"]
ha_viessmann_historical_device.update_sensors(total)
ha_viessmann_historical_device.update_sensors(total, last_reset=midnight_today.isoformat())
if one_time_print or logger.level == logging.DEBUG:
logger.info(total)
one_time_print = False
Expand Down Expand Up @@ -99,8 +99,6 @@ def run_addon():
gridbox_config = load_gridbox_config()
options_file = ''
WAIT = int(os.getenv('WAITTIME', "60"))
if WAIT < 30:
WAIT = 30
if os.path.exists(opens_file_path):
options_file = open(opens_file_path)
options_json = json.load(options_file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=device_class_of_power, unique_id="gridbox_production"+prefix, device=self.device_info, unit_of_measurement=unit_of_power, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
production_settings = Settings(mqtt=mqtt_settings, entity=production_sensor_info)

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, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
grid_settings = Settings(mqtt=mqtt_settings, entity=grid_sensor_info)

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, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
photovoltaic_settings = Settings(mqtt=mqtt_settings, entity=photovoltaic_sensor_info)

# consumption
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, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
consumption_household_settings = Settings(mqtt=mqtt_settings, entity=consumption_household_sensor_info)

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, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
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=device_class_of_power, unique_id="gridbox_direct_consumption_household"+prefix, device=self.device_info, unit_of_measurement=unit_of_power, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
direct_consumption_household_settings = Settings(mqtt=mqtt_settings, entity=direct_consumption_household_sensor_info)

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, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
direct_consumption_heatpump_settings = Settings(mqtt=mqtt_settings, entity=direct_consumption_heatpump_sensor_info)

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, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
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=device_class_of_power,unique_id="gridbox_self_supply"+prefix, device=self.device_info, unit_of_measurement=unit_of_power, state_class=state_class)
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, state_class=state_class, value_template=None if state_class is None else "{{ value_json.state }}", last_reset_value_template=None if state_class is None else "{{ value_json.last_reset }}")
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 Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ha-mqtt-discoverable==0.16.3
ha-mqtt-discoverable==0.16.4
requests==2.32.3
viessmann-gridbox-connector==1.6.0
logfire==2.11.0
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.35",
"version": "2.11.40",
"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.35"
version: "2.11.40"
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.35",
"version": "2.11.40",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down
76 changes: 76 additions & 0 deletions GridboxConnectorAddon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,86 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 2.11.40

### 🔨 Fixed

- fixed more step by step good to be test it first on edge

## 2.11.39

### 🔨 Fixed

- last_reset should now working 🙈 🤷

### 🔄 Changed

- bump ha-mqtt-discoverable 0.16.4

## 2.11.35

### 🔨 Fixed

- logfire

### 🔄 Changed

- bump viessmann-gridbox-connector 1.6.0

## 2.11.33

### 🔨 Fixed

- logfire

### 🔄 Changed

- bump viessmann-gridbox-connector 1.7.0

## 2.11.31

### 🚀 Added

- make possible the disable and enable telemetry

### 🔨 Fixed

- sensitive filter fixed

## 2.11.28

### 🔨 Fixed

- sensitive filter fixed

## 2.11.26

### 🚀 Added

- start with logfire implementation

## 2.11.25

### 🔨 Fixed

- historical devices revert last_update

## 2.11.24

### 🔨 Fixed

- historical devices added last_update

### 🔄 Changed

- bump requests 2.32.3
- bump ha-mqtt-discoverable 0.16.3

## 2.11.23

### 🔨 Fixed

- historical devices added state_class

## 2.11.22

### 🔨 Fixed
Expand Down
6 changes: 6 additions & 0 deletions GridboxConnectorAddon/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ use your credentials from the Viessmann **myGridbox** App or from the Viessmann
username: email
password: password
wait_time: timeout when will refresh
OverrideMqttUser: Mqtt user
OverrideMqttPw: Mqtt password
OverrideMqttServer: Mqtt Server
OverrideMqttPort: Mqtt Port
log_level: select one of this(TRACE|DEBUG|INFO|WARN|ERROR)
enable_telemetry: Send to logfire logs and exceptions
```
if you use an custom setup MQTT-Broker so you can add in the Addon the MQTT settings currently only support MQTT Standard Port 1833 (will fixed later)
Expand Down
2 changes: 2 additions & 0 deletions GridboxConnectorAddon/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ LABEL \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

ENV LOGFIRE_TOKEN=${LOGFIRE_TOKEN}

RUN \
apk add --no-cache \
python3 py3-pip
Expand Down
15 changes: 13 additions & 2 deletions GridboxConnectorAddon/GridboxConnector/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from importlib.resources import files
from utils import SensitiveDataFilter, get_bool_env
import threading
import logfire
opens_file_path = '/data/options.json'
#logging.basicConfig(format='%(asctime)s %(filename)s:%(lineno)d %(levelname)s - %(message)s', level=logging.getLevelName(os.getenv('LOG_LEVEL', 'INFO')))
logger = logging.getLogger(__name__)
Expand All @@ -17,6 +18,16 @@
console_handler.setFormatter(formatter)
logger.addHandler(console_handler)
logger.addFilter(SensitiveDataFilter())
# Retrieve logfire token from environment variable
try:
logfire_token = os.getenv('LOGFIRE_TOKEN', '4nzH9rJ0GBZ4QJNY5GQM6tTh2bFTTyfrsrw6ytZ1xGT9')
enable_telemetry = os.getenv('ENABLE_TELEMETRY', False)
if logfire_token and enable_telemetry:
logfire.configure(token=logfire_token)
logfire.instrument_requests()
logger.addHandler(logfire.LogfireLoggingHandler())
except Exception as e:
logger.error(f"Error configuring logfire: {e}")

def load_gridbox_config():
config_file = files('viessmann_gridbox_connector').joinpath('config.json')
Expand Down Expand Up @@ -48,14 +59,14 @@ def historical_data_task(gridboxConnector:GridboxConnector, ha_viessmann_histori
from datetime import datetime, timedelta, timezone
now = datetime.now(timezone(timedelta(hours=1)))
now = now.replace(hour=0, minute=0, second=0, microsecond=0)

today = now.isoformat()
tomorrow = (now + timedelta(days=1)).isoformat()
measurement = gridboxConnector.retrieve_historical_data(today, tomorrow)
midnight_today = now.replace(hour=0, minute=0, second=0, microsecond=0)
if len(measurement) > 0:
result = measurement[0]
total = result["total"]
ha_viessmann_historical_device.update_sensors(total)
ha_viessmann_historical_device.update_sensors(total, last_reset=midnight_today.isoformat())
if one_time_print or logger.level == logging.DEBUG:
logger.info(total)
one_time_print = False
Expand Down
Loading

0 comments on commit bdc283e

Please sign in to comment.