Having trouble passing a state attribute to an event

I’m brand new to home assistant and I am working on my first Node Red automation. I want to use one button on my remote to change the speed of a ceiling fan connected to a GE Smart Fan Control switch. I’m using a Node Red switch to iterate through the speeds when an event I created is fired. I want to configure this so that I can pass in the fan entity and the current speed (so I can re-use this for several other fans in the house). I am able to pass in the entity, process it, and call a service to change the speed. What I can’t figure out is how to pass the value of the state attribute for the fan speed into my event. I am testing this by sending the event in the developer tools and looking at the debug node in Node Red to examine the msg.payload.

Event Type
home.fan_speed_inc

Event Data
1 entity_id: fan.my_fan_level
2 speed: {{ state_attr(“fan.my_fan_level”, “speed”) }}

This results in a null object being received on the node red side for speed.

When I add fan.my_fan_level to the dashboard it shows a toggle switch. If I click on it to inspect it, I see it has an attribute called Speed. Capitalization of speed doesn’t affect the output of my event.

I’ve tried several different things and have done a decent amount of digging, but can’t find verification that I can do what I am trying to do here. Any advice would be appreciated.

Thanks

It’s easier to help if you export the flow or the sequence of nodes.
Select the nodes and click on the burger and export.

Just remember to remove any passwords if you have any in any of the nodes you select. (unlikely but could happen)

No problem, but I don’t know how helpful this is. My test case is just an event node and a debug node. Once I can get the speed to pass through correctly, everything in the full flow will work (I’ve tested by passing “high”, “medium”, and “low” explicitly. Thanks. :slight_smile:

[{"id":"36e3be94.cc1662","type":"debug","z":"c388fad.1237608","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":660,"wires":[]},{"id":"eeaff2d7.24a24","type":"server-events","z":"c388fad.1237608","name":"","server":"c75195a0.d36d78","event_type":"home.fan_speed_inc","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":200,"y":660,"wires":[["36e3be94.cc1662"]]},{"id":"c75195a0.d36d78","type":"server","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

So, in typical fashion, asking the question got me thinking about the problem in a different way. I started researching templates and found that you need to wrap variable substitutions in quotes. This actually doesn’t work in the dev tools event page so I tried it in my test automation and it worked. :slight_smile:

Thanks.