Closed fblackburn1 closed 7 months ago
I Tried the change node method. Could you provide an example? I was taking a number from mysql essentially a msg.payload.value and I tried it have a dozen ways and still could not get it into Hubitat. So I agree being able to add an expression into Command Node arguments would be invaluable. I was trying to send the internal humidity value from a Davis Weather Station to a variable in Hubitat.
As of 2023-08-19 I have tried more ways, even duplicating the message set to Hubitat using the change node and have found the only way to"setHumidity" is manual entry in the Command node Arguments entry. The Change/Set node before or after, and specifically after, will duplicate the output message, but it never makes it to Hubitat. So obviously I missing something . My rules are: Set msg.requestCommand to the value "setHumidity" // this is a string and Set msg.requestArguments to the value $string(msg.payload.HumidityInt) //this is an expression and HumidityInt is numeric
for Hubitat to accept the value it appears that it has to be converted to a string, although it is a number, format, i.e. "44"
msg.requestCommand
and msg.requestArguments
are the output of the node
If you want to set command and arguments you should set msg.command
and msg.arguments
You should not have to cast arguments to string, the node will do it for you
But thank you, you give me the opportunity to test variable with Hubitat :smile: Or maybe I missed something in your question?
I tried what you suggested as a string and number but neither worked. It does work from the command node, but that is a keyboard input. This is my setup, the output is on debug 2, the node above does work fine, this is my second option:
This is the message output on my terminal: 26 Aug 19:48:57 - [info] [debug:debug 2] { payload: [ RowDataPacket { Time: 2023-08-27T05:48:51.000Z, HumidityInt: 46 } ], _msgid: 'XXXXXXXXXXXXXXXXXXXX', requestCommand: 'setHumidity', requestArguments: '', responseStatus: 200, response: { id: '680', name: 'HumidityInt', label: 'HumidityInt', type: 'Virtual Humidity Sensor', room: 'Living Room', attributes: [ { name: 'humidity', currentValue: 22, dataType: 'NUMBER' } ], capabilities: [ 'RelativeHumidityMeasurement', { attributes: [ { name: 'humidity', dataType: null } ] } ], commands: [ 'setHumidity' ] }, command: 'setHumidity', arguments: 46 } Thanks also, I'm just a beginner at this . . . sort of, but any assistance is much appreciated.
This is the error message in the Hubitat log: dev:6802023-08-26 19:56:34.450errorjava.lang.NullPointerException: Cannot invoke method toInteger() on null object on line 28 (method setHumidity)
This is just me thinking out-loud: The message goes out in string format, i.e. "44" and the Hubitat sees it as an error and rejects the command.
@BUMPRW The change node must be done before command node.
You must see node red as a flow. Using command
node before anything will trigger command (with empty msg.arguments
) and will make the request failing.
To help you, you should add debug node before/after every node to know what was the input/output. Also, start by using simple logic (ex: use change node to hardcode 44 like my example, then when it works, use more advance logic)
If you want more step-by-step / quick help, do not hesitate to ask on the hubitat forum on node-red section: https://community.hubitat.com/c/comappsanddrivers/nodered/105
That worked. I had tried this before, but with “Arguments” vs. “arguments” and many other things, so . . . I didn’t think that worked. As soon as I changed it to “arguments” my database is feeding it fine.
Thanks!,
RWB
On Sep 1, 2023, at 15:05, Francois Blackburn @.***> wrote:
@BUMPRW https://github.com/BUMPRW The change node must be done before command node. You must see node red as a flow. Using command node before anything will trigger command (with empty msg.arguments) and will make the request failing. To help you, you should add debug node before/after every node to know what was the input/output. Also, start by using simple logic (ex: use change node to hardcode 44 like my example, then when it works, use more advance logic) If you want more step-by-step / quick help, do not hesitate to ask on the hubitat forum on node-red section: https://community.hubitat.com/c/comappsanddrivers/nodered/105
— Reply to this email directly, view it on GitHub https://github.com/fblackburn1/node-red-contrib-hubitat/issues/153#issuecomment-1703265143, or unsubscribe https://github.com/notifications/unsubscribe-auth/AES35DJW55WLHNAN257ER5LXYI5XZANCNFSM6AAAAAAXQPHHHI. You are receiving this because you were mentioned.
From https://community.hubitat.com/t/node-red-nodes-for-hubitat/34386/5235