Appliance Power Monitor Blueprint With Elapsed Time and Energy Used Variables

This blueprint allows you to monitor the activity of a home appliance based on its power consumption (in watts) and trigger actions based on start, running, and stop events. You can configure the entities for power and energy consumption, as well as set thresholds for starting and finishing. You can use the variables {{ elapsed_time }}, {{ energy_used }}, and {{ event_type }} in all the steps (start, running, and stop).

The purpose of this blueprint is to be simple and use variables to determine the duration and energy consumption while the appliance is running, using the least number of input_texts possible. There are other solutions available on the forum, but none of them met this specific scenario that I needed. If there’s a better way to achieve this, please don’t hesitate to let me know.

Features

  • Monitors power consumption (in watts) of a home appliance.
  • Triggers actions based on start, running, and stop events.
  • Configurable starting and finishing power thresholds.
  • Stores elapsed time and energy data.
  • Variables {{ elapsed_time }}, {{ energy_used }}, and {{ event_type }} available in all steps (start, running, and stop).

Inputs

  • power_entity: Entity representing the power consumption of the appliance (sensor domain).
  • energy_entity: Entity representing the energy consumption of the appliance (sensor domain).
  • start_threshold: Power threshold above which we assume the appliance has started (default: 1 W).
  • finish_threshold: Power threshold below which we assume the appliance has finished (default: 1 W).
  • elapsed_time_energy_data: Input text entity to store the elapsed time and energy data (input_text domain).
  • on_start: Actions to perform when the appliance starts.
  • on_running: Actions to perform when the appliance is running.
  • on_stop: Actions to perform when the appliance stops.

Usage

To use this blueprint, simply import it into your Home Assistant instance using the following GitHub link:

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

After importing, create a new automation using this blueprint, select the appropriate entities and actions for your use case, and enjoy your new appliance power monitor!

If you have any questions or feedback, please let me know in the comments below.

4 Likes

Looks very good @Jhonattan-Souza , i am kinda confused on what is the difference between power and energy… can you provide an example?
Also a good idea would be to calculate the cost of the specific usage based on the cost value set on the energy dashboard, then push notification that includes the cost when job is finished
can this be done?

nice
i’m quite new to home assistant so i do have a question.
In ‘Elapsed Time and Energy Data Input text entity to store the elapsed time and energy data.’ no entities show up, so how do i create this entity?

Hi @ptrnmgr , yes, you need to create the input text!

Power = The actual consuming of the device, when it is running live.
Energy = Accumulate kwh over the time, its always increasing.

I’ll take a look into the possibility of using the energy dashboard tariffs !

thx, i’ll have a look

I was having a hard time getting this to work initially. The automation would register that it had been triggered, but the actions were not being performed.

Eventually I worked out the problem was my input_text helper default settings was set to ‘max: 100’. I could see there were no events in the log and nothing was being stored in here. As soon as I changed this to 1000 the blueprint started working perfectly and the actions were performed when triggered.

Exactly the same issue here. Can I suggest to avoid user confusion you update the elapsed_time_energy_data: entry to something like. elapsed_time_energy_data : Create under Settings->Devices & Services->Helpers a Text helper with maximum length 1000 then select this helper from the drop down menu (input_text domain)

Hi Jhonattan - after configuring this new automation, I got this error:

Stopped because an error was encountered at 10 maggio 2023 alle ore 15:55:10 (runtime: 0.25 seconds)

Error rendering data template: UndefinedError: ‘int object’ has no attribute ‘initial_energy’

Could you please help me to fix this issue?

I made an updated/more advanced version of this blueprint at advanced_appliance_power_monitor.yaml · GitHub

Improvements include:

  • You can set a delay before triggering start, running, or stop events (e.g. the for part of a condition)
  • The energy_entity is now optional
  • The elapsed_time_energy_data entity is no longer needed; the automation runs until the appliance stops.
  • The following new variables are available:
    • {{ elapsed_time_days }}
    • {{ elapsed_time_hours }}
    • {{ elapsed_time_minutes }}
    • {{ elapsed_time_seconds }}
    • {{ start_time }} (a unix timestamp)

If you’d like to pick it up as a revision to your blueprint, that would be great! If not, just let me know and I’ll post it as a separate one.

3 Likes

Hi @FlyingSaucrDude , I am very glad to hear that you improved the code!

Please, post at a separated one and let me know, I’ll put the link of your implementation here, and I’ll let people know that your code is up to date.

To be honest I’m out of time to keep things up to date.

Thanks a lot!

Hi,
great work! I do have some questions about how to do some things.
Is it possible to create a statuscard in a dashboard for what the appliance is doing. E.g. Off/On/Running? And how? the sensor is a text sensor so it is not that straightforward?

Hi @FlyingSaucrDude,

Did you post yours as a separate blueprint or is it only on Github?

If you did create a separate blueprint, please share it here for people that come across this post.

Thank you and @Jhonattan-Souza for this!

Hi,
Thank you for you work.
I am trying this automation but I am getting this error:

CAN YOU PLEASE HELP ME?