From 51857f2afeeb881fc8e80b1b21150fe5a96e4064 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Fri, 24 Nov 2023 17:41:34 +0000 Subject: [PATCH] Remove beat --- .../components/time_date/config_flow.py | 2 ++ homeassistant/components/time_date/const.py | 1 - homeassistant/components/time_date/sensor.py | 24 ++----------------- .../components/time_date/strings.json | 4 ---- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/homeassistant/components/time_date/config_flow.py b/homeassistant/components/time_date/config_flow.py index 5cdc04645d5f6..e5d0129b5ebef 100644 --- a/homeassistant/components/time_date/config_flow.py +++ b/homeassistant/components/time_date/config_flow.py @@ -43,6 +43,8 @@ async def validate_input( hass = async_get_hass() if hass.config.time_zone is None: raise SchemaFlowError("timezone_not_exist") + if user_input.get("beat"): + user_input.pop("beat") return user_input diff --git a/homeassistant/components/time_date/const.py b/homeassistant/components/time_date/const.py index d01d1025e1ec6..e52ce822a6c0b 100644 --- a/homeassistant/components/time_date/const.py +++ b/homeassistant/components/time_date/const.py @@ -17,6 +17,5 @@ "date_time_utc", "date_time_iso", "time_date", - "beat", "time_utc", ] diff --git a/homeassistant/components/time_date/sensor.py b/homeassistant/components/time_date/sensor.py index 95a3158901f3e..5fa20d464f9b2 100644 --- a/homeassistant/components/time_date/sensor.py +++ b/homeassistant/components/time_date/sensor.py @@ -134,13 +134,8 @@ def get_next_interval(self) -> datetime: tomorrow = dt_util.as_local(now) + timedelta(days=1) return dt_util.start_of_local_day(tomorrow) - if self.type == "beat": - # Add 1 hour because @0 beats is at 23:00:00 UTC. - timestamp = dt_util.as_timestamp(now + timedelta(hours=1)) - interval = 86.4 - else: - timestamp = dt_util.as_timestamp(now) - interval = 60 + timestamp = dt_util.as_timestamp(now) + interval = 60 delta = interval - (timestamp % interval) next_interval = now + timedelta(seconds=delta) @@ -166,21 +161,6 @@ def _update_internal_state(self, time_date: datetime) -> None: self._state = f"{time}, {date}" elif self.type == "time_utc": self._state = time_utc - elif self.type == "beat": - # Calculate Swatch Internet Time. - time_bmt = time_date + timedelta(hours=1) - delta = timedelta( - hours=time_bmt.hour, - minutes=time_bmt.minute, - seconds=time_bmt.second, - microseconds=time_bmt.microsecond, - ) - - # Use integers to better handle rounding. For example, - # int(63763.2/86.4) = 737 but 637632//864 = 738. - beat = int(delta.total_seconds() * 10) // 864 - - self._state = f"@{beat:03d}" elif self.type == "date_time_iso" and ( _datetime := dt_util.parse_datetime(f"{date} {time}") ): diff --git a/homeassistant/components/time_date/strings.json b/homeassistant/components/time_date/strings.json index 290d5a6b70ebc..e58cfb768ef43 100644 --- a/homeassistant/components/time_date/strings.json +++ b/homeassistant/components/time_date/strings.json @@ -32,7 +32,6 @@ "date_time_utc": "Date & Time (UTC)", "date_time_iso": "Date & Time (ISO)", "time_date": "Time & Date", - "beat": "Internet time", "time_utc": "Time (UTC)" } } @@ -57,9 +56,6 @@ "time_date": { "name": "[%key:component::time_date::selector::display_options::options::time_date%]" }, - "beat": { - "name": "[%key:component::time_date::selector::display_options::options::beat%]" - }, "time_utc": { "name": "[%key:component::time_date::selector::display_options::options::time_utc%]" }