Node Red dimming lights

Hello,

Im trying to simplify my node-red flows a bit using templates after input from switches, but cant figure out how to not merge the data sent to the call service node properly.
This works sending as a payload

{
    "service": "turn_on",
    "data":
    {
        "brightness_step": 255,
        "transition": 7
    }
}

However, trying to stop dimming by sending this, all it does is setting transition to 0, dimming all the way to 100% immediatly. Is it possible to overwrite this value?

{
    "service": "turn_on",
    "data":
    {
          "brightness_step": 0,
         "transition": 0
    }
}
[{"id":"d786aa91.fe1888","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"17d24e55.b1c502","type":"inject","z":"d786aa91.fe1888","name":"up","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":930,"y":280,"wires":[["bf3a42fb.5db35"]]},{"id":"5e613547.a8079c","type":"inject","z":"d786aa91.fe1888","name":"down","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":930,"y":340,"wires":[["ed5ffc3e.0fa29"]]},{"id":"adc031c9.391bf","type":"api-call-service","z":"d786aa91.fe1888","name":"","server":"c060dd68.07dd8","version":1,"debugenabled":false,"service_domain":"light","service":"","entityId":"light.soverom","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1300,"y":340,"wires":[[]]},{"id":"ed5ffc3e.0fa29","type":"template","z":"d786aa91.fe1888","name":"Decrease Brightness","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n    \"service\": \"turn_on\",\n    \"data\":\n{\n    \"brightness_step\": -150,\n    \"transition\": 4\n}\n}","output":"yaml","x":1100,"y":340,"wires":[["adc031c9.391bf"]]},{"id":"daa79d34.9639c","type":"template","z":"d786aa91.fe1888","name":"Off","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n    \"service\": \"turn_off\",\n    \"data\":\n{\n    \"transition\": 4\n}\n}","output":"yaml","x":1110,"y":440,"wires":[["adc031c9.391bf"]]},{"id":"1813c860.bf5168","type":"inject","z":"d786aa91.fe1888","name":"down","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":950,"y":440,"wires":[["daa79d34.9639c"]]},{"id":"bf3a42fb.5db35","type":"template","z":"d786aa91.fe1888","name":"Increase Brightness","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n    \"service\": \"turn_on\",\n    \"data\":\n    {\n        \"brightness_step\": 255,\n        \"transition\": 4\n    }\n}","output":"yaml","x":1090,"y":280,"wires":[["adc031c9.391bf"]]},{"id":"d26bd2ea.b1ac1","type":"template","z":"d786aa91.fe1888","name":"StopDim","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n    \"service\": \"turn_on\",\n    \"data\":\n    {\n          \"brightness_step\": 0,\n         \"transition\": 0\n    }\n}","output":"yaml","x":1060,"y":380,"wires":[["adc031c9.391bf"]]},{"id":"23dc429d.f7ebde","type":"inject","z":"d786aa91.fe1888","name":"down","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":930,"y":380,"wires":[["d26bd2ea.b1ac1"]]},{"id":"c060dd68.07dd8","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Probably you shouldn’t send a command “go to full brightness in 7 seconds” and stop this command somewhere down the line. That second snippet is off in 0 seconds, so exactly what is does.

{
    "service": "turn_on",
    "data":
    {
          "brightness_step": 20,
         "transition": 1 //1 or 0.5 or whatever timespan
    }
}

And send new msg to Trigger template node after X (milli)seconds.

1 Like