Power management in-between events (Octoprint/Shelly)

Hi, I’m looking for ideas on how to implement an automation that could measure the energy/cost of my 3d prints.
For instance, when a sensor changes from Operational to Printing start measuring the energy and when the state changes from printing to operational it would get the power consumed, do the math for the cost and store it somewhere.

Would this be achievable by using templates? or is there a better way of doing?

Thanks in advance

The easiest way would be an energy monitoring smart plug.

Create a utility meter with two tariffs; working and standby.

utility_meter:
  octoprint_energy:
    source: sensor.your_energy_sensor_here
    cycle: daily
    tariffs:
      - standby
      - working

Use an automation to switch the tariff based on the printer state.

- id: 841ae395-4646-4c95-8991-14cdd7e9c834
  alias: 'Set Octoprint Tarrif'
  trigger:
  - platform: state
    entity_id: binary_sensor.octoprint_printing # Your printer working sensor here
  action:
  - service: utility_meter.select_tariff
    data:
      entity_id: utility_meter.octoprint_energy
      tariff: >
        {% if is_state('binary_sensor.octoprint_printing', 'on') %}
          working
        {% else %}
          standby
        {% endif %}

This give you two energy sensors, sensor.octoprint_energy_working and sensor.octoprint_energy_standby.

If you need to reset the energy between jobs use the utility meter reset service.

If your prints take longer than 24hrs or work past midnight, change the utility meter cycle to be longer than daily.

1 Like