Last Updated or created 2023-06-21
Our bedroom has a shelly dimmer, this one is connected with a wall switch and is being controlled by Domoticz, Home Assistant and NodeRed.
I had to fix some stuff, so this was a perfect time to jot down some notes.
I’ve wired it up like this:
(I’ve got a Line wire in my ceiling socket, so i placed the module there instead of the wall socket)
Configure the Shelly as mentioned in the manual. After that do the following:
Advance > Developer settings :
(Enable CoIot if you want a easy auto detect for Home Assistant)
Enable MQTT (This will DISABLE cloud ! )
Server: the ip number of your Mqtt Broker
Next I did was:
Now the wall switch will change/toggle what the current state is.
(If the light is off, and you switch it on using Mqtt, you probably needed to hit the switch two times to turn it off again. Not so with this setting.)
My Nodered Flow ( Not using the Shelly palette nodes in this example)
The Mqtt IN node sets the state of the switch when you use the wall switch!
Cozy turns light on at a specific level.
The slider send an off command when 0% selected, else an on command and the sliders value.
# Cozy function msg.payload = {}; msg.payload.turn="on"; msg.payload.brightness=30; return msg; # Slider function var varlevel = msg.payload; msg.payload = {}; if(varlevel == 0){ msg.payload.turn="off"; } else { msg.payload.turn="on"; } msg.payload.brightness=varlevel; return msg;
DashBoard
The Flow
[ { "id": "32d1c58277d38408", "type": "ui_switch", "z": "746c372deb597681", "name": "", "label": "Bedroom lights2", "tooltip": "", "group": "c387df0cfc06c60e", "order": 3, "width": 0, "height": 0, "passthru": false, "decouple": "true", "topic": "", "topicType": "str", "style": "", "onvalue": "on", "onvalueType": "str", "onicon": "", "oncolor": "", "offvalue": "off", "offvalueType": "str", "officon": "", "offcolor": "", "animate": true, "className": "", "x": 220, "y": 940, "wires": [ [ "df432d3faea35f38" ] ] }, { "id": "fb12eddd50d3013e", "type": "ui_slider", "z": "746c372deb597681", "name": "", "label": "Bedroom Lights2", "tooltip": "", "group": "c387df0cfc06c60e", "order": 4, "width": 0, "height": 0, "passthru": true, "outs": "end", "topic": "", "topicType": "str", "min": 0, "max": "100", "step": 1, "className": "", "x": 230, "y": 900, "wires": [ [ "d9c299ec7c0c82b0" ] ] }, { "id": "d9c299ec7c0c82b0", "type": "function", "z": "746c372deb597681", "name": "Get level", "func": "var varlevel = msg.payload;\nmsg.payload = {};\n\nif(varlevel == 0){ \nmsg.payload.turn=\"off\";\n} else\n{\n msg.payload.turn=\"on\";\n}\n\nmsg.payload.brightness=varlevel;\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 460, "y": 900, "wires": [ [ "315ffbe441467c10" ] ] }, { "id": "df432d3faea35f38", "type": "mqtt out", "z": "746c372deb597681", "name": "", "topic": "shellies/shellydimmer-CFE204/light/0/command", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "8c74c5f6.9a7a48", "x": 800, "y": 940, "wires": [] }, { "id": "315ffbe441467c10", "type": "mqtt out", "z": "746c372deb597681", "name": "", "topic": "shellies/shellydimmer-CFE204/light/0/set", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "8c74c5f6.9a7a48", "x": 780, "y": 900, "wires": [] }, { "id": "15f1c904607a0adc", "type": "function", "z": "746c372deb597681", "name": "Cozy", "func": "msg.payload = {};\n\nmsg.payload.turn=\"on\";\n\nmsg.payload.brightness=30;\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 450, "y": 860, "wires": [ [ "315ffbe441467c10" ] ] }, { "id": "57fb1210d37e5325", "type": "ui_button", "z": "746c372deb597681", "name": "", "group": "c387df0cfc06c60e", "order": 5, "width": 0, "height": 0, "passthru": false, "label": "Bedroom lights2 Cozy", "tooltip": "", "color": "", "bgcolor": "", "className": "", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 240, "y": 860, "wires": [ [ "15f1c904607a0adc" ] ] }, { "id": "30cba96b08f3b830", "type": "mqtt in", "z": "746c372deb597681", "name": "", "topic": "shellies/shellydimmer-CFE204/light/0", "qos": "2", "datatype": "auto-detect", "broker": "8c74c5f6.9a7a48", "nl": false, "rap": true, "rh": 0, "inputs": 0, "x": 240, "y": 1000, "wires": [ [ "32d1c58277d38408" ] ] }, { "id": "c387df0cfc06c60e", "type": "ui_group", "name": "Bedroom", "tab": "f177532a78f3f1d2", "order": 3, "disp": true, "width": "6", "collapse": true, "className": "" }, { "id": "8c74c5f6.9a7a48", "type": "mqtt-broker", "name": "IPBROKER", "broker": "IPBROKER", "port": "1883", "clientid": "", "usetls": false, "compatmode": true, "keepalive": "15", "cleansession": true, "birthTopic": "", "birthQos": "0", "birthPayload": "", "closeTopic": "", "closePayload": "", "willTopic": "", "willQos": "0", "willPayload": "" }, { "id": "f177532a78f3f1d2", "type": "ui_tab", "name": "House", "icon": "dashboard", "order": 1, "disabled": false, "hidden": false } ]