Allow float for inital MQTT climate temperature (#97995)

* Allow float for inital MQTT climate temperature

* Update tests/components/mqtt/test_climate.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Jan Bouwhuis 2023-08-08 23:44:49 +02:00 committed by GitHub
parent 25467b573e
commit 5c9bce9eac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -327,7 +327,7 @@ _PLATFORM_SCHEMA_BASE = MQTT_BASE_SCHEMA.extend(
): cv.ensure_list,
vol.Optional(CONF_SWING_MODE_STATE_TEMPLATE): cv.template,
vol.Optional(CONF_SWING_MODE_STATE_TOPIC): valid_subscribe_topic,
vol.Optional(CONF_TEMP_INITIAL): cv.positive_int,
vol.Optional(CONF_TEMP_INITIAL): vol.All(vol.Coerce(float)),
vol.Optional(CONF_TEMP_MIN): vol.Coerce(float),
vol.Optional(CONF_TEMP_MAX): vol.Coerce(float),
vol.Optional(CONF_TEMP_STEP, default=1.0): vol.Coerce(float),

View File

@ -1868,6 +1868,24 @@ async def test_temperature_unit(
DEFAULT_MAX_TEMP,
25,
),
(
help_custom_config(
climate.DOMAIN,
DEFAULT_CONFIG,
(
{
"initial": 68.9, # 20.5 °C
"temperature_unit": "F",
"current_temperature_topic": "current_temperature",
},
),
),
UnitOfTemperature.CELSIUS,
20.5,
DEFAULT_MIN_TEMP,
DEFAULT_MAX_TEMP,
25,
),
(
help_custom_config(
climate.DOMAIN,