Skip to content

Commit

Permalink
Validate temp as float or integer
Browse files Browse the repository at this point in the history
Validate temp as float or integer prior to adding the variable
  • Loading branch information
kayjei authored Mar 28, 2022
1 parent d7cb968 commit 47191d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/badtemp_karlskrona/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
lon = str(jsonr["geometryArea"]["x"])
timestamp = datetime.datetime.strptime(str(jsonr["timeStamp"]).split('.')[0], "%Y-%m-%dT%H:%M:%S")

if isinstance(jsonr["temperatureWater"], float):
if isinstance(jsonr["temperatureWater"], float) or isinstance(jsonr["temperatureWater"], int):
temp = float(round(jsonr["temperatureWater"], 1))
devices.append(SensorDevice(id, temp, lat, lon, timestamp, name, poller_entity))
_LOGGER.info("Adding sensor: " + str(id))
Expand Down

0 comments on commit 47191d8

Please sign in to comment.