mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Change Ambient solar radiation units to lx (#24690)
This commit is contained in:
parent
729df112a7
commit
40fa4463de
@ -183,7 +183,7 @@ SENSOR_TYPES = {
|
|||||||
TYPE_SOILTEMP7F: ('Soil Temp 7', '°F', TYPE_SENSOR, 'temperature'),
|
TYPE_SOILTEMP7F: ('Soil Temp 7', '°F', TYPE_SENSOR, 'temperature'),
|
||||||
TYPE_SOILTEMP8F: ('Soil Temp 8', '°F', TYPE_SENSOR, 'temperature'),
|
TYPE_SOILTEMP8F: ('Soil Temp 8', '°F', TYPE_SENSOR, 'temperature'),
|
||||||
TYPE_SOILTEMP9F: ('Soil Temp 9', '°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_TEMP10F: ('Temp 10', '°F', TYPE_SENSOR, 'temperature'),
|
||||||
TYPE_TEMP1F: ('Temp 1', '°F', TYPE_SENSOR, 'temperature'),
|
TYPE_TEMP1F: ('Temp 1', '°F', TYPE_SENSOR, 'temperature'),
|
||||||
TYPE_TEMP2F: ('Temp 2', '°F', TYPE_SENSOR, 'temperature'),
|
TYPE_TEMP2F: ('Temp 2', '°F', TYPE_SENSOR, 'temperature'),
|
||||||
|
@ -3,7 +3,7 @@ import logging
|
|||||||
|
|
||||||
from homeassistant.const import ATTR_NAME
|
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
|
from .const import ATTR_LAST_DATA, DATA_CLIENT, DOMAIN, TYPE_SENSOR
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -61,5 +61,13 @@ class AmbientWeatherSensor(AmbientWeatherEntity):
|
|||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Fetch new state data for the sensor."""
|
"""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)
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user