def extra_state_attributes(self): """Return the attributes of the sensor.""" return { ATTR_FEEDID: self._elem["id"], ATTR_TAG: self._elem["tag"], ATTR_FEEDNAME: self._elem["name"], ATTR_SIZE: self._elem["size"], ATTR_USERID: self._elem["userid"], ATTR_LASTUPDATETIME: self._elem["time"], ATTR_LASTUPDATETIMESTR: template.timestamp_local(float(self._elem["time"])), }
def device_state_attributes(self): """Return the atrributes of the sensor.""" return { ATTR_FEEDID: self._elem["id"], ATTR_TAG: self._elem["tag"], ATTR_FEEDNAME: self._elem["name"], ATTR_SIZE: self._elem["size"], ATTR_USERID: self._elem["userid"], ATTR_LASTUPDATETIME: self._elem["time"], ATTR_LASTUPDATETIMESTR: template.timestamp_local( float(self._elem["time"])), }
def alerts(self): alarms = self._api.alerts() if alarms: # filter alerts = [ m for m in alarms if m["awareness_type"] in self._awareness_types ] # change to local date/time (drop the seconds) for alert in alerts: try: alert["from"] = timestamp_local(as_timestamp( alert["from"]))[:-3] alert["until"] = timestamp_local( as_timestamp(alert["until"]))[:-3] alert["published"] = timestamp_local( as_timestamp(alert["published"]))[:-3] except ValueError: _LOGGER.error("Not possible to convert to local time") alarms = alerts return alarms
def _local_ts(iso_ts): """Change to local date/time and drop the seconds.""" return timestamp_local(as_timestamp(iso_ts))[:-3]