Math Help - Excel to HA

Trying to convert some excel math to something HA will understand, hoping to get help on this one so I can do the remainder of them myself…

Excel

=(4098*(0.6108EXP(((17.27H24)/(H24+237.3)))))/(H24+237.3)^2

ChatGPT attempt, this did not work :slight_smile:

result = (4098 * (0.6108 * exp(((17.27 * state(‘sensor.h24’)) / (state(‘sensor.h24’) + 237.3))))) / (state(‘sensor.h24’) + 237.3)^2

What is the entity ID that holds the value of H24?

Here’s the helper…
sensor.mean_outdoor_temp

{% set h = states('sensor.mean_outdoor_temp')|float(0) %}
{{ (4098 * (0.6108 * e**((17.27 * h)/(h + 237.3)))) / (h + 237.3)**2 }}

Jinja: Math
Home Assistant Templating: States
Home Assistant Templating: Numeric Functions, Filters, and Constants

How would I save the result of that equation inside HA, make a helper?

Yes, you can use it in a Template Helper.

1 Like

One more quick question, this equation is gong to have a lot of helpers (only half way down now). Is there any chance that this will slow down HA or cause issues. I am sure there is a more eloquent way to do this but this is the extent of my newbie skills?

It shouldn’t cause any issues unless you’re running HA on a potato.

I think the answer to that question very much depends on how often those sensor readings are updated, and whether or not you record them.

I think I recently heard that was possible :rofl:

With some work

https://libre.computer/products/aml-s905x-cc/

2 Likes

Dumb question, but how do you tell if they are recorded or not?

By default no entities are excluded from the Recorder:

Recorder Filter

Ok so I have my final Eto number and many helpers :slight_smile: working as required, thank you again @Didgeridrew .

Then next part is to start at an Eto Value of zero and increment that value every day while subtracting any rain that may have occured that day (all calcs to be done after midnight). My thought process on this is as folows

  • Make a sensor that starts at a zero flow (Eto_Total = 0)
  • add the Eto value at the end of each day to it (Eto_Total = Eto_Total + Daily Eto)
  • subtract of any rain ((Eto_Total = Eto_Total + Daily_Eto) - Rain)

I have no idea how to do this inside HA, is there a reference I can search?

In Home Assistant there are almost always at least 3 ways to do anything…

Integrations you might want to take a look at:

Utility Meter: Not exclusively for utilities and helpful for periodic consumption/accumulation

Trigger-based Template Sensors: Helpful when you want to throttle how often, or schedule when templates are rendered. Also: self-referencing in template sensors

MesureIt (custom): A useful, Frankenstein’s monster of Templates sensors, Utility Meter, and History Stats sensors.

1 Like