Automating Water Heater Energy Tracking with Shelly

Hey everyone, I wanted to share a cool automation setup I’ve been working on with my Shelly 1 PM water heater monitor. It’s been a fun project, and I think others might find it useful too! :rocket:

So, the goal here was to track the energy consumption of my water heater and get notifications whenever it turns on or off. I’ve managed to set up an automation that does exactly that, but there was one tricky part I wanted to solve: calculating the actual energy used during each heating cycle. :face_with_monocle:

Here’s the setup: I have a Shelly 1 PM connected to my water heater. It monitors the power usage and sends data to Home Assistant. I created two input numbers: one for the starting energy reading when the heater turns on and another for when it turns off. The challenge was figuring out how to subtract these two values to get the total energy used during each cycle. :bar_chart:

After some trial and error, I finally got it working! When the water heater turns on, it records the current energy reading. When it turns off, it records the final reading and then calculates the difference. This gives me the exact amount of energy used during that cycle. :tada:

Here’s how it works step by step:

  1. When the water heater turns on, it triggers an automation that records the current energy reading in input_number.consumption_start.
  2. I get a notification with the initial reading and the current water temperature. :chart_with_upwards_trend:
  3. When the heater turns off, another automation records the final reading in input_number.consumption_end.
  4. It then calculates the difference between the start and end readings and stores it in input_number.energy_used.
  5. Finally, I get a notification with the total energy used and the final water temperature. :chart_with_downwards_trend:

The best part is seeing the exact energy usage for each cycle. It’s been really helpful for understanding how much energy my water heater uses and identifying any inefficiencies. :bulb:

If anyone has suggestions on how to improve this setup or other cool ways to track energy usage, I’d love to hear about it! Let’s keep the smart home projects rolling! :star2: