[ags10] Fix wrong type passed to cg.templatable for set_zero_point mode (#15467)

This commit is contained in:
Jonathan Swoboda
2026-04-05 22:48:00 -04:00
committed by GitHub
parent 07f6be679f
commit aac74f4c94
2 changed files with 18 additions and 3 deletions

View File

@@ -112,7 +112,9 @@ AGS10_SET_ZERO_POINT_ACTION_MODE = {
AGS10_SET_ZERO_POINT_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.use_id(AGS10Component),
cv.Required(CONF_MODE): cv.enum(AGS10_SET_ZERO_POINT_ACTION_MODE, upper=True),
cv.Required(CONF_MODE): cv.templatable(
cv.enum(AGS10_SET_ZERO_POINT_ACTION_MODE, upper=True)
),
cv.Optional(CONF_VALUE, default=0xFFFF): cv.templatable(cv.uint16_t),
},
)
@@ -127,8 +129,10 @@ AGS10_SET_ZERO_POINT_SCHEMA = cv.Schema(
async def ags10setzeropoint_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg)
await cg.register_parented(var, config[CONF_ID])
mode = await cg.templatable(config.get(CONF_MODE), args, enumerate)
mode = await cg.templatable(
config.get(CONF_MODE), args, AGS10SetZeroPointActionMode
)
cg.add(var.set_mode(mode))
value = await cg.templatable(config[CONF_VALUE], args, int)
value = await cg.templatable(config[CONF_VALUE], args, cg.uint16)
cg.add(var.set_value(value))
return var

View File

@@ -4,3 +4,14 @@ sensor:
tvoc:
name: AGS10 TVOC
update_interval: 60s
button:
- platform: template
name: "Test AGS10 Actions"
on_press:
- ags10.set_zero_point:
id: ags10_1
mode: CURRENT_VALUE
- ags10.new_i2c_address:
id: ags10_1
address: 0x1A