tlskinneriv / awnet_local

Enables local support for Ambient Weather personal weather stations.
27 stars 5 forks source link

TypeError: unsupported operand type(s) for -: 'float' and 'str' #29

Closed asayler closed 1 year ago

asayler commented 1 year ago

Integration Version:

v1.1.1

Home Assistant Version:

2023.06.2

Describe the bug There seems to be a type error that is getting thrown a number of times in the logs in this integration, perhaps related to lightning sensor handling. See below.

To Reproduce

Install awnet_local and associated add on, then add a local weather station with a lightning sensor.

Expected behavior

Error is not raised.

Screenshots

N/A

Additional context

N/A

Debug log output from the integration

2023-06-15 23:38:35.742 ERROR (MainThread) [homeassistant.util.logging] Exception in update when dispatching 'awnet_local_data_update_aa:bb:cc:dd:ee:ff': ()
Traceback (most recent call last):
File "/config/custom_components/awnet_local/__init__.py", line 268, in update
self.update_from_latest_data()
File "/config/custom_components/awnet_local/sensor.py", line 79, in update_from_latest_data
raw = AmbientSensorCalculations.calculate(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/awnet_local/helpers_calc.py", line 84, in calculate
return AmbientSensorCalculations.lightning_hour(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/awnet_local/helpers_calc.py", line 191, in lightning_hour
lightning_data_closest_times = {
^
File "/config/custom_components/awnet_local/helpers_calc.py", line 192, in <dictcomp>
abs(search_datetime.timestamp() - test_datetime): datetime.fromtimestamp(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'float' and 'str'