Skip to content

Commit

Permalink
Change Ambient solar radiation units to lx (home-assistant#24690)
Browse files Browse the repository at this point in the history
  • Loading branch information
bachya authored Jun 22, 2019
1 parent 729df11 commit 40fa446
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/ambient_station/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
TYPE_SOILTEMP7F: ('Soil Temp 7', '°F', TYPE_SENSOR, 'temperature'),
TYPE_SOILTEMP8F: ('Soil Temp 8', '°F', TYPE_SENSOR, 'temperature'),
TYPE_SOILTEMP9F: ('Soil Temp 9', '°F', TYPE_SENSOR, 'temperature'),
TYPE_SOLARRADIATION: ('Solar Rad', 'W/m^2', TYPE_SENSOR, None),
TYPE_SOLARRADIATION: ('Solar Rad', 'lx', TYPE_SENSOR, 'illuminance'),
TYPE_TEMP10F: ('Temp 10', '°F', TYPE_SENSOR, 'temperature'),
TYPE_TEMP1F: ('Temp 1', '°F', TYPE_SENSOR, 'temperature'),
TYPE_TEMP2F: ('Temp 2', '°F', TYPE_SENSOR, 'temperature'),
Expand Down
12 changes: 10 additions & 2 deletions homeassistant/components/ambient_station/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from homeassistant.const import ATTR_NAME

from . import SENSOR_TYPES, AmbientWeatherEntity
from . import SENSOR_TYPES, TYPE_SOLARRADIATION, AmbientWeatherEntity
from .const import ATTR_LAST_DATA, DATA_CLIENT, DOMAIN, TYPE_SENSOR

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -61,5 +61,13 @@ def unit_of_measurement(self):

async def async_update(self):
"""Fetch new state data for the sensor."""
self._state = self._ambient.stations[
new_state = self._ambient.stations[
self._mac_address][ATTR_LAST_DATA].get(self._sensor_type)

if self._sensor_type == TYPE_SOLARRADIATION:
# Ambient's units for solar radiation (illuminance) are
# W/m^2; since those aren't commonly used in the HASS
# world, transform them to lx:
self._state = round(float(new_state)/0.0079)
else:
self._state = new_state

0 comments on commit 40fa446

Please sign in to comment.