Iâm sorry for the late reply.
Here is a picture of the flow:
Here is an export of the flow:
[{"id":"c8d04565.caeae8","type":"tab","label":"Loft","disabled":false,"info":""},{"id":"a25b6a5b.801cb8","type":"switch","z":"c8d04565.caeae8","name":"Valg","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"brightness_move_up","vt":"str"},{"t":"eq","v":"brightness_move_down","vt":"str"},{"t":"eq","v":"brightness_stop","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":470,"y":760,"wires":[["b47d1fd9.59c24","df0be10c.e8961"],["448d443d.96e96c","57fe9b4e.d01744"],["2e1e7788.81b648"],["dbac15f3.d2e908"],["13dea8ec.9dfcd7"]]},{"id":"b47d1fd9.59c24","type":"api-current-state","z":"c8d04565.caeae8","name":"Already on?","server":"22f5da40.d3e236","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":690,"y":540,"wires":[["e74d91e2.f0912"],["bdad43dd.7e1b4"]]},{"id":"e74d91e2.f0912","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn on - Max","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.light_loft_gang_taklys","data":"{\"brightness\": 254}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1280,"y":480,"wires":[[]]},{"id":"bdad43dd.7e1b4","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn on","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.light_loft_gang_taklys","data":"{\"brightness\": 180}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":540,"wires":[[]]},{"id":"448d443d.96e96c","type":"api-current-state","z":"c8d04565.caeae8","name":"Already off?","server":"22f5da40.d3e236","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":690,"y":600,"wires":[[],["98f994c4.1ae5a8"]]},{"id":"98f994c4.1ae5a8","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn off","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.light_loft_gang_taklys","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":600,"wires":[[]]},{"id":"3d4a7472.29aa1c","type":"api-current-state","z":"c8d04565.caeae8","name":"Status","server":"22f5da40.d3e236","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1010,"y":840,"wires":[["3ff617a1.c7dbc8"],[]]},{"id":"d23ffca9.d431","type":"api-call-service","z":"c8d04565.caeae8","name":"Light On","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"","data":"{ \"entity_id\": \"group.light_loft_gang_taklys\", \"brightness\": {{payload}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1380,"y":840,"wires":[[]]},{"id":"3ff617a1.c7dbc8","type":"function","z":"c8d04565.caeae8","name":"Brightness +30","func":"\nvar brightness = msg.data.attributes.brightness;\n\nbrightness = parseInt(brightness);\n\nif (brightness < 224) {\n brightness = brightness + 30;\n} else {\n brightness = 254;\n}\n\nmsg.payload = brightness;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":840,"wires":[["d23ffca9.d431"]]},{"id":"2e1e7788.81b648","type":"trigger","z":"c8d04565.caeae8","name":"Resend","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-500","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":860,"y":840,"wires":[["3d4a7472.29aa1c"]]},{"id":"6fa4d2fd.29cf6c","type":"api-current-state","z":"c8d04565.caeae8","name":"Status","server":"22f5da40.d3e236","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1010,"y":900,"wires":[["1b06e9c.bdc4c16"],[]]},{"id":"23cb20c5.bf7fd","type":"api-call-service","z":"c8d04565.caeae8","name":"Light Off","server":"22f5da40.d3e236","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.light_loft_gang_taklys","data":"{\"brightness\": {{payload}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1380,"y":900,"wires":[[]]},{"id":"1b06e9c.bdc4c16","type":"function","z":"c8d04565.caeae8","name":"Brightness -30","func":"\nvar brightness = msg.data.attributes.brightness;\n\nbrightness = parseInt(brightness);\n\nif (brightness >= 30) {\n brightness = brightness - 30;\n} else {\n brightness = 0;\n}\n\nmsg.payload = brightness;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":900,"wires":[["23cb20c5.bf7fd"]]},{"id":"dbac15f3.d2e908","type":"trigger","z":"c8d04565.caeae8","name":"Resend","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-500","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":860,"y":900,"wires":[["6fa4d2fd.29cf6c"]]},{"id":"b591f0df.663b2","type":"mqtt in","z":"c8d04565.caeae8","name":"Loft - Gang - Lysbryter","topic":"zigbee2mqtt/Loft - Gang - Lysbryter","qos":"0","datatype":"json","broker":"3d06dee0.f98b0a","x":160,"y":760,"wires":[["a25b6a5b.801cb8"]]},{"id":"13dea8ec.9dfcd7","type":"change","z":"c8d04565.caeae8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":860,"wires":[["2e1e7788.81b648","dbac15f3.d2e908"]]},{"id":"328d9492.69a7fc","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn on","server":"c20c4f32.3a7de","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"group.light_loft_gang_taklys","data":"{\"brightness\":{{{payload}}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":200,"wires":[[]]},{"id":"66c00d69.935014","type":"api-current-state","z":"c8d04565.caeae8","name":"Already on?","server":"c20c4f32.3a7de","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":670,"y":200,"wires":[[],["d33e8b50.1cf5d8","b0a3631f.fbad"]]},{"id":"cc281130.ff1dd","type":"api-call-service","z":"c8d04565.caeae8","name":"Turn off","server":"c20c4f32.3a7de","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.light_loft_gang_taklys","data":"{\"transition\": 10}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":400,"wires":[[]]},{"id":"a6456619.b41898","type":"inject","z":"c8d04565.caeae8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":130,"y":200,"wires":[["66c00d69.935014"]]},{"id":"3cc3eeae.209542","type":"inject","z":"c8d04565.caeae8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":130,"y":400,"wires":[["14e51033.64d2c"]]},{"id":"480545a5.befb6c","type":"trigger","z":"c8d04565.caeae8","name":"60 sec delay","op1":"","op2":"on","op1type":"nul","op2type":"str","duration":"60","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1090,"y":400,"wires":[["cc281130.ff1dd"]]},{"id":"d33e8b50.1cf5d8","type":"change","z":"c8d04565.caeae8","name":"Light Brightness Adjustment","rules":[{"t":"set","p":"payload","pt":"msg","to":"Light_Brightness","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":200,"wires":[["328d9492.69a7fc"]]},{"id":"c4c618c0.3671d8","type":"switch","z":"c8d04565.caeae8","name":"True or False","property":"payload.occupancy","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":300,"wires":[["66c00d69.935014"],["14e51033.64d2c"]]},{"id":"c91fd5be.057b28","type":"mqtt in","z":"c8d04565.caeae8","name":"Loft - Motion sensor","topic":"zigbee2mqtt/Loft - Gang - Motion Sensor","qos":"2","datatype":"json","broker":"3d06dee0.f98b0a","x":150,"y":300,"wires":[["c4c618c0.3671d8"]]},{"id":"14e51033.64d2c","type":"api-current-state","z":"c8d04565.caeae8","name":"Already off?","server":"c20c4f32.3a7de","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.light_loft_gang_taklys","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":690,"y":400,"wires":[["3900f36c.7175ac"],[]]},{"id":"df0be10c.e8961","type":"api-call-service","z":"c8d04565.caeae8","name":"Boolean Light On","server":"c20c4f32.3a7de","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.helper_loft_lysbryter","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":680,"wires":[[]]},{"id":"3900f36c.7175ac","type":"api-current-state","z":"c8d04565.caeae8","name":"Lys fra bryter?","server":"c20c4f32.3a7de","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.helper_loft_lysbryter","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":880,"y":400,"wires":[[],["480545a5.befb6c"]]},{"id":"57fe9b4e.d01744","type":"api-call-service","z":"c8d04565.caeae8","name":"Boolean Light Off","server":"c20c4f32.3a7de","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.helper_loft_lysbryter","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":740,"wires":[[]]},{"id":"6ab49071.0ee37","type":"inject","z":"c8d04565.caeae8","name":"Reduce Brightness at 21:00","props":[{"p":"payload"},{"p":"topic","v":"Light_Brightness","vt":"num"}],"repeat":"","crontab":"00 21 * * *","once":false,"onceDelay":"","topic":"","payload":"20","payloadType":"num","x":200,"y":140,"wires":[["9a5ba6c.9b25758"]]},{"id":"56c351ae.2f3b3","type":"inject","z":"c8d04565.caeae8","name":"Normal Brightness at 6:00","props":[{"p":"payload"},{"p":"topic","v":"Light_Brightness","vt":"num"}],"repeat":"","crontab":"00 06 * * *","once":false,"onceDelay":"","topic":"","payload":"150","payloadType":"num","x":200,"y":80,"wires":[["9a5ba6c.9b25758"]]},{"id":"9a5ba6c.9b25758","type":"change","z":"c8d04565.caeae8","name":"Light Brightness Adjustment","rules":[{"t":"set","p":"Light_Brightness","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":100,"wires":[[]]},{"id":"b0a3631f.fbad","type":"api-call-service","z":"c8d04565.caeae8","name":"Boolean Light Off","server":"c20c4f32.3a7de","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.helper_loft_lysbryter","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1290,"y":260,"wires":[[]]},{"id":"22f5da40.d3e236","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"3d06dee0.f98b0a","type":"mqtt-broker","name":"localhost - Min","broker":"mqtt://core-mosquitto","port":"1883","tls":"","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"c20c4f32.3a7de","type":"server","name":"Home Assistant - Min","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
The switch is a Philips Hue light switch connected by Zigbee2MQTT. The light is connected via the Philips Hue bridge.
Thanks.