fix bl0906 reset energy action (#7488)

Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
Samuel Sieb 2024-09-24 17:50:44 -07:00 committed by Jesse Hills
parent 1f8037d5bc
commit 4332301dbb
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
2 changed files with 10 additions and 2 deletions

View file

@ -145,8 +145,9 @@ FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema(
),
)
async def reset_energy_to_code(config, action_id, template_arg, args):
paren = await cg.get_variable(config[CONF_ID])
return cg.new_Pvariable(action_id, template_arg, paren)
var = cg.new_Pvariable(action_id, template_arg)
await cg.register_parented(var, config[CONF_ID])
return var
async def to_code(config):

View file

@ -8,6 +8,7 @@ uart:
sensor:
- platform: bl0906
id: bl
frequency:
name: 'Frequency'
temperature:
@ -60,3 +61,9 @@ sensor:
name: 'Total_Energy'
total_power:
name: 'Total_Power'
button:
- platform: template
id: reset
on_press:
- bl0906.reset_energy: bl