mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Fix default elkm1 temp units (#34274)
This commit is contained in:
parent
cd3fc7c76d
commit
97609576cb
@ -15,6 +15,8 @@ from homeassistant.const import (
|
||||
CONF_PASSWORD,
|
||||
CONF_TEMPERATURE_UNIT,
|
||||
CONF_USERNAME,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
@ -23,6 +25,8 @@ from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
BARE_TEMP_CELSIUS,
|
||||
BARE_TEMP_FAHRENHEIT,
|
||||
CONF_AREA,
|
||||
CONF_AUTO_CONFIGURE,
|
||||
CONF_COUNTER,
|
||||
@ -119,7 +123,10 @@ DEVICE_SCHEMA = vol.Schema(
|
||||
vol.Optional(CONF_USERNAME, default=""): cv.string,
|
||||
vol.Optional(CONF_PASSWORD, default=""): cv.string,
|
||||
vol.Optional(CONF_AUTO_CONFIGURE, default=False): cv.boolean,
|
||||
vol.Optional(CONF_TEMPERATURE_UNIT, default="F"): cv.temperature_unit,
|
||||
# cv.temperature_unit will mutate 'C' -> '°C' and 'F' -> '°F'
|
||||
vol.Optional(
|
||||
CONF_TEMPERATURE_UNIT, default=BARE_TEMP_FAHRENHEIT
|
||||
): cv.temperature_unit,
|
||||
vol.Optional(CONF_AREA, default={}): DEVICE_SCHEMA_SUBDOMAIN,
|
||||
vol.Optional(CONF_COUNTER, default={}): DEVICE_SCHEMA_SUBDOMAIN,
|
||||
vol.Optional(CONF_KEYPAD, default={}): DEVICE_SCHEMA_SUBDOMAIN,
|
||||
@ -187,7 +194,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
|
||||
_LOGGER.debug("Setting up elkm1 %s", conf["host"])
|
||||
|
||||
config = {"temperature_unit": conf[CONF_TEMPERATURE_UNIT]}
|
||||
temperature_unit = TEMP_FAHRENHEIT
|
||||
if conf[CONF_TEMPERATURE_UNIT] in (BARE_TEMP_CELSIUS, TEMP_CELSIUS):
|
||||
temperature_unit = TEMP_CELSIUS
|
||||
|
||||
config = {"temperature_unit": temperature_unit}
|
||||
|
||||
if not conf[CONF_AUTO_CONFIGURE]:
|
||||
# With elkm1-lib==0.7.16 and later auto configure is available
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.components.climate.const import (
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.const import PRECISION_WHOLE, STATE_ON, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.const import PRECISION_WHOLE, STATE_ON
|
||||
|
||||
from . import ElkEntity, create_elk_entities
|
||||
from .const import DOMAIN
|
||||
@ -55,7 +55,7 @@ class ElkThermostat(ElkEntity, ClimateDevice):
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
"""Return the temperature unit."""
|
||||
return TEMP_FAHRENHEIT if self._temperature_unit == "F" else TEMP_CELSIUS
|
||||
return self._temperature_unit
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
|
@ -13,6 +13,8 @@ from homeassistant.const import (
|
||||
CONF_PROTOCOL,
|
||||
CONF_TEMPERATURE_UNIT,
|
||||
CONF_USERNAME,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
)
|
||||
from homeassistant.util import slugify
|
||||
|
||||
@ -33,7 +35,9 @@ DATA_SCHEMA = vol.Schema(
|
||||
vol.Optional(CONF_USERNAME, default=""): str,
|
||||
vol.Optional(CONF_PASSWORD, default=""): str,
|
||||
vol.Optional(CONF_PREFIX, default=""): str,
|
||||
vol.Optional(CONF_TEMPERATURE_UNIT, default="F"): vol.In(["F", "C"]),
|
||||
vol.Optional(CONF_TEMPERATURE_UNIT, default=TEMP_FAHRENHEIT): vol.In(
|
||||
[TEMP_FAHRENHEIT, TEMP_CELSIUS]
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -18,6 +18,9 @@ CONF_ZONE = "zone"
|
||||
CONF_PREFIX = "prefix"
|
||||
|
||||
|
||||
BARE_TEMP_FAHRENHEIT = "F"
|
||||
BARE_TEMP_CELSIUS = "C"
|
||||
|
||||
ELK_ELEMENTS = {
|
||||
CONF_AREA: Max.AREAS.value,
|
||||
CONF_COUNTER: Max.COUNTERS.value,
|
||||
|
@ -39,7 +39,7 @@ async def test_form_user_with_secure_elk(hass):
|
||||
"address": "1.2.3.4",
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"temperature_unit": "F",
|
||||
"temperature_unit": "°F",
|
||||
"prefix": "",
|
||||
},
|
||||
)
|
||||
@ -51,7 +51,7 @@ async def test_form_user_with_secure_elk(hass):
|
||||
"host": "elks://1.2.3.4",
|
||||
"password": "test-password",
|
||||
"prefix": "",
|
||||
"temperature_unit": "F",
|
||||
"temperature_unit": "°F",
|
||||
"username": "test-username",
|
||||
}
|
||||
await hass.async_block_till_done()
|
||||
@ -82,7 +82,7 @@ async def test_form_user_with_non_secure_elk(hass):
|
||||
{
|
||||
"protocol": "non-secure",
|
||||
"address": "1.2.3.4",
|
||||
"temperature_unit": "F",
|
||||
"temperature_unit": "°F",
|
||||
"prefix": "guest_house",
|
||||
},
|
||||
)
|
||||
@ -95,7 +95,7 @@ async def test_form_user_with_non_secure_elk(hass):
|
||||
"prefix": "guest_house",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"temperature_unit": "F",
|
||||
"temperature_unit": "°F",
|
||||
}
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
@ -125,7 +125,7 @@ async def test_form_user_with_serial_elk(hass):
|
||||
{
|
||||
"protocol": "serial",
|
||||
"address": "/dev/ttyS0:115200",
|
||||
"temperature_unit": "F",
|
||||
"temperature_unit": "°C",
|
||||
"prefix": "",
|
||||
},
|
||||
)
|
||||
@ -138,7 +138,7 @@ async def test_form_user_with_serial_elk(hass):
|
||||
"prefix": "",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"temperature_unit": "F",
|
||||
"temperature_unit": "°C",
|
||||
}
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
@ -166,7 +166,7 @@ async def test_form_cannot_connect(hass):
|
||||
"address": "1.2.3.4",
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"temperature_unit": "F",
|
||||
"temperature_unit": "°F",
|
||||
"prefix": "",
|
||||
},
|
||||
)
|
||||
@ -193,7 +193,7 @@ async def test_form_invalid_auth(hass):
|
||||
"address": "1.2.3.4",
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"temperature_unit": "F",
|
||||
"temperature_unit": "°F",
|
||||
"prefix": "",
|
||||
},
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user