mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 07:47:08 +00:00
Fix step in presets for generic thermostat (#128922)
This commit is contained in:
parent
f8e6fb81d6
commit
3ddef56167
@ -62,7 +62,7 @@ OPTIONS_SCHEMA = {
|
|||||||
PRESETS_SCHEMA = {
|
PRESETS_SCHEMA = {
|
||||||
vol.Optional(v): selector.NumberSelector(
|
vol.Optional(v): selector.NumberSelector(
|
||||||
selector.NumberSelectorConfig(
|
selector.NumberSelectorConfig(
|
||||||
mode=selector.NumberSelectorMode.BOX, unit_of_measurement=DEGREE
|
mode=selector.NumberSelectorMode.BOX, unit_of_measurement=DEGREE, step=0.1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for v in CONF_PRESETS.values()
|
for v in CONF_PRESETS.values()
|
||||||
|
@ -18,6 +18,25 @@
|
|||||||
'type': <FlowResultType.FORM: 'form'>,
|
'type': <FlowResultType.FORM: 'form'>,
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_config_flow_preset_accepts_float[create_entry]
|
||||||
|
FlowResultSnapshot({
|
||||||
|
'result': ConfigEntrySnapshot({
|
||||||
|
'title': 'My thermostat',
|
||||||
|
}),
|
||||||
|
'title': 'My thermostat',
|
||||||
|
'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_config_flow_preset_accepts_float[init]
|
||||||
|
FlowResultSnapshot({
|
||||||
|
'type': <FlowResultType.FORM: 'form'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_config_flow_preset_accepts_float[presets]
|
||||||
|
FlowResultSnapshot({
|
||||||
|
'type': <FlowResultType.FORM: 'form'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_options[create_entry]
|
# name: test_options[create_entry]
|
||||||
FlowResultSnapshot({
|
FlowResultSnapshot({
|
||||||
'result': True,
|
'result': True,
|
||||||
|
@ -132,3 +132,51 @@ async def test_options(hass: HomeAssistant, snapshot: SnapshotAssertion) -> None
|
|||||||
# Check config entry is reloaded with new options
|
# Check config entry is reloaded with new options
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert hass.states.get("climate.my_thermostat") == snapshot(name="without_away")
|
assert hass.states.get("climate.my_thermostat") == snapshot(name="without_away")
|
||||||
|
|
||||||
|
|
||||||
|
async def test_config_flow_preset_accepts_float(
|
||||||
|
hass: HomeAssistant, snapshot: SnapshotAssertion
|
||||||
|
) -> None:
|
||||||
|
"""Test the config flow with preset is a float."""
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.generic_thermostat.async_setup_entry",
|
||||||
|
return_value=True,
|
||||||
|
) as mock_setup_entry:
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
|
)
|
||||||
|
assert result == snapshot(name="init", include=SNAPSHOT_FLOW_PROPS)
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
result["flow_id"],
|
||||||
|
{
|
||||||
|
CONF_NAME: "My thermostat",
|
||||||
|
CONF_HEATER: "switch.run",
|
||||||
|
CONF_SENSOR: "sensor.temperature",
|
||||||
|
CONF_AC_MODE: False,
|
||||||
|
CONF_COLD_TOLERANCE: 0.3,
|
||||||
|
CONF_HOT_TOLERANCE: 0.3,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert result == snapshot(name="presets", include=SNAPSHOT_FLOW_PROPS)
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
result["flow_id"],
|
||||||
|
user_input={
|
||||||
|
CONF_PRESETS[PRESET_AWAY]: 10.4,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert result == snapshot(name="create_entry", include=SNAPSHOT_FLOW_PROPS)
|
||||||
|
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
assert result["options"] == {
|
||||||
|
"ac_mode": False,
|
||||||
|
"away_temp": 10.4,
|
||||||
|
"cold_tolerance": 0.3,
|
||||||
|
"heater": "switch.run",
|
||||||
|
"hot_tolerance": 0.3,
|
||||||
|
"name": "My thermostat",
|
||||||
|
"target_sensor": "sensor.temperature",
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user