Node-RED nodes for hubitat

Maybe so, but that is a bastardized colloquialism. And I don't know for sure if decimal is a wrapper for double, or float, but I digress.

In groovy the NUMBER type is a wrapper class for all/any of: byte, short, integer, long, float, and double.

If they meant integer, they should have just used integer - that is a base data type. They chose to make it easy from a coding perspective and just use NUMBER, which I can understand, but then they did not document anywhere what data type individual attributes are - even though they assume/require them to be specific base types elsewhere.

Anyway, it is what it is. This is just something we will have to live with as developers at this point.

Regardless, I did setup a virtual omni sensor, and I am not seeing this same issue if setting it with a decimal from the device detail page. I do see the error over Maker API regardless wehat I send though.

Seems like a bug. I'll start a separate thread.

I do send RH from zigbee2mqtt to hubitat. However, I'm not using any built-in virtual driver, so there are no errors in my logs.

Edit - although I agree that it makes sense for RH to an integer, even if the devices report it as a decimal value.

Are you using the built-in virtual omni sensor driver? I'm asking because I'm not seeing these errors. FWIW, I'm not using the built-in driver.

This is what I do to get my Konke TH sensor data into a Hubitat device

Screen Shot 2021-05-08 at 8.37.23 AM

Latest platform. NR 1.3.2. But I'm not using any built-in virtual driver.

1 Like

OK. I can replicate Mike's issue.

If I specifically send a msg.argument that contains a STRING with a decimal value in it (like "22.33"), I get the same error.

For now I would suggest to @mike that he:

  1. Don't send humidity as a decimal, convert it to an integer
    and/or
  2. Convert the string to a double/float before sending it to the node if you really want to keep the decimal.

You do not get an error if you send:

  1. Decimal value as a decimal (not inside a string)
  2. Integer value
  3. String that contains an integer value

As the Virtual Omni Sensor will accept a decimal as an argument to setRelativeHumidity if done locally, this seems like a driver bug @bravenel . Just my opinion, yours may differ - and that's OK. No big deal in the end, as it is easily worked around.

2 Likes

Oh yeah, I remember that now. I forgot about that completely, but that's why I was specifically converting the payload to a number. Also wanted to round it down to 2 decimal places.

Would be cleaner, particularly since decimal is not appropriate for use with attributes (ENUM, STRING, DYNAMIC_ENUM, JSON_OBJECT, NUMBER, DATE, VECTOR3), but for preferences and input values decimal can be used ( along with: bool, date, decimal, email, enum, number, password, time, text )

You aren't passing it a number. You're passing it a string, as it clearly states in the error message. AFAIK, Virtual Omni Sensor does not care about integer vs decimal number value, although as discussed ad nauseam, some apps do.

The driver does force the value to integer if a decimal is given (see below). But string? The attribute is NUMBER.

There have been no changes to Virtual Omni Sensor.

2 Likes

Fair enough. Just because it seems that the driver will cast a string with an integer in it without throwing an error doesn't mean that sending it a string in the first place was ok. :+1:

Moral of the story - send it the right data type. :wink:

Evidently, the driver throws an error if you pass it a string for a number, per OP above. I think all drivers do this. Where do you get the idea that anything will "cast a string" to a number? As far as I know this has never been the case.

If you send it a string with an integer as the string it will take it and not throw an error.

  • "11" works

If you send it a string with an double/float as the string it will not take it and will throw an error.

  • "11.11" does not work

Again, no big deal. The 1st one working was likely just a quirk anyway, and not intended behavior.

That's news to me. There is nothing in the driver code that touches these values, so must be a platform level thing.

Probably. I agree 100% with your message, though - send it the correct data type. :slight_smile:

I don't know what is going on with the OP situation reported above. Maker API does look up that command parameter attribute, and does convert a string to a number, either integer or double. So that's where the conversion is taking place, not the platform.

This code has not changed in Maker API.

Dunno. I see the same error as him when passing a decimal in a string through maker api though.

I had to fabricate an example to do it, though, I hadn't seen that in "real use" as I don't typically pass numbers as strings. It may always have worked this way - never tried it before.

Are you using "/devices/:id/:command/:secondary" ?

If so,

if(supported?.arguments[i] == "NUMBER") params[i] = it.isInteger() ? it.toInteger() : it.isDouble() ? it.toDouble() : it

I think this code has worked for everyone for as long as Maker API has been available, pretty sure it's never changed. So I honestly don't know what would cause the error he has with the device. Curious...

Both it.isInteger() and it.isDouble() would have to fail for it to send a string.

Mystery solved: The Virtual Omni Sensor driver is doing this, that is forcing an integer value, which in turn would make it barf on decimal value. And this is a recent change. Will change it back...

5 Likes

As far as I am aware, I was sending the correct data type - number or decimal. I wasnt sending a string. Although are you referring to integer, (which I was not sending)?.

Yes. Although it isn't documented (so how would any driver author know??) The system expects integers for some variables - humidity included.

I'm not faulting you, or any other driver author. But as a generic/blanket statement I always think it is better to send the expected type rather than relying on it being cast to the correct type by the system.

@JasonJoel Hoping you might be able to assist me. Here is the story. I have a new install of Node Red on my qnap and everything works perfect, no issues at all. A friend of my advised that it would be much better to use Node red thru Home Assistant. So I got HA up and running. I have Node Red, Influxdb and Grafana all up and running and everything seemed to be working. However, the only time I get info from Hubitat using this app is when I do a deploy. Any other time it just sits there. Any ideas on what I did wrong or what I am missing? I have my original setup identical and that works, but the new does not.