Skip to content

Commit cd6d971

Browse files
committed
Add step param to OpenthermNumber
1 parent f3dbd12 commit cd6d971

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

components/opentherm/input.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
CONF_max_value = "max_value"
1010
CONF_auto_min_value = "auto_min_value"
1111
CONF_auto_max_value = "auto_max_value"
12+
CONF_step = "step"
1213

1314
OpenthermInput = generate.opentherm_ns.class_("OpenthermInput")
1415

@@ -26,6 +27,8 @@ def input_schema(entity: schema.InputSchema) -> cv.Schema:
2627
schema = schema.extend({ cv.Optional(CONF_auto_min_value, False): cv.boolean })
2728
if CONF_auto_max_value in entity:
2829
schema = schema.extend({ cv.Optional(CONF_auto_max_value, False): cv.boolean })
30+
if CONF_step in entity:
31+
schema = schema.extend({ cv.Optional(CONF_step, False): cv.float_ })
2932
schema = schema.add_extra(validate_min_value_less_than_max_value)
3033
return schema
3134

components/opentherm/number.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import esphome.codegen as cg
44
import esphome.config_validation as cv
55
from esphome.components import number
6-
from esphome.const import CONF_ID, CONF_UNIT_OF_MEASUREMENT
6+
from esphome.const import CONF_ID, CONF_UNIT_OF_MEASUREMENT, CONF_STEP
77

88
from . import const, schema, validate, input, generate
99

@@ -15,15 +15,16 @@
1515
async def new_openthermnumber(config: Dict[str, Any]) -> cg.Pvariable:
1616
var = cg.new_Pvariable(config[CONF_ID])
1717
await cg.register_component(var, config)
18-
await number.register_number(var, config, min_value = config[input.CONF_min_value], max_value = config[input.CONF_max_value])
18+
await number.register_number(var, config, min_value = config[input.CONF_min_value], max_value = config[input.CONF_max_value], step = config[input.CONF_step])
1919
input.generate_setters(var, config)
2020
return var
2121

2222
def get_entity_validation_schema(entity: schema.InputSchema) -> cv.Schema:
2323
return number.NUMBER_SCHEMA \
2424
.extend({
2525
cv.GenerateID(): cv.declare_id(OpenthermNumber),
26-
cv.Optional(CONF_UNIT_OF_MEASUREMENT, entity["unit_of_measurement"]): cv.string_strict
26+
cv.Optional(CONF_UNIT_OF_MEASUREMENT, entity["unit_of_measurement"]): cv.string_strict,
27+
cv.Optional(CONF_STEP, entity["step"]): cv.float_,
2728
}) \
2829
.extend(input.input_schema(entity)) \
2930
.extend(cv.COMPONENT_SCHEMA)

components/opentherm/schema.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ class AutoConfigure(TypedDict):
476476

477477
class InputSchema(EntitySchema):
478478
unit_of_measurement: str
479+
step: float
479480
range: Tuple[int, int]
480481
auto_max_value: NotRequired[AutoConfigure]
481482
auto_min_value: NotRequired[AutoConfigure]
@@ -484,6 +485,7 @@ class InputSchema(EntitySchema):
484485
"t_set": InputSchema({
485486
"description": "Control setpoint: temperature setpoint for the boiler's supply water",
486487
"unit_of_measurement": UNIT_CELSIUS,
488+
"step": 0.1,
487489
"message": "TSet",
488490
"keep_updated": True,
489491
"message_data": "f88",
@@ -493,6 +495,7 @@ class InputSchema(EntitySchema):
493495
"t_set_ch2": InputSchema({
494496
"description": "Control setpoint 2: temperature setpoint for the boiler's supply water on the second heating circuit",
495497
"unit_of_measurement": UNIT_CELSIUS,
498+
"step": 0.1,
496499
"message": "TsetCH2",
497500
"keep_updated": True,
498501
"message_data": "f88",
@@ -502,6 +505,7 @@ class InputSchema(EntitySchema):
502505
"cooling_control": InputSchema({
503506
"description": "Cooling control signal",
504507
"unit_of_measurement": UNIT_PERCENT,
508+
"step": 1.0,
505509
"message": "CoolingControl",
506510
"keep_updated": True,
507511
"message_data": "f88",
@@ -510,6 +514,7 @@ class InputSchema(EntitySchema):
510514
"t_dhw_set": InputSchema({
511515
"description": "Domestic hot water temperature setpoint",
512516
"unit_of_measurement": UNIT_CELSIUS,
517+
"step": 0.1,
513518
"message": "TdhwSet",
514519
"keep_updated": True,
515520
"message_data": "f88",
@@ -520,6 +525,7 @@ class InputSchema(EntitySchema):
520525
"max_t_set": InputSchema({
521526
"description": "Maximum allowable CH water setpoint",
522527
"unit_of_measurement": UNIT_CELSIUS,
528+
"step": 0.1,
523529
"message": "MaxTSet",
524530
"keep_updated": True,
525531
"message_data": "f88",
@@ -530,6 +536,7 @@ class InputSchema(EntitySchema):
530536
"t_room_set": InputSchema({
531537
"description": "Current room temperature setpoint (informational)",
532538
"unit_of_measurement": UNIT_CELSIUS,
539+
"step": 0.1,
533540
"message": "TrSet",
534541
"keep_updated": True,
535542
"message_data": "f88",
@@ -538,6 +545,7 @@ class InputSchema(EntitySchema):
538545
"t_room_set_ch2": InputSchema({
539546
"description": "Current room temperature setpoint on CH2 (informational)",
540547
"unit_of_measurement": UNIT_CELSIUS,
548+
"step": 0.1,
541549
"message": "TrSetCH2",
542550
"keep_updated": True,
543551
"message_data": "f88",
@@ -546,6 +554,7 @@ class InputSchema(EntitySchema):
546554
"t_room": InputSchema({
547555
"description": "Current sensed room temperature (informational)",
548556
"unit_of_measurement": UNIT_CELSIUS,
557+
"step": 0.1,
549558
"message": "Tr",
550559
"keep_updated": True,
551560
"message_data": "f88",

0 commit comments

Comments
 (0)