Setting Default Level with ZHA Cluster Commands and Node Red for time based light brightness

I was trying to wrap my head around this for quite some time, as the Default Value Local and Remote were not exposed in ZHA and I didn’t quite understand cluster commands. I was finally able to figure out what values I needed to enter to send the correct cluster command after playing with it a bit.

Sorry if any of this is obvious to others, still learning myself. Please let me know if you find any issues or have suggestions for improving my flow.

Attributes needed for call service “zha.set_zigbee_cluster_attribute”:
YAML:

service: zha.set_zigbee_cluster_attribute
data:
  ieee: 04:0d:84:ff:fe:02:a8:d3
  endpoint_id: 1
  cluster_id: 64561
  attribute: 13
  manufacturer: "4655"
  value: "255"

UI Mode:

Gotchas:

  • You would need to change the IEEE to an IEEE from your own devices. This can be found on the device page, under Device info > Zigbee Info
  • Set value from 1-254 for a brightness value and 255 for it to remember it’s last state, the default setting for this attribute.

I’m using this in node-red like this:


An example flow:

  • Inject Node, repeats at a specific time of day, creates msg named value, and assign value to it:
    image
    image
  • Change node, creates msg named IEEE, set to one of my switches IEEE value
    image
  • One output goes to a Call service node for local level and another to remote:
    Example of Local level settings:
    image
    expression:
{"ieee":ieee,"cluster_id":64561,"attribute":13,"manufacturer":4655,"endpoint_id":1,"value":value}
  • For the Remote value setting, it’s expression just needs it’s “attribute” value to be set to 14 instead of 13.
  • I’m using the msg values “ieee” and “value” in the data expression, this way I only need two Call Service nodes rather then one for each light and time of day.

Full Flow Example:

[{"id":"6e39d33a2cfa1247","type":"inject","z":"c26113a3.aa95","name":"6 am","props":[{"p":"payload"},{"p":"value","v":"127","vt":"str"}],"repeat":"","crontab":"00 06 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":610,"y":1980,"wires":[["475ebc9924e017dd","7a24f33c6ed0f844"]]},{"id":"d2e31579605eeb2d","type":"api-call-service","z":"c26113a3.aa95","name":"Set Local","server":"d66b167d.4338d8","version":5,"debugenabled":false,"domain":"zha","service":"set_zigbee_cluster_attribute","areaId":[],"deviceId":[],"entityId":[],"data":"{\"ieee\":ieee,\"cluster_id\":64561,\"attribute\":13,\"manufacturer\":4655,\"endpoint_id\":1,\"value\":value}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1640,"y":2240,"wires":[[]]},{"id":"e9fd08db259dcc3c","type":"api-call-service","z":"c26113a3.aa95","name":"Set Remote","server":"d66b167d.4338d8","version":5,"debugenabled":false,"domain":"zha","service":"set_zigbee_cluster_attribute","areaId":[],"deviceId":[],"entityId":[],"data":"{\"ieee\":ieee,\"cluster_id\":64561,\"attribute\":14,\"manufacturer\":4655,\"endpoint_id\":1,\"value\":value}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1650,"y":2340,"wires":[[]]},{"id":"475ebc9924e017dd","type":"change","z":"c26113a3.aa95","name":"Office Main Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"04:0d:84:ff:fe:02:a8:d3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":1940,"wires":[["4cd06a56a2b7e428"]]},{"id":"7a24f33c6ed0f844","type":"change","z":"c26113a3.aa95","name":"Living Room Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"94:de:b8:ff:fe:f4:c0:4d","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":2020,"wires":[["4cd06a56a2b7e428"]]},{"id":"69302902f67d96ce","type":"inject","z":"c26113a3.aa95","name":"4 pm","props":[{"p":"payload"},{"p":"value","v":"254","vt":"str"}],"repeat":"","crontab":"00 16 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":610,"y":2180,"wires":[["a2313ac7c712daa0","e69d00536e6465ce"]]},{"id":"a2313ac7c712daa0","type":"change","z":"c26113a3.aa95","name":"Office Main Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"04:0d:84:ff:fe:02:a8:d3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":2140,"wires":[["2c21f4de242cc6a2"]]},{"id":"e69d00536e6465ce","type":"change","z":"c26113a3.aa95","name":"Living Room Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"94:de:b8:ff:fe:f4:c0:4d","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":2220,"wires":[["2c21f4de242cc6a2"]]},{"id":"9a36e40f5b513a7e","type":"inject","z":"c26113a3.aa95","name":"9 pm","props":[{"p":"payload"},{"p":"value","v":"35","vt":"str"}],"repeat":"","crontab":"00 21 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":610,"y":2380,"wires":[["23322a41d2596d58","8950273162bd1a12"]]},{"id":"23322a41d2596d58","type":"change","z":"c26113a3.aa95","name":"Office Main Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"04:0d:84:ff:fe:02:a8:d3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":2340,"wires":[["81b2b3ece02a2a13"]]},{"id":"8950273162bd1a12","type":"change","z":"c26113a3.aa95","name":"Living Room Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"94:de:b8:ff:fe:f4:c0:4d","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":2420,"wires":[["81b2b3ece02a2a13"]]},{"id":"1f8a1b6ca72e5946","type":"inject","z":"c26113a3.aa95","name":"11 pm","props":[{"p":"payload"},{"p":"value","v":"1","vt":"str"}],"repeat":"","crontab":"00 23 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":620,"y":2580,"wires":[["9fecf9f6751712b7","5831e3ae3c7cb3af"]]},{"id":"9fecf9f6751712b7","type":"change","z":"c26113a3.aa95","name":"Office Main Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"04:0d:84:ff:fe:02:a8:d3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":2540,"wires":[["5fc3088a59d37d7d"]]},{"id":"5831e3ae3c7cb3af","type":"change","z":"c26113a3.aa95","name":"Living Room Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"94:de:b8:ff:fe:f4:c0:4d","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":2620,"wires":[["5fc3088a59d37d7d"]]},{"id":"2e0bc4cdfb5d9a43","type":"comment","z":"c26113a3.aa95","name":"Most Lights","info":"","x":630,"y":1880,"wires":[]},{"id":"e40a7a6a37313ee0","type":"junction","z":"c26113a3.aa95","x":1240,"y":2280,"wires":[["cf257bc9c3e66217"]]},{"id":"4cd06a56a2b7e428","type":"junction","z":"c26113a3.aa95","x":1100,"y":1980,"wires":[["e40a7a6a37313ee0"]]},{"id":"2c21f4de242cc6a2","type":"junction","z":"c26113a3.aa95","x":1100,"y":2180,"wires":[["e40a7a6a37313ee0"]]},{"id":"81b2b3ece02a2a13","type":"junction","z":"c26113a3.aa95","x":1100,"y":2380,"wires":[["e40a7a6a37313ee0"]]},{"id":"5fc3088a59d37d7d","type":"junction","z":"c26113a3.aa95","x":1100,"y":2580,"wires":[["e40a7a6a37313ee0"]]},{"id":"cf257bc9c3e66217","type":"junction","z":"c26113a3.aa95","x":1440,"y":2280,"wires":[["d2e31579605eeb2d","e9fd08db259dcc3c"]]},{"id":"d66b167d.4338d8","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]```
1 Like

Quick Update:
Simplified the flow a bit, bit spider webby, but in a slightly controlled way. Now I only have to maintain a single change node per switch. I also added some limiters to slow things down a little as I saw some API errors randomly.

I now also have it check if the lights are on, and as long as they don’t have Full Brightness enabled (Double Click up for full brightness) the lights will start fading to the new comfort level over the span of a minute.

Flow:

[{"id":"19afc2fd89ba74f1","type":"inject","z":"c04665c6c7e5cd6c","name":"6 am","props":[{"p":"payload"},{"p":"value","v":"26","vt":"num"}],"repeat":"","crontab":"00 06 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":220,"wires":[["bcca276452165fd4","4e4b14f01939bb49","86f61b6d5d2c6a53","874addbb83c73390"]]},{"id":"4d57af8e5fb99f8e","type":"api-call-service","z":"c04665c6c7e5cd6c","name":"Set Local","server":"d66b167d.4338d8","version":5,"debugenabled":false,"domain":"zha","service":"set_zigbee_cluster_attribute","areaId":[],"deviceId":[],"entityId":[],"data":"{\"ieee\":ieee,\"cluster_id\":64561,\"attribute\":13,\"manufacturer\":4655,\"endpoint_id\":1,\"value\":value}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"all","x":1620,"y":480,"wires":[[]]},{"id":"63254535a72fc2dc","type":"api-call-service","z":"c04665c6c7e5cd6c","name":"Set Remote","server":"d66b167d.4338d8","version":5,"debugenabled":false,"domain":"zha","service":"set_zigbee_cluster_attribute","areaId":[],"deviceId":[],"entityId":[],"data":"{\"ieee\":ieee,\"cluster_id\":64561,\"attribute\":14,\"manufacturer\":4655,\"endpoint_id\":1,\"value\":value}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"all","x":1630,"y":560,"wires":[[]]},{"id":"95da0aca2840ead1","type":"change","z":"c04665c6c7e5cd6c","name":"Office Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"04:0d:84:ff:fe:02:a8:d3","tot":"str"},{"t":"set","p":"entity","pt":"msg","to":"light.office_main_lights","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":260,"wires":[["c7133a2ba466e656"]]},{"id":"5b3cd95726caaf92","type":"change","z":"c04665c6c7e5cd6c","name":"Living Room Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"94:de:b8:ff:fe:f4:c0:4d","tot":"str"},{"t":"set","p":"entity","pt":"msg","to":"light.living_room_main","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":320,"wires":[["c7133a2ba466e656"]]},{"id":"1ddf8b379176a98f","type":"inject","z":"c04665c6c7e5cd6c","name":"12 pm","props":[{"p":"payload"},{"p":"value","v":"125","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":340,"wires":[["bcca276452165fd4","4e4b14f01939bb49","86f61b6d5d2c6a53","874addbb83c73390"]]},{"id":"47f42f8a0465b805","type":"inject","z":"c04665c6c7e5cd6c","name":"9 pm","props":[{"p":"payload"},{"p":"value","v":"15","vt":"num"}],"repeat":"","crontab":"00 21 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":400,"wires":[["bcca276452165fd4","4e4b14f01939bb49","86f61b6d5d2c6a53","874addbb83c73390"]]},{"id":"85b9dd4a891d0185","type":"inject","z":"c04665c6c7e5cd6c","name":"11 pm","props":[{"p":"payload"},{"p":"value","v":"1","vt":"num"}],"repeat":"","crontab":"00 23 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":460,"wires":[["bcca276452165fd4","4e4b14f01939bb49","86f61b6d5d2c6a53","874addbb83c73390"]]},{"id":"6c6ac53e66d7b55c","type":"comment","z":"c04665c6c7e5cd6c","name":"Most Lights","info":"","x":170,"y":120,"wires":[]},{"id":"955760ec4d0d30f0","type":"comment","z":"c04665c6c7e5cd6c","name":"Nursery","info":"","x":170,"y":560,"wires":[]},{"id":"01e2610c0892de0f","type":"inject","z":"c04665c6c7e5cd6c","name":"9 am","props":[{"p":"payload"},{"p":"value","v":"127","vt":"num"}],"repeat":"","crontab":"00 09 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":640,"wires":[["a4fcf4df916e7dec"]]},{"id":"a4fcf4df916e7dec","type":"change","z":"c04665c6c7e5cd6c","name":"Nursery Main Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"04:0d:84:ff:fe:02:ba:b7","tot":"str"},{"t":"set","p":"entity","pt":"msg","to":"light.nursery_main_lights","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":720,"wires":[["6e61c2f4214d5b52"]]},{"id":"a49b79f248b67fcc","type":"inject","z":"c04665c6c7e5cd6c","name":"4 pm","props":[{"p":"payload"},{"p":"value","v":"254","vt":"num"}],"repeat":"","crontab":"00 16 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":700,"wires":[["a4fcf4df916e7dec"]]},{"id":"67a0debcd56f2743","type":"inject","z":"c04665c6c7e5cd6c","name":"7 pm","props":[{"p":"payload"},{"p":"value","v":"15","vt":"num"}],"repeat":"","crontab":"00 19 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":760,"wires":[["a4fcf4df916e7dec"]]},{"id":"a3f3b09ab3a820ca","type":"inject","z":"c04665c6c7e5cd6c","name":"8 pm","props":[{"p":"payload"},{"p":"value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":820,"wires":[["a4fcf4df916e7dec"]]},{"id":"e2eb31fae56527ac","type":"change","z":"c04665c6c7e5cd6c","name":"Master Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"04:0d:84:ff:fe:05:fa:15","tot":"str"},{"t":"set","p":"entity","pt":"msg","to":"light.master_bedroom_main","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":380,"wires":[["c7133a2ba466e656"]]},{"id":"d532e4814488c65d","type":"inject","z":"c04665c6c7e5cd6c","name":"9 am","props":[{"p":"payload"},{"p":"value","v":"60","vt":"num"}],"repeat":"","crontab":"00 09 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":280,"wires":[["bcca276452165fd4","4e4b14f01939bb49","86f61b6d5d2c6a53","874addbb83c73390"]]},{"id":"e386cc994392ba85","type":"change","z":"c04665c6c7e5cd6c","name":"Hallway Lights","rules":[{"t":"set","p":"ieee","pt":"msg","to":"04:0d:84:ff:fe:02:99:99","tot":"str"},{"t":"set","p":"entity","pt":"msg","to":"light.hallway","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":440,"wires":[["c7133a2ba466e656"]]},{"id":"b1060c3c1b03b79e","type":"comment","z":"c04665c6c7e5cd6c","name":"Light Brightness Schedule","info":"","x":150,"y":60,"wires":[]},{"id":"299b6b1f493943f3","type":"api-current-state","z":"c04665c6c7e5cd6c","name":"","server":"d66b167d.4338d8","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{entity}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1240,"y":320,"wires":[["df061fd58fd60d28"],[]]},{"id":"c29fbc500d232302","type":"api-call-service","z":"c04665c6c7e5cd6c","name":"Set ","server":"d66b167d.4338d8","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["{{entity}}"],"data":"{\"brightness\":(value+2), \"transition\":60}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1670,"y":320,"wires":[[]]},{"id":"6c619c0ae3c5401a","type":"delay","z":"c04665c6c7e5cd6c","name":"","pauseType":"rate","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1130,"y":500,"wires":[["80490cb4f7891669","505d9ad1d7cecaeb"]]},{"id":"505d9ad1d7cecaeb","type":"delay","z":"c04665c6c7e5cd6c","name":"","pauseType":"rate","timeout":"1.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1390,"y":560,"wires":[["63254535a72fc2dc"]]},{"id":"80490cb4f7891669","type":"delay","z":"c04665c6c7e5cd6c","name":"","pauseType":"rate","timeout":"1.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1390,"y":480,"wires":[["4d57af8e5fb99f8e"]]},{"id":"df061fd58fd60d28","type":"switch","z":"c04665c6c7e5cd6c","name":"Not Full Brightness?","property":"data.attributes.brightness","propertyType":"msg","rules":[{"t":"neq","v":"254","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1480,"y":320,"wires":[["c29fbc500d232302"]]},{"id":"fcea686644bc8738","type":"junction","z":"c04665c6c7e5cd6c","x":800,"y":320,"wires":[["3fef3515b5f73942"]]},{"id":"c7133a2ba466e656","type":"junction","z":"c04665c6c7e5cd6c","x":660,"y":320,"wires":[["fcea686644bc8738"]]},{"id":"61cb6dfbd0ae08ea","type":"junction","z":"c04665c6c7e5cd6c","x":1200,"y":500,"wires":[[]]},{"id":"e79b2c1d39d6b8d1","type":"junction","z":"c04665c6c7e5cd6c","x":800,"y":720,"wires":[["3fef3515b5f73942"]]},{"id":"bcca276452165fd4","type":"junction","z":"c04665c6c7e5cd6c","x":360,"y":260,"wires":[["95da0aca2840ead1"]]},{"id":"4e4b14f01939bb49","type":"junction","z":"c04665c6c7e5cd6c","x":360,"y":320,"wires":[["5b3cd95726caaf92"]]},{"id":"86f61b6d5d2c6a53","type":"junction","z":"c04665c6c7e5cd6c","x":360,"y":380,"wires":[["e2eb31fae56527ac"]]},{"id":"874addbb83c73390","type":"junction","z":"c04665c6c7e5cd6c","x":360,"y":440,"wires":[["e386cc994392ba85"]]},{"id":"6e61c2f4214d5b52","type":"junction","z":"c04665c6c7e5cd6c","x":660,"y":720,"wires":[["e79b2c1d39d6b8d1"]]},{"id":"3fef3515b5f73942","type":"junction","z":"c04665c6c7e5cd6c","x":1020,"y":500,"wires":[["6c619c0ae3c5401a","299b6b1f493943f3"]]},{"id":"d66b167d.4338d8","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]