Require step to be set when calling register_number (#4622)

This commit is contained in:
Jesse Hills 2023-03-27 11:44:56 +13:00 committed by GitHub
parent 806e43c34c
commit e542e75b9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -204,14 +204,13 @@ def number_schema(
async def setup_number_core_(
var, config, *, min_value: float, max_value: float, step: Optional[float]
var, config, *, min_value: float, max_value: float, step: float
):
await setup_entity(var, config)
cg.add(var.traits.set_min_value(min_value))
cg.add(var.traits.set_max_value(max_value))
if step is not None:
cg.add(var.traits.set_step(step))
cg.add(var.traits.set_step(step))
cg.add(var.traits.set_mode(config[CONF_MODE]))
@ -239,7 +238,7 @@ async def setup_number_core_(
async def register_number(
var, config, *, min_value: float, max_value: float, step: Optional[float] = None
var, config, *, min_value: float, max_value: float, step: float
):
if not CORE.has_id(config[CONF_ID]):
var = cg.Pvariable(config[CONF_ID], var)