After playing around, I almost got to where I wanted to be.
Colin you're right, I can send whatever payload I want to be displayed.
My goal is to have a universal flow which creates a toggle button with notification window for a kind of "are you sure?" dialog.
I have three open issues:
- I'm not able to preserve the original state of "Printer". But I need to since at the end I need to toggle based on the Notification Dialog result. Is there any clever way to achieve that?
- How do I display the Topic name on the toggle button?
- And this is more cosmetic, the first function which creates the "Phrase" or notification topic, how do I create that in the button template instead of using a separate function?
[{"id":"f27959d3.60f5f8","type":"ui_toast","z":"72373649.58baf8","position":"dialog","displayTime":"3","highlight":"","outputs":1,"ok":"Yes","cancel":"No","topic":"","name":"","x":570,"y":260,"wires":[["ae4a1df8.118e58","b9313c5.c09d94"]]},{"id":"d614d424.5b8a1","type":"ui_template","z":"72373649.58baf8","group":"c713dff5.21ab3","name":"Toggle Button","order":1,"width":"3","height":"2","format":"<md-button\n class=\"vibrate filled bigfont\"\n ng-style=\"{background: !msg.payload ? 'red' : 'green' }\"\n ng-click=\"send({payload: msg.notification})\"\n > \n msg.topic\n </md-button>","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":360,"y":260,"wires":[["f27959d3.60f5f8","d7863455.7aa8"]]},{"id":"b9313c5.c09d94","type":"debug","z":"72373649.58baf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":750,"y":320,"wires":[]},{"id":"46b40042.ad6318","type":"function","z":"72373649.58baf8","name":"","func":"msg.notification = (msg.payload == \"true\" ? ('Turn on ' + msg.topic + '?') : ('Turn off ' + msg.topic + '?'));\nreturn msg;","outputs":1,"noerr":0,"x":190,"y":260,"wires":[["d614d424.5b8a1","1f9920ce.224d37"]]},{"id":"d7863455.7aa8","type":"debug","z":"72373649.58baf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":550,"y":320,"wires":[]},{"id":"aff37395.212b88","type":"mqtt in","z":"72373649.58baf8","name":"","topic":"Printer","qos":"2","broker":"aa21acb8.2e7348","x":70,"y":260,"wires":[["46b40042.ad6318"]]},{"id":"ae4a1df8.118e58","type":"function","z":"72373649.58baf8","name":"","func":"msg.payload = (msg.payload == \"Yes\") ? !msg.payload : msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":260,"wires":[["c9fecf21.a0a7c8","5de67d26.b386ac"]]},{"id":"c9fecf21.a0a7c8","type":"mqtt out","z":"72373649.58baf8","name":"","topic":"Printer","qos":"","retain":"","broker":"aa21acb8.2e7348","x":930,"y":260,"wires":[]},{"id":"1f9920ce.224d37","type":"debug","z":"72373649.58baf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":330,"y":320,"wires":[]},{"id":"5de67d26.b386ac","type":"debug","z":"72373649.58baf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":930,"y":320,"wires":[]},{"id":"c713dff5.21ab3","type":"ui_group","z":"","name":"Arbeitszimmer","tab":"a2b4d00e.93a548","order":1,"disp":false,"width":"10","collapse":false},{"id":"aa21acb8.2e7348","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"a2b4d00e.93a548","type":"ui_tab","z":"","name":"Arbeitszimmer","icon":"book","order":1}]