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): async def reset_energy_to_code(config, action_id, template_arg, args):
paren = await cg.get_variable(config[CONF_ID]) var = cg.new_Pvariable(action_id, template_arg)
return cg.new_Pvariable(action_id, template_arg, paren) await cg.register_parented(var, config[CONF_ID])
return var
async def to_code(config): async def to_code(config):

View file

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