Node red instead of tplink integration

I have been having slight challenges with the stock tplink integration. I try to sync another light to the tplink switch but because of the polling time the delay could be to long. Also I cant seem to get rid of the log errors and occasionally devices will not function after a reboot (largely fixed by putting the ip’s in config.yaml).

I had been using the node red tplink nodes for my syncing and it has worked great so I thought I wonder if I can go the other way also. After playing around I used the entity node to create a home assistant and a couple of flows to sync everything up. the advantage is adjustable polling and devices always available.

[{"id":"384fca3a.995fd6","type":"subflow","name":"Subflow 1","info":"","in":[{"x":140,"y":320,"wires":[{"id":"f2add863.8faa08"}]}],"out":[{"x":580,"y":120,"wires":[{"id":"8f1b41b9.23b37","port":0}]},{"x":580,"y":120,"wires":[{"id":"8f1b41b9.23b37","port":1}]}]},{"id":"8f1b41b9.23b37","type":"switch","z":"384fca3a.995fd6","g":"25465464.d2c08c","name":"On/Off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":120,"wires":[[],[]]},{"id":"f2add863.8faa08","type":"change","z":"384fca3a.995fd6","g":"25465464.d2c08c","name":"","rules":[{"t":"move","p":"payload.state","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":320,"wires":[["a1d3a720.12e118"]]},{"id":"a1d3a720.12e118","type":"change","z":"384fca3a.995fd6","g":"25465464.d2c08c","name":"true,false/On,off","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"on","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":200,"wires":[["8f1b41b9.23b37"]]},{"id":"39fa97bc.6a2f98","type":"debug","z":"7c807148.ea8d4","name":"TPLink","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":980,"y":580,"wires":[]},{"id":"fff64752.b4a948","type":"kasa","z":"7c807148.ea8d4","name":"back deck barbeque lights - HS200(US)","device":"10.0.0.213","interval":"10000","eventInterval":"1000","payload":"getQuickInfo","payloadType":"info","debug":false,"x":220,"y":400,"wires":[["1462b30e.7bc12d"]]},{"id":"bf8b6acc.7858d8","type":"inject","z":"7c807148.ea8d4","name":"Start Power Events","props":[{"p":"payload"}],"repeat":"900","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"startPowerEvents","payloadType":"str","x":170,"y":340,"wires":[["fff64752.b4a948"]]},{"id":"1462b30e.7bc12d","type":"subflow:384fca3a.995fd6","z":"7c807148.ea8d4","name":"Convert tplink to switch","env":[],"x":530,"y":400,"wires":[["2569d0f0.1b6ec"],["3fef1060.41db1"]]},{"id":"2569d0f0.1b6ec","type":"api-call-service","z":"7c807148.ea8d4","name":"back deck bbq 2","server":"","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.back_dech_bbq_2","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":920,"y":340,"wires":[[]]},{"id":"3fef1060.41db1","type":"api-call-service","z":"7c807148.ea8d4","name":"back deck bbq 2","server":"","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.back_dech_bbq_2","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":920,"y":400,"wires":[[]]},{"id":"600b3331.2e1a1c","type":"comment","z":"7c807148.ea8d4","name":"tplink switch in home assistant with a virtual switch","info":"make a virtual switch then use this to integrate tplink switch's\n2 flows 1st for syncing physical status to entity\n2nd to have entity physically change switch\n","x":510,"y":320,"wires":[]},{"id":"c11c2464.c50928","type":"change","z":"7c807148.ea8d4","name":"on/off to true/false","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"true","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":500,"wires":[["23cf306c.f3544"]]},{"id":"23cf306c.f3544","type":"kasa","z":"7c807148.ea8d4","name":"back deck barbeque lights - HS200(US)","device":"10.0.0.213","interval":60000,"eventInterval":"2000","payload":"","payloadType":"str","debug":true,"x":720,"y":500,"wires":[[]]},{"id":"6fbadeb6.e2a09","type":"link in","z":"7c807148.ea8d4","name":"in from virt switches","links":["f8bac6db.037158"],"x":115,"y":500,"wires":[["c11c2464.c50928","39fa97bc.6a2f98"]]},{"id":"53a1134b.19da8c","type":"comment","z":"7c807148.ea8d4","name":"updates the entity based on physical changes","info":"","x":530,"y":360,"wires":[]},{"id":"ed629611.441be8","type":"comment","z":"7c807148.ea8d4","name":"entity turns switch on/off","info":"","x":550,"y":460,"wires":[]}]