diff --git a/custom_components/super_soco_custom/const.py b/custom_components/super_soco_custom/const.py index d015406..943b289 100644 --- a/custom_components/super_soco_custom/const.py +++ b/custom_components/super_soco_custom/const.py @@ -43,11 +43,9 @@ POWER_OFF_DISTANCE_THRESHOLD_METERS = 16 POWER_ON_UPDATE_SECONDS = 5 SECONDS_IN_A_MINUTE = 60 -SECONDS_IN_AN_HOUR = 3600 SIGNAL_MAX_STRENGTH = 4 # It goes from 0 to 4 SUPER_SOCO = "super_soco" SWITCH_REFRESH_SLEEP_SECONDS = 10 -UTC_TO_SHANGHAI_HOURS_DIFFERENCE = 8 VMOTO_SOCO = "vmoto_soco" # Directions of travel diff --git a/custom_components/super_soco_custom/coordinator.py b/custom_components/super_soco_custom/coordinator.py index b95fe0c..dfb5217 100644 --- a/custom_components/super_soco_custom/coordinator.py +++ b/custom_components/super_soco_custom/coordinator.py @@ -213,7 +213,6 @@ async def _async_update_data(self): DATA_ECU_BATTERY: device_data[DATA_ECU_BATTERY], DATA_LAST_GPS_TIME: parse_timestamp( device_data[DATA_LAST_GPS_TIME], - False, ), DATA_MODEL_NAME: self._user_data[DATA_USER_BIND_DEVICE][ DATA_MODEL_NAME @@ -453,11 +452,9 @@ async def _get_last_trip_data(self) -> dict: ), DATA_LAST_TRIP_BEGIN_TIME: parse_timestamp( trip[DATA_LAST_TRIP_BEGIN_TIME], - True, ), DATA_LAST_TRIP_END_TIME: parse_timestamp( trip[DATA_LAST_TRIP_END_TIME], - True, ), DATA_LAST_TRIP_RIDE_DISTANCE: round( trip[DATA_LAST_TRIP_MILEAGE], DISTANCE_ROUNDING_DECIMALS @@ -548,7 +545,6 @@ async def _get_last_warning_data(self) -> dict: data = { DATA_LAST_WARNING_TIME: parse_timestamp( warning[DATA_CREATE_TIME], - False, ), } else: diff --git a/custom_components/super_soco_custom/helpers.py b/custom_components/super_soco_custom/helpers.py index 4c84798..77b5525 100644 --- a/custom_components/super_soco_custom/helpers.py +++ b/custom_components/super_soco_custom/helpers.py @@ -12,8 +12,6 @@ DEFAULT_FLOAT, METERS_IN_EARTH_RADIUS, MILLISECONDS_IN_A_SECOND, - SECONDS_IN_AN_HOUR, - UTC_TO_SHANGHAI_HOURS_DIFFERENCE, ) @@ -77,10 +75,7 @@ def parse_date(date_string: str) -> datetime: return datetime.strptime(clean_string, "%d/%m/%Y %H:%M%z") -def parse_timestamp(timestampMilliseconds: int, fix_timezone: bool = False) -> datetime: +def parse_timestamp(timestampMilliseconds: int) -> datetime: timestamp = timestampMilliseconds / MILLISECONDS_IN_A_SECOND - if fix_timezone: - timestamp += UTC_TO_SHANGHAI_HOURS_DIFFERENCE * SECONDS_IN_AN_HOUR - return datetime.fromtimestamp(timestamp, tz=pytz.UTC) diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 83edfea..cfae59e 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -17,9 +17,6 @@ def test_calculate_course(): def test_parse_timestamp(): """Test parse_timestamp.""" - assert parse_timestamp(1681423654000, True) == datetime.datetime( - 2023, 4, 14, 6, 7, 34, tzinfo=pytz.UTC - ) assert parse_timestamp(1681423654000) == datetime.datetime( 2023, 4, 13, 22, 7, 34, tzinfo=pytz.UTC )