Shelly Dimmer2 MQTT brightness scenarios

I have Shelly Dimmer2 which I want to control via MQTT in node red.
I want to set different dim scenarios depending on what Brightness state is.

When i press the button, I like to have brightness and on/off status. Dimmer2 must set according to eg if Brightness is 0% and Off it must switch on 100%, If Brightness is on 100% it must switch on brightness 30% and if Brightness is 1-30% switch on brightness 60%. If the brightness is 31-60% it should set brightness to 0% and off.

Try this

[{"id":"81ac6f04f07ebdf7","type":"switch","z":"f80b6c338afd5483","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"btwn","v":"1","vt":"num","v2":"30","v2t":"num"},{"t":"btwn","v":"31","vt":"num","v2":"60","v2t":"num"},{"t":"eq","v":"100","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":600,"y":620,"wires":[[],[],[],[]]},{"id":"9328452fa7922e11","type":"inject","z":"f80b6c338afd5483","name":"button press","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":150,"y":620,"wires":[["5c25363505d1361f"]]},{"id":"5c25363505d1361f","type":"api-current-state","z":"f80b6c338afd5483","name":"","server":"6b1110b5.183a4","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$entity().attributes.brightness","valueType":"jsonata"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":360,"y":620,"wires":[["81ac6f04f07ebdf7"]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Thanks, but this uses “Home Assistant” and i like to use Mqtt…

Are you saying the light is not an entity in home assistant? The flow above gets the brightness state of the light, depending on the state routes the message through the switch. After the switch you can call whatever mqtt service call you want.

Okay thanks, i just thought it was better (more stabil) to ude mqtt as much as possiable. I Will tryk to look more info it