Skip to content

Commit

Permalink
Add check for larger numbers when parsing unix timestamp values #110
Browse files Browse the repository at this point in the history
  • Loading branch information
fsaris committed Apr 15, 2024
1 parent d99fc19 commit 005772c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion custom_components/zonneplan_one/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,10 @@ def _value_from_coordinator(self):
if self.entity_description.device_class == SensorDeviceClass.TIMESTAMP:
if isinstance(value, str):
value = dt_util.parse_datetime(value)
else:
elif value > 100000000000000:
value = datetime.fromtimestamp(value/1000000, timezone('Europe/Amsterdam'))
else:
value = datetime.fromtimestamp(value/1000, timezone('Europe/Amsterdam'))

if self.entity_description.value_factor:
value = value * self.entity_description.value_factor
Expand Down

0 comments on commit 005772c

Please sign in to comment.