From: Giorgio Ravera Date: Mon, 7 Dec 2020 15:02:21 +0000 (+0100) Subject: Fixed issue: in query.py, _config is not defined X-Git-Tag: v0.5~1 X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=2856021133b90475896fe2994cce9047b0516704;p=mercedes_me_api.git Fixed issue: in query.py, _config is not defined --- 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: ########################