generated from home-assistant/addons-example
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
207 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
GridboxConnectorAddon-dev/GridboxConnector/ha_viessmann_heater.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from ha_mqtt_discoverable.sensors import Sensor, SensorInfo | ||
from ha_mqtt_discoverable import Settings, DeviceInfo | ||
|
||
|
||
class HAViessmannHeater: | ||
def __init__(self, mqtt_settings, device_info, name, id): | ||
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") | ||
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") | ||
self.heater_temperature_settings = Settings( | ||
mqtt=mqtt_settings, entity=self.heater_sensor_temperature) | ||
self.heater_temperature = Sensor(self.heater_temperature_settings) | ||
|
||
|
||
def get_name(self): | ||
return self.name | ||
|
||
def set_states(self, power, temperature): | ||
self.heater_power.set_state(power) | ||
self.heater_temperature.set_state(temperature) | ||
|
45 changes: 45 additions & 0 deletions
45
GridboxConnectorAddon-dev/GridboxConnector/tests/mock_data/mock_data_with_heater.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"batteries": [ | ||
{ | ||
"applianceID": "a1731af4-0399-495b-92c2-523fd61ab681", | ||
"capacity": 10000, | ||
"nominalCapacity": 10000, | ||
"power": -102, | ||
"remainingCharge": 10000, | ||
"stateOfCharge": 1 | ||
} | ||
], | ||
"battery": { | ||
"capacity": 10000, | ||
"nominalCapacity": 10000, | ||
"power": -102, | ||
"remainingCharge": 10000, | ||
"stateOfCharge": 1 | ||
}, | ||
"consumption": 847, | ||
"directConsumption": 4523, | ||
"directConsumptionEV": 0, | ||
"directConsumptionHeatPump": 0, | ||
"directConsumptionHeater": 3676, | ||
"directConsumptionHousehold": 847, | ||
"directConsumptionRate": 0.5465200579990334, | ||
"grid": -3651, | ||
"gridMeterReadingNegative": 5630400000, | ||
"gridMeterReadingPositive": 5344920000, | ||
"heaters": [ | ||
{ | ||
"applianceID": "12bdd8ec-9b1e-465e-8f26-feae00e5af0f", | ||
"power": 3676, | ||
"temperature": 70.9 | ||
} | ||
], | ||
"heating": 3676, | ||
"measuredAt": "2024-07-12T12:52:47Z", | ||
"photovoltaic": 8276, | ||
"production": 8276, | ||
"selfConsumption": 4625, | ||
"selfConsumptionRate": 0.5588448525857902, | ||
"selfSufficiencyRate": 1, | ||
"selfSupply": 4523, | ||
"totalConsumption": 4523 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import json | ||
import logging | ||
import ast | ||
class SensitiveDataFilter(logging.Filter): | ||
def filter(self, record): | ||
message = record.getMessage() | ||
try: | ||
literal_msg = ast.literal_eval(message) | ||
# Sensible Daten filtern, falls vorhanden | ||
if 'username' in literal_msg: | ||
literal_msg['username'] = '***' | ||
if 'password' in literal_msg: | ||
literal_msg['password'] = '***' | ||
if 'id_token' in literal_msg: | ||
literal_msg['id_token'] = '***' | ||
if 'access_token' in literal_msg: | ||
literal_msg['access_token'] = '***' | ||
if 'client_id' in literal_msg: | ||
literal_msg['client_id'] = '***' | ||
# Das modifizierte Dictionary zurück in einen String konvertieren | ||
record.msg = json.dumps(literal_msg) | ||
except json.JSONDecodeError: | ||
# Wenn die Nachricht kein JSON ist, nichts tun | ||
logging.error('Could not parse message as JSON') | ||
pass | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.