Add unique_id to essent sensors (#31408)
* Fix mix-up of sensor entities and their values * Prevent multiple calls for the same meter
This commit is contained in:
parent
48402d49dc
commit
55aa341dab
1 changed files with 7 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
"""Support for Essent API."""
|
||||
from datetime import timedelta
|
||||
from typing import Optional
|
||||
|
||||
from pyessent import PyEssent
|
||||
import voluptuous as vol
|
||||
|
@ -73,7 +74,7 @@ class EssentBase:
|
|||
def update(self):
|
||||
"""Retrieve the latest meter data from Essent."""
|
||||
essent = PyEssent(self._username, self._password)
|
||||
eans = essent.get_EANs()
|
||||
eans = set(essent.get_EANs())
|
||||
for possible_meter in eans:
|
||||
meter_data = essent.read_meter(possible_meter, only_last_meter_reading=True)
|
||||
if meter_data:
|
||||
|
@ -92,6 +93,11 @@ class EssentMeter(Entity):
|
|||
self._tariff = tariff
|
||||
self._unit = unit
|
||||
|
||||
@property
|
||||
def unique_id(self) -> Optional[str]:
|
||||
"""Return a unique ID."""
|
||||
return f"{self._meter}-{self._type}-{self._tariff}"
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
|
|
Loading…
Add table
Reference in a new issue