From ed266139ea5503732128b680bd96faf77a10538d Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Mon, 7 Dec 2020 16:02:21 +0100 Subject: [PATCH] Fixed issue: in query.py, _config is not defined --- custom_components/mercedesmeapi/resources.py | 6 +----- resources.py | 13 ++++--------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/custom_components/mercedesmeapi/resources.py b/custom_components/mercedesmeapi/resources.py index 234991d..7385b14 100644 --- a/custom_components/mercedesmeapi/resources.py +++ b/custom_components/mercedesmeapi/resources.py @@ -87,11 +87,6 @@ class MercedesMeResource (Entity): "last_update": self._lastupdate, }) -# @property -# def unit_of_measurement(self): -# """Return the unit of measurement.""" -# return TEMP_CELSIUS - class MercedesMeResources: ######################## @@ -214,6 +209,7 @@ class MercedesMeResources: print (f"\tvalid: {res._valid}") print (f"\tstate: {res._state}") print (f"\ttimestamp: {res._timestamp}") + print (f"\tlast_update: {res._lastupdate}") ######################## # Update Resources State diff --git a/resources.py b/resources.py index d56e947..9259323 100644 --- a/resources.py +++ b/resources.py @@ -61,6 +61,10 @@ class MercedesMeResource: self._lastupdate = datetime.fromtimestamp(self._timestamp/1000) self._valid = True + def unique_id(self): + """Return the unique id of the sensor.""" + return f"{self._vin}-{self._name}" + def name(self): """Return the name of the sensor.""" return f"{self._vin}_{self.name}" @@ -77,15 +81,6 @@ class MercedesMeResource: "last_update": self._lastupdate, }) - def update(self): - """Fetch new state data for the sensor.""" - result = GetResource(URL_RES_PREFIX + self._href, self._config) - if not "reason" in result: - self._state = result[self._name]["value"] - self._timestamp = result[self._name]["timestamp"] - self._lastupdate = datetime.fromtimestamp(self._timestamp/1000) - self._valid = True - class MercedesMeResources: ######################## -- 2.47.3