Dimming Z-Wave Lights with Node-RED: A Smooth Experience

Hey everyone, I’ve been diving into the world of smart lighting and automation, and I wanted to share my journey with you. I recently set up my Z-Wave lights connected to the Fibaro HC2, and I’ve been experimenting with Node-RED to create a smooth dimming effect. It’s been a bit of a challenge, but also a lot of fun!

So, the goal was to have my lights dim from their current brightness to a specific level, say 15%, without any fixed steps. I wanted it to be dynamic based on the current brightness. I started by creating a flow in Node-RED to calculate the percentage difference and divide it into 10 equal steps. I stored this value in a flow variable to use later. The idea was to send this value to the light to dim it smoothly.

But here’s where I hit a snag. When I tried using the flow variable as a number to control the dimming, I kept getting an error: 'Call-service error. expected float for dictionary value @ data[‘brightness_pct’]. It was frustrating because the logic seemed sound, but clearly, something was off.

After some research and tinkering, I realized that the issue was with how the variable was being passed. Node-RED was expecting a float value, but the variable was being treated as a string. I adjusted the flow to ensure the variable was correctly formatted as a float, and voilà! The dimming worked perfectly. The lights now transition smoothly from their current brightness to the target level, creating a seamless effect.

This experience taught me the importance of data types in flows and how crucial it is to ensure variables are correctly formatted. It also highlighted the power of Node-RED in handling dynamic automation tasks. If anyone else is working on similar projects, I’d love to hear your tips or tricks for smooth transitions or any other automation hacks you’ve discovered!

Looking forward to hearing your experiences and learning more from the community. Happy automating! :rocket: