Skip to content

Commit

Permalink
#24
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Sep 9, 2023
1 parent 6292564 commit a953cae
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions custom_components/peaqnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
from custom_components.peaqnext.service.models.consumption_type import ConsumptionType
from custom_components.peaqnext.service.models.sensor_model import NextSensor
from .const import (CONF_CALCULATE_BY, CONF_CUSTOM_CONSUMPTION_PATTERN, CONF_DEDUCT_PRICE, CONF_UPDATE_BY, DOMAIN, PLATFORMS, HUB, CONF_NONHOURS_END, CONF_CONSUMPTION_TYPE, CONF_NAME, CONF_NONHOURS_START, CONF_SENSORS, CONF_TOTAL_CONSUMPTION_IN_KWH, CONF_TOTAL_DURATION_IN_MINUTES, CONF_CLOSEST_CHEAP)

from datetime import datetime
from uuid import uuid4

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(hass: HomeAssistant, conf: ConfigEntry) -> bool:
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][conf.entry_id] = conf.data
hub = Hub(hass)
hub = Hub(hass, hub_id=datetime.now().strftime('%Y%m-%d%H-%M%S-') + str(uuid4()))
hass.data[DOMAIN][HUB] = hub
internal_sensors = await async_create_internal_sensors(conf)
await hub.async_setup(internal_sensors)
Expand Down
3 changes: 2 additions & 1 deletion custom_components/peaqnext/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"name": "peaqnext, utility sensors",
"after_dependencies": [
"nordpool",
"energidataservice",
"peaqev"
],
"codeowners": [
Expand All @@ -13,5 +14,5 @@
"integration_type": "hub",
"iot_class": "calculated",
"issue_tracker": "https://github.com/elden1337/hass-peaqnext/issues",
"version": "0.5.2"
"version": "0.5.3"
}
2 changes: 1 addition & 1 deletion custom_components/peaqnext/sensors/next_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def extra_state_attributes(self) -> dict:
def device_info(self):
return {
"identifiers": {(DOMAIN, self.hub.hub_id)},
"name": f"{DOMAIN} {HUB}",
"name": f"{DOMAIN} {HUB} ({self.hub.hub_id})",
"sw_version": 1,
"model": "Normal",
"manufacturer": "Peaq systems",
Expand Down
10 changes: 5 additions & 5 deletions custom_components/peaqnext/service/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@


class Hub:
hub_id = 33512
hubname = "PeaqNext"
sensors_dict: dict[str:NextSensor] = {}
sensors: list[NextSensor] = []

def __init__(self, hass, test:bool = False) -> Any:

def __init__(self, hass, hub_id, test:bool = False) -> Any:
self.hub_id = hub_id
if not test:
self.state_machine: HomeAssistant = hass
self._current_minute: int = None
self.prices: tuple[list,list] = ([], [])
self.sensors_dict: dict[str:NextSensor] = {}
self.sensors: list[NextSensor] = []
self.spotprice: ISpotPrice = SpotPriceFactory.create(self, test)
self.latest_spotprice_update = 0
if not test:
Expand Down

0 comments on commit a953cae

Please sign in to comment.