Hi All
Right i am now getting somwhere.
So, if the doobell is pressed (at the moment im using a timestamp trigger to make it easier), it takes the current state, (colour, brightness or if the light is off)
This is now all working as expected, however i have one issue below:
The only issue i am having at the minute, is if the light is turned off, it doesnāt record the previous colour setting, so when you turn the light back on, its blue for example. I have this going back to white at the end of the flow, so if the light was off, it does come back on white. Now i can live with this, but it woul dbe great if i could get it to return to its previous state etc.
So, can anyone help me with a flow that will use context, to turn the light on briefly, and give 2 msg payloads, and depending if the light was on or off, to then inject the correct payload?
My current flow is below:
[{"id":"10258ce4.19a9c3","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"47d61b16.4bfe14","type":"inject","z":"10258ce4.19a9c3","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":240,"wires":[["d1c28401.6845f8","8d4e4f44.cb75e"]]},{"id":"d1c28401.6845f8","type":"api-current-state","z":"10258ce4.19a9c3","name":"","server":"7d041947.e86358","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.hue_color_lamp_1","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":410,"y":240,"wires":[["c67b9c40.1e714"]]},{"id":"6ff82db6.68c944","type":"debug","z":"10258ce4.19a9c3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","statusVal":"","statusType":"auto","x":1110,"y":80,"wires":[]},{"id":"c67b9c40.1e714","type":"switch","z":"10258ce4.19a9c3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":670,"y":240,"wires":[["1430417e.d4fe3f"],["af1d4ce8.60667"]]},{"id":"1430417e.d4fe3f","type":"change","z":"10258ce4.19a9c3","name":"","rules":[{"t":"set","p":"lightState","pt":"flow","to":"{ \"service\" : \"turn_on\",\t \"data\" : { \t \"entity_id\" : $string(topic),\t \"brightness\" : $number(data.attributes.brightness),\t \"rgb_color\" : data.attributes.rgb_color\t }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":200,"wires":[["4e68968e.e92788","6ff82db6.68c944"]]},{"id":"af1d4ce8.60667","type":"change","z":"10258ce4.19a9c3","name":"","rules":[{"t":"set","p":"lightState","pt":"flow","to":"{ \"service\" : \"turn_off\",\t \"data\" : { \t \"entity_id\" : $string(topic)\t }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":260,"wires":[["4e68968e.e92788","6ff82db6.68c944"]]},{"id":"6d14209d.f12ff","type":"inject","z":"10258ce4.19a9c3","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1100,"y":800,"wires":[[]]},{"id":"561b95ab.7dca2c","type":"change","z":"10258ce4.19a9c3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"lightState","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":340,"wires":[["c659f32a.951b","16a34f34.316cd1"]]},{"id":"c659f32a.951b","type":"api-call-service","z":"10258ce4.19a9c3","name":"","server":"7d041947.e86358","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hue_color_lamp_1","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":810,"y":340,"wires":[[]]},{"id":"16a34f34.316cd1","type":"debug","z":"10258ce4.19a9c3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":770,"y":400,"wires":[]},{"id":"7ae96554.093a0c","type":"inject","z":"10258ce4.19a9c3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":880,"wires":[["9615d676.e6c408"]]},{"id":"4e68968e.e92788","type":"api-call-service","z":"10258ce4.19a9c3","name":"","server":"7d041947.e86358","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hue_color_lamp_1","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1130,"y":220,"wires":[["e9e0be2b.61073"]]},{"id":"e9e0be2b.61073","type":"api-call-service","z":"10258ce4.19a9c3","name":"","server":"7d041947.e86358","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hue_color_lamp_1","data":"{\"brightness\":\"255\",\"color_name\":\"blue\",\"flash\":\"long\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1390,"y":220,"wires":[["71c2ae6e.d2793"]]},{"id":"9615d676.e6c408","type":"api-call-service","z":"10258ce4.19a9c3","name":"","server":"7d041947.e86358","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hue_color_lamp_1","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":380,"y":880,"wires":[["940b1706.ea3708"]]},{"id":"940b1706.ea3708","type":"api-call-service","z":"10258ce4.19a9c3","name":"","server":"7d041947.e86358","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hue_color_lamp_1","data":"{\"color_name\":\"white\",\"brightness\":\"255\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":630,"y":880,"wires":[[]]},{"id":"8d4e4f44.cb75e","type":"delay","z":"10258ce4.19a9c3","name":"","pauseType":"delay","timeout":"16","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":340,"wires":[["561b95ab.7dca2c"]]},{"id":"71c2ae6e.d2793","type":"delay","z":"10258ce4.19a9c3","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1640,"y":220,"wires":[["8f492b20.89a558"]]},{"id":"8f492b20.89a558","type":"api-call-service","z":"10258ce4.19a9c3","name":"","server":"7d041947.e86358","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hue_color_lamp_1","data":"{\"color_name\":\"white\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1860,"y":220,"wires":[[]]},{"id":"7d041947.e86358","type":"server","name":"Home Assistant - Pi","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]