This repository has been archived by the owner on Apr 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce Glowdata for generic access from sensors
heavily inspired by p1monitor and roombapy's design patterns
- Loading branch information
Showing
9 changed files
with
226 additions
and
158 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
"""Constants for the Hildebrand Glow integration.""" | ||
import logging | ||
from typing import Final | ||
|
||
DOMAIN = "hildebrandglow" | ||
APP_ID = "b0f1b774-a586-4f72-9edd-27ead8aa7a8d" | ||
DOMAIN: Final = "hildebrandglow" | ||
APP_ID: Final = "b0f1b774-a586-4f72-9edd-27ead8aa7a8d" | ||
|
||
LOGGER = logging.getLogger(__package__) | ||
|
||
GLOW_SESSION: Final = "glow_session" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Data classes for interpreted Glow structures.""" | ||
|
||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
|
||
from . import MQTTPayload | ||
|
||
|
||
@dataclass | ||
class SmartMeter: | ||
"""Data object for platform agnostic smart metering information.""" | ||
|
||
gas_consumption: float | None | ||
|
||
power_consumption: int | None | ||
energy_consumption: float | None | ||
|
||
@staticmethod | ||
def from_mqtt_payload(data: MQTTPayload) -> SmartMeter: | ||
"""Populate SmartMeter object from an MQTTPayload object.""" | ||
meter = SmartMeter( | ||
gas_consumption=None, | ||
power_consumption=None, | ||
energy_consumption=None, | ||
) | ||
|
||
if data.gas: | ||
ahc = data.gas.alternative_historical_consumption | ||
meter.gas_consumption = ahc.current_day_consumption_delivered | ||
|
||
if data.electricity: | ||
meter.power_consumption = ( | ||
data.electricity.historical_consumption.instantaneous_demand | ||
) | ||
|
||
if data.electricity.reading_information_set.current_summation_delivered: | ||
meter.energy_consumption = ( | ||
data.electricity.reading_information_set.current_summation_delivered | ||
* data.electricity.formatting.multiplier | ||
/ data.electricity.formatting.divisor | ||
) | ||
|
||
return meter |
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.