Help, need indicator to show information if water boiler has consumed energy today or not

I have water boiler (actually I have 3 heaters) , referred here also as “lvv” (short for it’s Finnish word “lämminvesivaraaja”) and I want to see indication that has it been on TODAY, or not.

Can not install temperature sensors to show if it is hot or not. Much easier to do it like this.

I am using Spot price electricity that has no fixed price, and boiler heats up in 3 of the cheapest hours at night (timeslot AM 0:00-10:00)

So in the morning I want to see if automation has worked and it has consumed energy. Two boilers have no temperature meters, one has analogue one.
.

Tried to get this done with couple AI:s, but not much help (Open AI and Bard)

I have like 1% Coding skills, bear that in mind when answering.
.

Entity → “sensor.zb_poro_lvv_summation_delivered” is cumulative, and will show every bit of energy my water boiler (lvv) used ever in it’s lifetime, and can not be reset, I think, so it grows every day. There is no daily consumption sensor.

How do I fix this so that it will indicate “Yes” if energy has been used TODAY? :thinking:

This is what AI made up, and it created “lvv_poro_usedornot”-entity, but that seems to always show “no”:

sensor:
  - platform: template
    sensors:
      lvv_poro_usedornot:
        value_template: |
          {% set now = now() %}
          {% set start_of_day = now.replace(hour=0, minute=0, second=0) %}
          {% set usage = states('sensor.zb_poro_lvv_summation_delivered', now) | float %}
          {% set usage_start_of_day = states('sensor.zb_poro_lvv_summation_delivered', start_of_day) | float %}
          {% set usage = usage - usage_start_of_day %}
          {% if usage > 0 %}
            {{ "Yes", " ({{ usage }} kWh)" }}
          {% else %}
            {{ "No" }}
          {% endif %}

(This all is ofcourse written to configuration.yaml)

Or does the code work, and I just need to wait for it to register when this consumption is happening? :face_with_monocle:

.
Here is the output atm, and it is ~1 hour until next day starts, so I am going to sleep and check here in the morning if you wonderful people have an answer to me! :yawning_face: :drooling_face: :sleeping:

boiler warm or not

No it does not work.

Don’t use AI for this. Currently what the various AI know about homeassistant is woefully out of date at best and draws from bad examples at worst so you end up with code above that looks close-ish bit has no basis in fact. (for instance it has two incorrect uses of’ ‘states’. And it was the whole reason for this post:

So let’s start over what entities do you have (before the AI) and what did you want from it?

1 Like

Yeah, I figured so also that they are no good.

.

I have only “sensor.zb_poro_lvv_summation_delivered” -entity

I need script to read if “sensor.zb_poro_lvv_summation_delivered” -entity has used power today or not.

“sensor.zb_poro_lvv_summation_delivered” -entity is cumulative and will not reset ever.

I want script to create “lvv_poro_usedornot” -entity.

If it has used power today I want “lvv_poro_usedornot” -entity to show “yes”

If it has not been using energy today, I want to answer “no”

So the Idea is that only way to check atm if there is hot water is to open the faucet.

This script will tell me if boiler used energy or not. If it used, it is hot. Simple :ok_hand:

I hope this is now more clear than my original post :smiley:

Here is the picture of entity card in my dashboard

boiler warm or not

1 Like

Actually I might got it working now with help from another person, if I do get it to work (we sill see in few hours), I will most likely post the code here (if code writer approves)! :ok_hand:

Here are the instructions, sorry they are in finnish partly.

This HAS been tested to work, and is written by human.

.
First add Utility Meter that will slice cumulative information to daily:


.

Then this script to configuration.yaml, which will look if there has been 1kw energy consumed today.

template:
  - sensor:
      - name: LVV Poro usedOrNot
        state: |-
            {% set isOk = is_number(states('sensor.lvv_paivan_kulutus')) %}
            {% if isOk %}
                {% set kulutus = states('sensor.lvv_paivan_kulutus') | float %}
                {% set kynnysArvo = 1.0 %}
                {% if(kulutus > kynnysArvo) %}
                    {{"Kyllä"}}
                {% else %}
                    {{"Ei"}}
                {% endif %}
            {% else %}
                {{"Mittadata on rikki"}}
            {% endif %}

Translations:
Tähän se sensorin entity - Insert here sensor entity
Kulutus - Consumption
Paivan kulutus - Daily consumption
KynnysArvo - theresold
Kyllä - Yes
Ei - No
Mittadata on rikki - Measuring data is broken

something like that.