Skip to content

Commit

Permalink
Remove redundant str cast - sensor value conversion (home-assistant#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Aug 25, 2021
1 parent d4064e7 commit 1224d68
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def state(self) -> Any:
# Suppress ValueError (Could not convert sensor_value to float)
with suppress(ValueError):
temp = units.temperature(float(value), unit_of_measurement)
value = str(round(temp) if prec == 0 else round(temp, prec))
value = round(temp) if prec == 0 else round(temp, prec)

return value

Expand Down
2 changes: 1 addition & 1 deletion tests/components/mhz19/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ async def test_temperature_sensor_f(mock_function, hass):
sensor.hass = hass
sensor.update()

assert sensor.state == "75"
assert sensor.state == 75

0 comments on commit 1224d68

Please sign in to comment.