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.

    source: sensor.your_energy_sensor_here
    cycle: daily
      - standby
      - working

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

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