def update(self):
Get the latest data and updates the states.
time_date = dt_util.utcnow()
time = dt_util.datetime_to_time_str(dt_util.as_local(time_date))
time_utc = dt_util.datetime_to_time_str(time_date)
date = dt_util.datetime_to_date_str(dt_util.as_local(time_date))
// Calculate the beat (Swatch Internet Time) time without date.
hours, minutes, seconds = time_date.strftime("%H:%M:%S").split(":")
beat = ((int(seconds) + (int(minutes) * 60) + ((int(hours) + 1) *
3600)) / 86.4)
if self.type == "time":
self._state = time
elif self.type == "date":
self._state = date
elif self.type == "date_time":
After Change
def update(self):
Get the latest data and updates the states.
time_date = dt_util.utcnow()
time = dt_util.as_local(time_date).strftime(TIME_STR_FORMAT)
time_utc = time_date.strftime(TIME_STR_FORMAT)
date = dt_util.as_local(time_date).date().isoformat()
// Calculate the beat (Swatch Internet Time) time without date.
hours, minutes, seconds = time_date.strftime("%H:%M:%S").split(":")
beat = ((int(seconds) + (int(minutes) * 60) + ((int(hours) + 1) *
3600)) / 86.4)
if self.type == "time":
self._state = time
elif self.type == "date":
self._state = date
elif self.type == "date_time":