Numeric_state - why no 'equal to'?

This is my case… Going with < 1

LOL. Really? Did you really say that? WTF? Obviously, all conditions : <,<=, ==, >, >= should exist.

How float is represented, it does not matter. You should be able to compare with known precision (sensor’s precision).

You are obviously not good programmer.

2 Likes

Did you join just to be unpleasant? If so, go away.

4 Likes

Sorry, but I totally disagree with quoted response. I know it may look unpleasant, but I couldn’t resist.

You are fine to disagree, but attacking a comment made 4 years ago is a little suspect. This forum is designed to help educate and assist each other as HA continues to expand.

Your comments came across as a bit troll’sh, agreed?

Simple example ;

Always take measures comparing a float against a literal

4 Likes

Similar to response like “You are obviously not programmer” in response to good question. I’ve also never heard anything like comparing float to anything is a bad practice. You just need to assume precision and you should not avoid comparing when you need to.

Pretty easy in this case. We know sensor precision (1 digit in most cases) and user should be able to use float value with the same precision to be able to check if value is equal or not.

My case is very simple. I want to be notified when temperature is below 15 °C and when it reaches 15°C or more. Simplest way is to use 2 conditions: <15 and >=15. I was wondering there’s no >= condition and that’s how I found this thread.

So I need to use <15 and >14.9, as sensor precision is 0.1. But it feels like a workaround, not a solution.

So if it looks like a duck, quacks like a duck, it is a duck. Please don’t be unpleasant, resist in future.

3 Likes

Yes seems simple, thou below is a “State” , reaches is an “Event”( “Changes of a State” ) sort of

0.000001 is > than 0 ( in my 6digits sensros, Yes I Did had to “round(x)” this, to keep it quite :wink:
0.1 is is > than 0 in your 1 digits ( Make sure your sensor actually is !, check state "state-changes in your DB ) i.e select_metadata-id=X )

How often do yo want to be “Notified” While temp is below 15 ? ) Meaning 14.9 and less ?

So lets say it reaches 15 ( and you’r “notified” , Do you want to be notified again when it reach 15.1 , 15 .2 etc ?

You are trying to prove equality is not needed and should not be there. I disagree + I see no reason why it’s so problematic to add. From gui, it could be dropdown control to select equality operator.

In my case >= 15 is good temperature, <15 is bad temperature. I need to be notified when temperature falls to bad temperature and also when it again rises to good temperature. So yes, there’s no >= 15 posssible, I need to use >14.9.

There’s an option to set sensor precision (never tried it though), can’t you set 1 digit precision? 6 digits is a nonsense (is your sensor really so accurate and you need 6 digits accuracy?). It looks like trash values and indeed values should be rounded (or garbage digits should be dropped)

or <15 , else ( Which is actually 14.999999( if your sensor is that smart, but i doubt you even know )… up to You

You obviously don’t know what you are talking about, Yes it’s a precision sensor( 6 digits specified in Specs , so not Trash Nor garbage Values )( Keep Up your Positive Aura ) do i need this No, but i certainly can’t change that fact, i didn’t produces it.

And Values Do get rounded by HA, depending upon where you look in the UI ( Might even be some “limits” in the DB ), i.e a Card or i.e in the Integration/device page ( You’ll learn eventually ) HA can’t either change a device/sensors Specs
As you also eventually learn to create Templates or Automations, where and what ever it is you’r trying to accomplice

Are you for real ?

abs(sensor - target) < margin, where margin is how close you want the sensor to be to your arbitrary target.

abs is an available filter in jinja2.

No it’s not

:rofl:

Looking at the code for the numeric_state trigger, it fires if the new state is less than or equal to below; or greater than or equal to above.

Lies, it’s the other way around. See below.

I don’t know if this is an attempt at humour, but yes it is:

I mean this:

But still, you can change sensor precision in HA sensors settings. I don’t know how does it apply to integrations though - is it only for display values or it also applies to values used for integrations and scripts.

BTW, I’m tired with gui for integration automation design, is there any full documentation that describes entire api I can use in yaml? As I can see, I can do more by writing code, for example, provide current temperature in notification etc

It’s not really an API; and you’re not designing integrations.

Also, for Jinja templating, as linked from the Developer Tools / Template page:

2 Likes

You can always do more writing code vs GUI.

Of course, but I can see simple code, method calls etc in yaml, for example to format date I used (found on this forum):

{{now().strftime("%Y-%m-%d %H:%M:%S")}}

That’s not YAML configuration, it’s Jinja2 templating. See the final two links in my prior post. You can use Jinja templates in the UI to some extent, too.

In addition to the features in those links, the Jinja language is based on Python, so you can use many of the object methods and properties. Your example of strftime is a datetime method (ref).

I know , Hint: The Laughing Rolling Face