MeasureIt: Measure all you need based on time and templates!

You need to convert power to energy. If your device doesn’t provide an energy sensor, you can look into this integration.
You can then add the resulting energy sensor as a source sensor in MeasureIt to generate the sensors per day/week/month.
Hope this helps!

1 Like

I’m using MeasureIt in several areas - and I love it. Thank you @danieldotnl a lot for provding it

Since I have quite some MeasureIt counters I would like to ask:
Is there a way to see or even edit/change the template which is used for a MeasureIt counter?

I think for the timers it’s easily possible.

Thanks for the great integration.

I’m trying to use it to calculate my HVAC cooling efficiency. I have two MeasureIt sensors:

  • time (counts how long the HVAC action is ‘cooling’),
  • sensor (measures the temperature change while HVAC action is ‘cooling’).
    I then divide the two (sensor / time) in a helper to get the degrees / hour approximating the HVAC efficiency.

Everything works while the AC is running and the temperature is falling. But there are situations where after hitting the setpoint, the AC turns off. It then turns on again once the temperature rises 1 degree above the setpoint.
Unfortunately, this causes the second MeasureIt entity to jump into positive values, even though the temperature change didn’t happen while the AC was running.

I think I need to have an entity that saves the temperature when the AC turns on, checks it again once the AC turns off and saves the difference to a running tally. Sort of like MeasureIt does.

Any ideas if I can use MeasureIt or do I need to use an automation to achieve this? Or do I need to look into template sensors?

I’m interested to hear if this is possible as well, with this integration. If not, it is definitely possible with a trigger-based template sensor. Create a new post if you end up needing to go that route and I can help. I don’t want to detract from this thread.

Also shout out to the OP for his other great integration multiscrape. Keep up the great work!

1 Like

It sounds like a scenario that should work. So I tried to write a unit test that imitates your scenario but I cannot reproduce it.

Please check if the following is accurately representing what you see happening, and if not, please correct it or tell me where I’m wrong:

measureit sensor: sensor.airco_temp_change_hour
airco_set_point: 21 (i'm thinking celcius :))

current_temp = 22
airco_status = cooling

sensor.airco_temp_change_hour == 0

current_temp = 21
airco_status = standby

sensor.airco_temp_change_hour == -1

current_temp = 22
airco_status = cooling

sensor.airco_temp_change_hour == -1

current_temp = 21
airco_status = standby

sensor.airco_temp_change_hour == -2

Hi,
Thanks for your replies. I ended up going with input_numbers instead of sensors, because it was easier to control when they change. Of course this requires automations rather than using MeasureIt or template sensors.
I used MeasureIt to create a timer that measures the runtime while the outside temperature is above a certain threshold.
In the end, I figured out that it would probably work with MeasureIt, but I needed to figure out the template conditions. It was much easier when I was able to control the other inputs.

Here’s what I did:
Automation 1: When cooling starts, measure starting temperature T1.
Automation 2: Every 30 seconds while AC is running measure Tdelta (T1 - current temerature).
Automation 3: Whenever Tdelta != 0, add Tdelta to a running Tdelta_total, set Tdelta back to 0.
MeasureIt: Measure runtime while AC is running.

I had to play around with different conditions, because Tdelta measurement sometimes was delayed (i.e. changed after AC stopped running), likely due to how Nest reports the values.

Ok, thanks for your reply. Let me know if you see opportunities to improve MeasureIt.

hello,
I’m trying to get duration of playing tv e.g. Disney+
{{ is_state_attr(‘media_player.smart_tv_pro’, ‘app_name’, ‘com.disney.disneyplus’) }},
values not increasing, do you have any clue?

Some questions:

  • Just to be sure: did you wait long enough? It updates every minute.
  • Did you enter that template in the condition field?
  • The sensor has an attribute ‘Status’. What value does it have? Measuring?

are you sure it’s not

{{ is_state_attr(‘media_player.smart_tv_pro’, ‘com.disney.disneyplus’) }}

EDIT: actually you are right

I have
{{ state_attr('media_player.bedroom_tv', 'app_name') == 'Plex') }}"

i waited few days :slight_smile:

Can you make a screenshot of the media_player.smart_tv_pro and measureit sensor in the developer tools including the attributes?

A recommendation/question to reset periods:

Wouldn’t it make sense to have a reset period Before each session (additionally to the existing After each session)?

Let´s say I want to measure the duration of a switch in some defined state and want to keep the last value as a state value of the MeaureIt sensor.

Currently, I’m selecting the reset period After each session, device class duration and state class total_increasing. Thus, the MeasureIt sensor has always the state of “0” (because of the reset after the measurement) and the attribute prev_period holds the value of the last measurement. Which is actually usable, but:

If the state value would be initialized before the measurement, then the (current) state of the sensor would hold the value of the last measurement (and the value of the prev_period would be still available - and it would be really the prev and not the last value).

Sorry forgot about this post. I think I understand what you mean. Probably best to call it ‘before next session’, right? But I’m not so sure if it won’t be confusing to the average user. Because actually the current state will then contain info about the last session which is finished, so not current… Hmm I will think about it.

@danieldotnl would be super good and appreciated if you could give me a hint :pray: