Chasing some assistance with Dimming all lights that are currently on

I’ve had a quick search through the forums and can’t quite see my problem appearing anywhere in the same manner which I’m experiencing it.

I’m using a custom dimmer addon which I found in the repository (node-red-contrib-dynamic-dimmer).

I’m trying to get an automation to dim all currently On lights at a specific time each night, this piece of the flow would get called by bigtimer which is set to 830 Off and dusk-2hrs On. I have a function that pulls the current brightness and runs the dimmer from there. That portion of the flow is functioning as intended but my problem arose when the dimmer would turn on all lights that were off, just to dim them to 0.


I’ve made a test flow to workout how exactly to do this before adding the new nodes and settings to that original flow(I’m new to HA and node-red and its been fun learning how to make things integrate!)

In my test flow I’m asking for all lights that are on to be dimmed from 10% to 100%.

I’ve manged to get the list of entities that are on and pass that along the chain and join that with the data for the brightness for the lights to be at but my problem arises with the lights service not actioning all the messages being sent.

Dimmer is set to 10 steps and 1000ms between steps yet my lights respond by immediately jumping to 100% and then only sometimes showing the current value sent through if I push the inject button again while it is currently running the dimmer node.

Works fine with 1 light, just not with more than one.

Sometimes the flow just gets ignored entirely and just punches out Undefined to the debug window.

Any thoughts to help our or different avenues to pursue would be greatly appreciated =)

Flow code

[{"id":"bf99a7a91ec71091","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"e886d4f64c8b96f2","type":"inject","z":"bf99a7a91ec71091","name":"payload dimmer full 100","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"full","payload":"100","payloadType":"str","x":140,"y":180,"wires":[["9ab693553cc40e4e"]]},{"id":"9ab693553cc40e4e","type":"split","z":"bf99a7a91ec71091","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":370,"y":180,"wires":[["2849993d66528ac9","f7be1811fe0c3b15"]]},{"id":"2849993d66528ac9","type":"template","z":"bf99a7a91ec71091","name":"Start from 10% to 100%","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"start\":0.1,\"target\":1}","output":"json","x":590,"y":180,"wires":[["02237a1b6e7c30d1"]]},{"id":"f7be1811fe0c3b15","type":"ha-get-entities","z":"bf99a7a91ec71091","name":"get all on entities","server":"5a6fd004.e68a5","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"light.","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"flow","output_location":"payload","output_results_count":1,"x":590,"y":280,"wires":[["304590c1beab57e8"]]},{"id":"02237a1b6e7c30d1","type":"dynamic-dimmer","z":"bf99a7a91ec71091","name":"","eventInterval":"500","steps":"5","minValue":0,"maxValue":100,"x":800,"y":180,"wires":[["f4c331991b76496f"]]},{"id":"9d39c1065defb16c","type":"split","z":"bf99a7a91ec71091","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":370,"y":280,"wires":[["f7be1811fe0c3b15","f4c331991b76496f"]]},{"id":"304590c1beab57e8","type":"change","z":"bf99a7a91ec71091","name":"entities payload to msg.lights","rules":[{"t":"move","p":"payload","pt":"msg","to":"lights","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":280,"wires":[["787dbc398084e7ef"]]},{"id":"f4c331991b76496f","type":"change","z":"bf99a7a91ec71091","name":"payload to msg.lightvalue","rules":[{"t":"move","p":"payload","pt":"msg","to":"lightvalue","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":340,"wires":[["787dbc398084e7ef"]]},{"id":"787dbc398084e7ef","type":"join","z":"bf99a7a91ec71091","name":"","mode":"custom","build":"object","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"0","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":1050,"y":340,"wires":[["38f5f27f38533eca","d1faf607a9ea7a81"]]},{"id":"52417e86ccfbfc19","type":"inject","z":"bf99a7a91ec71091","name":"payload On full 100","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"full","payload":"100","payloadType":"str","x":150,"y":280,"wires":[["9d39c1065defb16c"]]},{"id":"38f5f27f38533eca","type":"api-call-service","z":"bf99a7a91ec71091","name":"Turn on Light","server":"5a6fd004.e68a5","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["{{lights.entity_id}}"],"data":"{\"brightness_pct\": msg.lightvalue}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1230,"y":340,"wires":[[]]},{"id":"d1faf607a9ea7a81","type":"debug","z":"bf99a7a91ec71091","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1220,"y":420,"wires":[]},{"id":"5a6fd004.e68a5","type":"server","name":"Home Assistant","addon":true}]

You shouldn’t need to use the NR add-on. If you’re wanting to slowly dim the lights over time, you can use “transition” in the service call to turn the lights on.

I’m also not clear on what you’re doing with the split/join nodes. These should not be required, and I’m not clear what the join will do in manual mode without any of the “Send the message” parts set.

All you need is the “get all on entities” followed by a “change” node, followed by a “turn on light” service call (with nothing in entity or data). The change node would then set “msg.data” using the following JSONata:

"data": {
    "entity_id": $join(payload.*.entity_id, ','),
    "brightness_pct": 60,
    "transition": 10
}

This takes the array of entities returned by the “get all on entities” and joins all the entity ids together separated by a comma. You would also put in the brightness and transition you need.

PS - you should surround quotes with three backticks (```), or use the “Preformatted text” toolbar option (</>).

Ah I forgot to mention the ‘transition’ portion doesnt work with my lights for some reason. Hence my path forward for dimming lights.

I tried the posted flow without the split and join and I could never get msg.lightvalue to reach the end, or if it did then the entity group would be lost when trying to send two different payloads to the final service call.

The manual mode is taking place of a bigtimer trigger and function to see what the current light %(msg.lightvalue being sent from here) is before starting the dimmer cycle.

Little annoying to always dim from 100% when the lights may dimmed to 50% which would cause the lights to be raised to full brightness only to dim slowly over the next 30s.

I’ll have another look tonight and see if I can make any more headway.

Thanks for JSON pathway I’ll be looking into