Going from HA Trigger to Node Red

Can someone help me understand how I would go from HA YAML looking like this for a trigger:

device_id: 651fb79cea0c4254a1006bc95a5fcf62
domain: hubitat
platform: device
type: held
subtype: ‘4’

To making this an event state node? New to node red and hitting a road block. Thank you very much in advance!

1 Like

The event:states trigger would be whatever the entity_id is for the hubitat device.

It’s not the entity id that I’m wondering about, it’s how to look for the type and subtype

Ah, those should be in the attributes of the triggered device. I haven’t pulled my hubitat hub out in over a year, so I’m not sure of exactly what’s being passed. But, it sounds like you’re trying to trigger off a button remote?

Something like data.new_state.attributes is where they should be. If you’ve got the events:state node already working on entity_id, then you should be able to throw a debug node behind it, set it to complete msg, and then see all the details of the device:

1 Like

It’s an inovelli light switch with additional buttons that are in a state of held or pushed. Using debug I get the on/off but not the additional button press from the debug node

This is what I am trying to replicate, just in node red instead of HA automations

and this is what it is in YAML:

In NodeRED, create an events state for that entity and attach a debug node to it set to view the entire message object.

Trigger something that causes that entity to change, then look at the output on the debug node. This will give you the structure of the data stream for that entity, and you can use that information to test conditions or filter your flows, etc.

I’m struggling with this part. I’ve put a debug node at the end with a complete message. The debug works showing me standard on/off but nothing comes up when I push the config button (see attached). Also I know the config button is working because I have an automation directly through HA that is working using it.

Expand that object…the little arrow next to { topic then expand every arrow under that so the whole thing is opened up and you’ll be able to see what’s what.

In this example, you see topic, payload, and data at the top level of the object.

Screen Shot 2020-08-29 at 8.23.24 AM

So, if you were doing a switch condition, for example, under Property in the switch node, you have a default set as msg: in the drop down, and then a field probably with payload in it.

If that’s the case, then the information that’s being tested is whatever is paired with payload in the top level of your object for that message.

To address any of the other parts of the message, just replace payload with the other top level item.

msg.data would return another object (expand data and you’ll see more stuff.) If you wanted to test against the entity_id which is located under data in entity_id you would have to replace msg.payload with msg.data.entity_id.

If you wanted to test deeper into data, specifically to the user who triggered the event, you would put something like msg.data.new_state.context.user_id

Or… msg.data.old_state.context.user_id.

Of course, you’re not typing in msg into any of these because that’s implied by the drop-down selection in any given node.

Just follow the object like you would a file folder path and instead of using slashed, you use dots.

msg.does.that.compute? Good luck.

2 Likes

I really appreciate your help. The issue isn’t in the objects and data that are being picked up during those registered events in the debug node, the issue I am having is that when the other button is pressed nothing comes up in the debug log at all. In the above example I gave there were two registered events both on and off but in between those a third button was pressed that was never picked up by the debug log. If I just push the additional button nothing comes up in the debug log. I’m confused by why this button press is not being picked up at all despite the correct entity_id.

Is the inovelli switch called “light.kitchen_table_light”? In HA, look for the inovelli device and see what it’s entities are.


These are the entities associated with the device

If your button press doesn’t change a state or attribute, then I don’t think anything is detected, therefore there’s no event to send.

1 Like

Hmmm, OK, so it has to be something at the device level then. Based upon your entities, the device isn’t exposing a remote type of event, so I’m not sure how the HA automation is even picking it up.

Are you using the Hubitat > HA integration (Custom Component: Hubitat)?

Yeah, I’m really confused by whats going on. Yes I am

In case anyone is in a similar situations I was. This doesn’t directly address OPs need, but maybe it helps:

Prefacing this by saying that I’m using openzwave and the LZW36 fan/light combo switch.

In node red, set up an “mqtt in” node and a debug node to listen for events. If you know your node number, you can listen to everything from that node by setting the “mqtt in” topic to OpenZWave/1/node/44/#. My node is 44. Use whatever yours is.

The messages you receive are actually really helpful. Tells you exactly what to do:

{
    "Label": "Scene 2",
    "Value": {
        "List": [
            {
                "Value": 0,
                "Label": "Inactive"
            },
            {
                "Value": 1,
                "Label": "Pressed 1 Time"
            },
            {
                "Value": 2,
                "Label": "Key Released"
            },
            {
                "Value": 3,
                "Label": "Key Held down"
            },
            {
                "Value": 4,
                "Label": "Pressed 2 Times"
            },
            {
                "Value": 5,
                "Label": "Pressed 3 Times"
            },
            {
                "Value": 6,
                "Label": "Pressed 4 Times"
            },
            {
                "Value": 7,
                "Label": "Pressed 5 Times"
            }
        ],
        "Selected": "Pressed 2 Times",
        "Selected_id": 4
    },
    "Units": "",
    "ValueSet": true,
    "ValuePolled": false,
    "Cha...

You need to figure out two things with the inovelli switch.
Each button activates a different scene. Holding a button or pressing it (x)times activates a different “Selected_id” within that scene.
For example, pressing the fan switch twice activates scene 1, Selected_id: 4. Pressing the light switch twice activates scene 2, Selected_id: 4.

I set up a couple of different switch nodes. The first switch node detects the scene activated and directs traffic to the next switch nodes. The next ones detect the “Selected_id” and direct traffic to whatever you want activated / controlled.

Here is the node-red export. Hope this helps.

[{"id":"45dff1c8.49b7b8","type":"mqtt in","z":"7a836c19.b39db4","name":"Bedroom Switch - Inovelli","topic":"OpenZWave/1/node/44/instance/1/commandclass/#","qos":"0","datatype":"auto","broker":"65414733.ac707","x":150,"y":3300,"wires":[["c47ce803.8cb86"]]},{"id":"c47ce803.8cb86","type":"switch","z":"7a836c19.b39db4","name":"Scene 1 or 2","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"Label\": \"Scene 2\"","vt":"str"},{"t":"cont","v":"\"Label\": \"Scene 1\"","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":3300,"wires":[["ddddaf3e.e8e3a8"],["180f27dd.10907"]]},{"id":"ddddaf3e.e8e3a8","type":"switch","z":"7a836c19.b39db4","name":"Light Button - Selected_id","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"Selected_id\": 3","vt":"str"},{"t":"cont","v":"\"Selected_id\": 4","vt":"str"},{"t":"cont","v":"\"Selected_id\": 5","vt":"str"},{"t":"cont","v":"\"Selected_id\": 6","vt":"str"},{"t":"cont","v":"\"Selected_id\": 7","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":600,"y":3180,"wires":[["dbf69c6a.dd3b3"],["aa6cfe44.5b04a8"],["d5cc7896.c20e"],["f4c9a062.659b58"],["6c606144.05dae8"]]},{"id":"180f27dd.10907","type":"switch","z":"7a836c19.b39db4","name":"Fan Button - Selected_id","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"Selected_id\": 3","vt":"str"},{"t":"cont","v":"\"Selected_id\": 4","vt":"str"},{"t":"cont","v":"\"Selected_id\": 5","vt":"str"},{"t":"cont","v":"\"Selected_id\": 6","vt":"str"},{"t":"cont","v":"\"Selected_id\": 7","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":590,"y":3500,"wires":[["f1bd2cc4.dbc3a"],["341b3fa6.69f518"],["f69a21a8.0049"],["c44748fd.1278a"],["77603489.10ed14"]]},{"id":"65414733.ac707","type":"mqtt-broker","z":"","name":"Mosquitto","broker":"192.168.1.216","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]
2 Likes