Sonoff S31 Tasmota

Trying to play around with the Tasmota commands.
I want each month to reset the power useage figures back to 0.

I can do it manually but does anyone have an example of how to properly write the code for an automation to send the “energyreset1 0” command?
Just unsure…

As starting point you might setup a condition like this:

condition:
    condition: template
    value_template : '{{(now().strftime("%d")|int==1)}}'

This will be true on each 1st day of a month. The action triggered is your command to send.
Just be sure the other trigger’ criterias meet only once, so you won’t end up with continuous firing. I.e. check the power usage is > 0.

Thanks mate. I’m away from home at the moment and can’t get into samba but I do have the trigger if the day equals the first.
Actually reading now I think similar to what you have there but just for the trigger.

you can shorten that up to:

{{(now().day == 1)}}

and get the same result.

# Power Usage Reset
- alias: S31 Power Usage Reset
  initial_state: on
  trigger:
    - platform: template
      value_template: '{{ now().strftime("%d") == "1" }}'
  condition: []
  action:
    - service: persistent_notification.create
      data_template:
        message: "For {{now().month}}/{{now().year}}: The Kettle used ${{states ('sensor.kettle_monthly_cost') }}"
        title: "Kettle Useage"  
  - service: mqtt.publish
    data_template:
      topic: "cmnd/kettle/energyreset1"
      payload: "0"
  - service: mqtt.publish
    data_template:
      topic: "cmnd/kettle/energyreset2"
      payload: "0"
  - service: mqtt.publish
    data_template:
      topic: "cmnd/kettle/energyreset3"
      payload: "0"
1 Like

Perfect, thanks!
But in persistent notification would have to put something like {{ now().month -1 }} ¿?¿?