mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Add fahrenheit support in miflora sensor (#33136)
* add support for fahrenheit in miflora sensor * fix error introduced when resolving merge conflict * fix formatting
This commit is contained in:
parent
f0472f2dc2
commit
ab8c50895e
@ -16,12 +16,14 @@ from homeassistant.const import (
|
|||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
|
TEMP_FAHRENHEIT,
|
||||||
UNIT_PERCENTAGE,
|
UNIT_PERCENTAGE,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
from homeassistant.util.temperature import celsius_to_fahrenheit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import bluepy.btle # noqa: F401 pylint: disable=unused-import
|
import bluepy.btle # noqa: F401 pylint: disable=unused-import
|
||||||
@ -93,7 +95,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
|
|
||||||
for parameter in config[CONF_MONITORED_CONDITIONS]:
|
for parameter in config[CONF_MONITORED_CONDITIONS]:
|
||||||
name = SENSOR_TYPES[parameter][0]
|
name = SENSOR_TYPES[parameter][0]
|
||||||
unit = SENSOR_TYPES[parameter][1]
|
unit = (
|
||||||
|
hass.config.units.temperature_unit
|
||||||
|
if parameter == "temperature"
|
||||||
|
else SENSOR_TYPES[parameter][1]
|
||||||
|
)
|
||||||
icon = SENSOR_TYPES[parameter][2]
|
icon = SENSOR_TYPES[parameter][2]
|
||||||
|
|
||||||
prefix = config.get(CONF_NAME)
|
prefix = config.get(CONF_NAME)
|
||||||
@ -208,6 +214,8 @@ class MiFloraSensor(Entity):
|
|||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
_LOGGER.debug("%s = %s", self.name, data)
|
_LOGGER.debug("%s = %s", self.name, data)
|
||||||
|
if self._unit == TEMP_FAHRENHEIT:
|
||||||
|
data = celsius_to_fahrenheit(data)
|
||||||
self.data.append(data)
|
self.data.append(data)
|
||||||
self.last_successful_update = dt_util.utcnow()
|
self.last_successful_update = dt_util.utcnow()
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user