Skip to content

Commit

Permalink
Changement meter config datastructure
Browse files Browse the repository at this point in the history
Since hass2022.2, utility_meter setup_platform is no more expecting a
list, but it's expecting a dict.

This change converts the meter config to a dict to address this

fixes #75
  • Loading branch information
valleedelisle committed Feb 3, 2022
1 parent 04ab170 commit caf3b1f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/hilo/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, hass, period):
self.hass = hass
self.period = period
self.meter_configs = OrderedDict()
self.meter_entities = []
self.meter_entities = {}
self.new_entities = 0

def add_meter(self, entity, tariff_list):
Expand All @@ -33,9 +33,11 @@ def add_meter_entity(self, entity, tariff_list):
for tarif in tariff_list:
name = f"{entity}_{self.period}"
LOG.debug(f"Creating UtilityMeter entity: {name} {tarif}")
self.meter_entities.append(
{"meter": entity, "name": f"{name} {tarif}", "tariff": tarif}
)
self.meter_entities[entity] = {
"meter": entity,
"name": f"{name} {tarif}",
"tariff": tarif,
}

def add_meter_config(self, entity, tariff_list):
name = f"{entity}_{self.period}"
Expand Down

0 comments on commit caf3b1f

Please sign in to comment.