New Shelly Pro 4PM - wifi & LAN & MQTT - First of Shelly Pro Series

Mine still has not shipped.

for switch i try this :

 - platform: mqtt
   name: "Shelly 4Pro PM Relay 0"
   unique_id: "shelly4pmpro-84CCA87E46F8-switch-0"
   command_topic: "shelly4pmpro-84CCA87E46F8/rpc"
   payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 0, "on": true}}'
   payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 0, "on": false}}'
   state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:0"
   value_template: "{{ value_json.output }}"
   state_on: true
   state_off: false
   qos: 1   
 - platform: mqtt
   name: "Shelly 4Pro PM Relay 1"
   unique_id: "shelly4pmpro-84CCA87E46F8-switch-1"
   command_topic: "shelly4pmpro-84CCA87E46F8/rpc"
   payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 1, "on": true}}'
   payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 1, "on": false}}'
   state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:1"
   value_template: "{{ value_json.output }}"
   state_on: true
   state_off: false
   qos: 1   
 - platform: mqtt
   name: "Shelly 4Pro PM Relay 2"
   unique_id: "shelly4pmpro-84CCA87E46F8-switch-2"
   command_topic: "shelly4pmpro-84CCA87E46F8/rpc"
   payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 2, "on": true}}'
   payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 2, "on": false}}'
   state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:2"
   value_template: "{{ value_json.output }}"
   state_on: true
   state_off: false
   qos: 1   
 - platform: mqtt
   name: "Shelly 4Pro PM Relay 3"
   unique_id: "shelly4pmpro-84CCA87E46F8-switch-3"
   command_topic: "shelly4pmpro-84CCA87E46F8/rpc"
   payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 3, "on": true}}'
   payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 3, "on": false}}'
   state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:3"
   value_template: "{{ value_json.output }}"
   state_on: true
   state_off: false
   qos: 1      

for sensor :

   ############################################################
   ##                                                        ##
   ##                     Sensor Shelly Cabane               ##
   ##                                                        ##
   ############################################################
###### Voltage 1
  - platform: mqtt
    name: “Voltage cabane Sw1”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:0"
    unit_of_measurement: “V”
    value_template: "{{ value_json.voltage }}"
###### Voltage 2
  - platform: mqtt
    name: “Voltage cabane Sw2”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:1"
    unit_of_measurement: “V”
    value_template: "{{ value_json.voltage }}"
###### Voltage 3
  - platform: mqtt
    name: “Voltage cabane Sw3”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:2"
    unit_of_measurement: “V”
    value_template: "{{ value_json.voltage }}"
###### Voltage 4
  - platform: mqtt
    name: “Voltage cabane Sw4”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:3"
    unit_of_measurement: “V”
    value_template: "{{ value_json.voltage }}"
    
###### Power 1
  - platform: mqtt
    name: “Puissance cabane Sw1”
    unit_of_measurement: “W”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:0" 
    value_template: "{{ value_json.apower }}"
###### Power 2
  - platform: mqtt
    name: “Puissance cabane Sw2”
    unit_of_measurement: “W”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:1" 
    value_template: "{{ value_json.apower }}"
###### Power 3
  - platform: mqtt
    name: “Puissance cabane Sw3”
    unit_of_measurement: “W”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:2" 
    value_template: "{{ value_json.apower }}"
###### Power 4
  - platform: mqtt
    name: “Puissance cabane Sw4”
    unit_of_measurement: “W”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:3" 
    value_template: "{{ value_json.apower }}"

###### Energy 1
  - platform: mqtt
    name: “Consommation cabane Sw1”
    unit_of_measurement: “kWh”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:0" 
    value_template: "{{ value_json['aENERGY'].Total }}"
 
###### Energy 2
  - platform: mqtt
    name: “Consommation cabane Sw2”
    unit_of_measurement: “kWh”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:1" 
    value_template: "{{ value_json['aENERGY'].Total }}"
 
###### Energy 3
  - platform: mqtt
    name: “Consommation cabane Sw3”
    unit_of_measurement: “kWh”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:2" 
    value_template: "{{ value_json['aENERGY'].Total }}"
 
###### Energy 4
  - platform: mqtt
    name: “Consommation cabane Sw4”
    unit_of_measurement: “kWh”
    state_topic: "shelly4pmpro-84CCA87E46F8/status/switch:3" 
    value_template: "{{ value_json['aENERGY'].Total }}"
3 Likes

Now integrated with Home Assistant Core 2021.10.0 and working perfectly.

1 Like

Did you do anything specifically to get it discovered, I have tried almost anything and it is still not shown, I have other shelly products that are discovered nicely and I am running the latest 2021.10.6

There are still some bugs. If you activate the deactivated sensors, you quickly lose everything else…

Maybe do you know, how to also set up MQTT for input sensors.

I can control MQTT output 1 to 4, but I also need information on input, as I will use device as detached mode, so that I will just to check inputs independetly…

Thank you…

So… that I write correctly, I would like also saw the state of input 1, 2, 3, 4 as binary_sensor via mqtt protocol.

As I am aware this can be done as the same thing is working on Shelly 2.5, but via HA integration or Shelly4HASS, where Shelly Pro 4PM is yet not supported…

Anybody achieve this?

As of today this is working via auto discovery with the most up to date (non beta) Shelly firmware: 20210921-202058/0.8.1-g52de872 and HA core version: core-2021.11.4

This gives switch control and power readings, however the default disabled entities such as binary sensors to indicate input state and voltage sensors are not working.

If anyone has success in getting this working please let us know.

For inputs use binary_sensor:

  - platform: mqtt
    name: "Shelly Pro 4PM Input 1"
    state_topic: 'shellypro4pm-XXXX-kabinet/events/rpc'
    value_template: >- 
      {% if ('input:0') and ('long_push') in value %}   
        {{'ON'}}
      {% elif ('input:0') and ('single_push') in value %}   
        {{'ON'}}
      {% elif ('input:0') and ('btn_up') in value %}   
        {{'OFF'}}
      {% else %}
        {{ states('binary_sensor.shelly_pro_4pm_input_1') }}
      {% endif %}
  - platform: mqtt
    name: "Shelly Pro 4PM Input 2"
    state_topic: 'shellypro4pm-XXXX-kabinet/events/rpc'
    value_template: >- 
      {% if ('input:1') and ('long_push') in value %}   
        {{'ON'}}
      {% elif ('input:1') and ('single_push') in value %}   
        {{'ON'}}
      {% elif ('input:1') and ('btn_up') in value %}   
        {{'OFF'}}
      {% else %}
        {{ states('binary_sensor.shelly_pro_4pm_input_2') }}
      {% endif %}
  - platform: mqtt
    name: "Shelly Pro 4PM Input 3"
    state_topic: 'shellypro4pm-XXXX-kabinet/events/rpc'
    value_template: >- 
      {% if ('input:2') and ('long_push') in value %}   
        {{'ON'}}
      {% elif ('input:2') and ('single_push') in value %}   
        {{'ON'}}
      {% elif ('input:2') and ('btn_up') in value %}   
        {{'OFF'}}
      {% else %}
        {{ states('binary_sensor.shelly_pro_4pm_input_3') }}
      {% endif %}
  - platform: mqtt
    name: "Shelly Pro 4PM Input 4"
    state_topic: 'shellypro4pm-XXXX-kabinet/events/rpc'
    value_template: >- 
      {% if ('input:3') and ('long_push') in value %}   
        {{'ON'}}
      {% elif ('input:3') and ('single_push') in value %}   
        {{'ON'}}
      {% elif ('input:3') and ('btn_up') in value %}   
        {{'OFF'}}
      {% else %}
        {{ states('binary_sensor.shelly_pro_4pm_input_4') }}
      {% endif %}

And is tested and working…

Is Power Reading working through the Shelly integration or do you need to use MQTT?

Power reading is working as is the Energy reading, however the Energy reading resets to zero on each reset of the Shelly. Sorry it took a while to reply, I haven’t actually installed this yet (just bench tests so far) and I wanted to test a high current appliance. My multimeter (which I find pretty accurate) is giving 1669W rather than the Shelly’s 1738W so I think it is over recording by about 4%, but will certainly do for my purposes.

This thread has been very helpful for setting up my shell 1 plus (2nd gen shelly 1) devices. The mqtt commands and status topics are the same as the ones for the Shelly Pro 4PM

My device is working om MQTT. Only issue is: when I switch the light on, the button moves after 2-3 seconds to off state automatic.
Any suggestions??

image

#############################################

Switch 2 = Button 3; Ingang voorzijde

#############################################

  • platform: mqtt
    name: “Pro4-button-3”
    unique_id: “shellypro4pm-84cca87f11dc-switch-2”
    command_topic: “shelly-4pro/rpc”
    payload_on: ‘{“id”: 1, “src”:“homeassistant”, “method”: “Switch.Set”, “params”: {“id”: 2, “on”: true}}’
    payload_off: ‘{“id”: 1, “src”:“homeassistant”, “method”: “Switch.Set”, “params”: {“id”: 2, “on”: false}}’
    state_topic: “shellypro4pm-84cca87f11dc/status/switch:2”
    value_template: “{{ value_json.output }}”
    state_on: true
    state_off: false
    qos: 1

#############################################

Switch 3 = Button 4; Zijkant huis

#############################################

  • platform: mqtt
    name: “Pro4-button-4”
    unique_id: “shellypro4pm-84cca87f11dc-switch-3”
    command_topic: “shelly-4pro/rpc”
    payload_on: ‘{“id”: 1, “src”:“homeassistant”, “method”: “Switch.Set”, “params”: {“id”: 3, “on”: true}}’
    payload_off: ‘{“id”: 1, “src”:“homeassistant”, “method”: “Switch.Set”, “params”: {“id”: 3, “on”: false}}’
    state_topic: “shellypro4pm-84cca87f11dc/status/switch:3”
    value_template: “{{ value_json.output }}”
    state_on: true
    state_off: false
    qos: 1

I am using this:

[
{
“id”: “6f50cf4298918b19”,
“type”: “mqtt in”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“topic”: “shellypro4pm-84cca87fb628/#”,
“qos”: “1”,
“datatype”: “json”,
“broker”: “ab51feb9.0ff75”,
“nl”: false,
“rap”: false,
“inputs”: 0,
“x”: 200,
“y”: 180,
“wires”: [
[
“30547f899c284c1f”,
“31da2c659e60fd79”,
“bad6c7601250d361”,
“30d9879f7341424d”
]
]
},
{
“id”: “b5398c54dca1df81”,
“type”: “function”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “4PM 0”,
“func”: “var Topic =“4PM 0”;\nmsg.topic =Topic;\nif ( msg.payload === “off”) {flow.set (“turn_trp” , “on” ) ; node.status({fill:“black”, shape:“ring”, text:Topic +” = “+msg.payload }) ;return msg}\nif ( msg.payload === “on” ) {flow.set (“turn_trp” , “off”) ; node.status({fill:“black”, shape:“ring”, text:Topic +” = “+msg.payload }) ;return msg}\nnode.status({fill:“black”, shape:“ring”, text:Topic +” = “+msg.payload }) ;\nreturn msg”,
“outputs”: 1,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 1470,
“y”: 620,
“wires”: [
[
“9522977e1b9fad78”,
“f9f6b38192767375”
]
]
},
{
“id”: “9522977e1b9fad78”,
“type”: “ui_text”,
“z”: “68c5e3c3eff4dfe1”,
“group”: “343e475464f16c37”,
“order”: 8,
“width”: 0,
“height”: 0,
“name”: “”,
“label”: “{{msg.topic}}”,
“format”: “{{msg.payload}}”,
“layout”: “row-left”,
“x”: 1890,
“y”: 700,
“wires”: []
},
{
“id”: “e40cf09db6d4ae40”,
“type”: “ui_button”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “RBE Button”,
“group”: “a57400f8988c6a8a”,
“order”: 8,
“width”: 1,
“height”: 1,
“passthru”: false,
“label”: “{{msg.txt}}”,
“tooltip”: “”,
“color”: “{{msg.fontclr}}”,
“bgcolor”: “{{msg.colour}}”,
“icon”: “”,
“payload”: “X”,
“payloadType”: “str”,
“topic”: “”,
“topicType”: “str”,
“x”: 2095,
“y”: 700,
“wires”: [
[
“6d3f5522f1595a8a”
]
],
“l”: false
},
{
“id”: “f9f6b38192767375”,
“type”: “function”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “toggle info”,
“func”: “var hulp = msg.payload;\nswitch (hulp) {\ncase “on” : \n msg.colour =“green”\n msg.txt = “uit”\n break;\n \ndefault :\n msg.colour =“grey”\n msg.txt = “aan”\n break;\n}\nnode.status({fill:“black”, shape:“ring”, text:msg.topic +” = “+msg.payload })\nmsg.payload = “status”\nreturn msg”,
“outputs”: 1,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 1850,
“y”: 620,
“wires”: [
[
“e40cf09db6d4ae40”
]
]
},
{
“id”: “cb8b3a212b345582”,
“type”: “function”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “Pro 0”,
“func”: “msg.topic = “Pro 0”;\nvar IP = “192.168.2.247”;\nmsg.url= “http://”+ IP + “/relay/0”;\nmsg.turn= msg.payload\nmsg.payload = “turn=” +msg.payload\nif (msg.turn === “on” ) { return [msg, null, null, null, null, null]} \nif (msg.turn === “off”) { return [msg, null, null, null, null, null]}\nmsg.turn = “status” ; msg.payload = “status” ; return [null,null, null, null, null, msg ]\n// “status opvragen status””,
“outputs”: 6,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 510,
“y”: 660,
“wires”: [
[
“2f480477432f1ac6”
],
[],
[],
[],
[],
[
“11d8b4804631239a”
]
]
},
{
“id”: “2f480477432f1ac6”,
“type”: “function”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “start loop”,
“func”: “\nif (msg.turn === msg.status_00 ) { msg.resend_ignore = true ; return [null , msg]; } \nif (msg.turn === “status” ) { msg.resend_ignore = true ; return [null , msg]; }\n// 1 = change status – 2 = staus correct \nreturn [msg, null]; \n”,
“outputs”: 2,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 720,
“y”: 640,
“wires”: [
[
“11d8b4804631239a”
],
[
“b8564b29f69770c7”
]
]
},
{
“id”: “11d8b4804631239a”,
“type”: “http request”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“method”: “POST”,
“ret”: “obj”,
“paytoqs”: “ignore”,
“url”: “”,
“tls”: “”,
“persist”: false,
“proxy”: “”,
“authType”: “”,
“senderr”: false,
“x”: 930,
“y”: 640,
“wires”: [
[
“2d79a1db3befd651”
]
]
},
{
“id”: “2d79a1db3befd651”,
“type”: “function”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “on/off ?”,
“func”: “if (msg.payload.ison === true ) {msg.status_00 = “on” ; return [msg, null]} \nif (msg.payload.ison === false) {msg.status_00 = “off”; return [msg, null]} \nreturn [null , msg]”,
“outputs”: 2,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 1100,
“y”: 620,
“wires”: [
[
“c4a522e1c862a2c7”,
“2f480477432f1ac6”
],
[]
]
},
{
“id”: “b8564b29f69770c7”,
“type”: “msg-resend”,
“z”: “68c5e3c3eff4dfe1”,
“interval”: “20”,
“intervalUnit”: “secs”,
“maximum”: “5”,
“bytopic”: false,
“clone”: false,
“firstDelayed”: false,
“addCounters”: false,
“waitForResend”: false,
“highRate”: true,
“outputCountField”: “”,
“outputMaxField”: “”,
“name”: "Repeat 1 min ",
“x”: 615,
“y”: 660,
“wires”: [
[
“2f480477432f1ac6”
]
],
“l”: false
},
{
“id”: “c4a522e1c862a2c7”,
“type”: “function”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “on/off info”,
“func”: “var Topic = msg.topic || “no topic”\nif ( msg.payload.ison === true ) { msg.payload = “on” ; msg.turn = “off” ;node.status({fill:“black”, shape:“ring”, text:Topic +” = “+msg.payload }) ; return msg}\nif ( msg.payload.ison === false ) { msg.payload = “off”; msg.turn = “on” ;node.status({fill:“black”, shape:“ring”, text:Topic +” = “+msg.payload }) ; return msg}\nnode.status({fill:“black”, shape:“ring”, text:Topic +” = “+msg.payload }) ;\nreturn msg”,
“outputs”: 1,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 1260,
“y”: 620,
“wires”: [
[
“b5398c54dca1df81”
]
]
},
{
“id”: “40ce49000450d0e0”,
“type”: “inject”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “toggle”,
“payloadType”: “str”,
“x”: 210,
“y”: 680,
“wires”: [
[
“cb8b3a212b345582”
]
]
},
{
“id”: “d7485edaa67394fd”,
“type”: “inject”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “status”,
“payloadType”: “str”,
“x”: 350,
“y”: 680,
“wires”: [
[
“cb8b3a212b345582”
]
]
},
{
“id”: “6d3f5522f1595a8a”,
“type”: “function”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “on/off info”,
“func”: “var Topic = msg.topic || “no topic”\nmsg.payload= flow.get (“turn_trp”) || “status” \nnode.status({fill:“black”, shape:“ring”, text:Topic +” = “+msg.payload })\nreturn msg”,
“outputs”: 1,
“noerr”: 0,
“initialize”: “”,
“finalize”: “”,
“libs”: [],
“x”: 300,
“y”: 720,
“wires”: [
[
“cb8b3a212b345582”
]
]
},
{
“id”: “59bec342e40abc42”,
“type”: “inject”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “on”,
“payloadType”: “str”,
“x”: 220,
“y”: 580,
“wires”: [
[
“cb8b3a212b345582”
]
]
},
{
“id”: “5bd1b0d81dee540e”,
“type”: “inject”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“props”: [
{
“p”: “payload”
},
{
“p”: “topic”,
“vt”: “str”
}
],
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“topic”: “”,
“payload”: “off”,
“payloadType”: “str”,
“x”: 210,
“y”: 540,
“wires”: [
[
“cb8b3a212b345582”
]
]
},
{
“id”: “30547f899c284c1f”,
“type”: “change”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“rules”: [
{
“t”: “move”,
“p”: “payload.params[“switch:0”].output”,
“pt”: “msg”,
“to”: “payload”,
“tot”: “msg”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 630,
“y”: 140,
“wires”: [
[
“cb290519ffa37dfc”
]
]
},
{
“id”: “7fc0f9535e9716c2”,
“type”: “debug”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“active”: false,
“tosidebar”: true,
“console”: true,
“tostatus”: true,
“complete”: “payload”,
“targetType”: “msg”,
“statusVal”: “payload”,
“statusType”: “auto”,
“x”: 1060,
“y”: 140,
“wires”: []
},
{
“id”: “cb290519ffa37dfc”,
“type”: “switch”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“property”: “payload”,
“propertyType”: “msg”,
“rules”: [
{
“t”: “true”
},
{
“t”: “false”
}
],
“checkall”: “true”,
“repair”: false,
“outputs”: 2,
“x”: 870,
“y”: 140,
“wires”: [
[
“7fc0f9535e9716c2”,
“183a2fd853a14791”
],
[
“7fc0f9535e9716c2”,
“183a2fd853a14791”
]
]
},
{
“id”: “31da2c659e60fd79”,
“type”: “change”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“rules”: [
{
“t”: “move”,
“p”: “payload.params[“switch:1”].output”,
“pt”: “msg”,
“to”: “payload”,
“tot”: “msg”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 630,
“y”: 220,
“wires”: [
[
“fa6908f9885cbc33”
]
]
},
{
“id”: “c4b43c0806a56d5f”,
“type”: “debug”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“active”: false,
“tosidebar”: true,
“console”: true,
“tostatus”: true,
“complete”: “payload”,
“targetType”: “msg”,
“statusVal”: “payload”,
“statusType”: “auto”,
“x”: 1060,
“y”: 220,
“wires”: []
},
{
“id”: “fa6908f9885cbc33”,
“type”: “switch”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“property”: “payload”,
“propertyType”: “msg”,
“rules”: [
{
“t”: “true”
},
{
“t”: “false”
}
],
“checkall”: “true”,
“repair”: false,
“outputs”: 2,
“x”: 890,
“y”: 220,
“wires”: [
[
“c4b43c0806a56d5f”,
“6b3732ba6f3abccf”
],
[
“c4b43c0806a56d5f”,
“6b3732ba6f3abccf”
]
]
},
{
“id”: “bad6c7601250d361”,
“type”: “change”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“rules”: [
{
“t”: “move”,
“p”: “payload.params[“switch:2”].output”,
“pt”: “msg”,
“to”: “payload”,
“tot”: “msg”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 630,
“y”: 280,
“wires”: [
[
“6550e0f4aa9ef0c3”
]
]
},
{
“id”: “895828ce03a0fda4”,
“type”: “debug”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“active”: false,
“tosidebar”: true,
“console”: true,
“tostatus”: true,
“complete”: “payload”,
“targetType”: “msg”,
“statusVal”: “payload”,
“statusType”: “auto”,
“x”: 1060,
“y”: 280,
“wires”: []
},
{
“id”: “6550e0f4aa9ef0c3”,
“type”: “switch”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“property”: “payload”,
“propertyType”: “msg”,
“rules”: [
{
“t”: “true”
},
{
“t”: “false”
}
],
“checkall”: “true”,
“repair”: false,
“outputs”: 2,
“x”: 890,
“y”: 280,
“wires”: [
[
“895828ce03a0fda4”,
“46e13fc273620be2”
],
[
“895828ce03a0fda4”,
“46e13fc273620be2”
]
]
},
{
“id”: “30d9879f7341424d”,
“type”: “change”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“rules”: [
{
“t”: “move”,
“p”: “payload.params[“switch:3”].output”,
“pt”: “msg”,
“to”: “payload”,
“tot”: “msg”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 630,
“y”: 340,
“wires”: [
[
“b5e7bb78abb07f21”
]
]
},
{
“id”: “3111905c7cbd462f”,
“type”: “debug”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“active”: false,
“tosidebar”: true,
“console”: true,
“tostatus”: true,
“complete”: “payload”,
“targetType”: “msg”,
“statusVal”: “payload”,
“statusType”: “auto”,
“x”: 1060,
“y”: 340,
“wires”: []
},
{
“id”: “b5e7bb78abb07f21”,
“type”: “switch”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“property”: “payload”,
“propertyType”: “msg”,
“rules”: [
{
“t”: “true”
},
{
“t”: “false”
}
],
“checkall”: “true”,
“repair”: false,
“outputs”: 2,
“x”: 890,
“y”: 340,
“wires”: [
[
“3111905c7cbd462f”,
“30c1ef382e0ff602”
],
[
“3111905c7cbd462f”,
“30c1ef382e0ff602”
]
]
},
{
“id”: “abd1dbd0ae79568a”,
“type”: “link out”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “Pro 3”,
“mode”: “link”,
“links”: [
“f5d53219162d81ce”
],
“x”: 1475,
“y”: 340,
“wires”: []
},
{
“id”: “02227c5d2a48142b”,
“type”: “link in”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “Pro 3”,
“links”: [
“4a49b2d1036f9157”
],
“x”: 1395,
“y”: 520,
“wires”: [
[
“b5398c54dca1df81”
]
]
},
{
“id”: “09b5d1a25b211547”,
“type”: “link out”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “Pro 2”,
“mode”: “link”,
“links”: [
“86e05215d09d0f09”,
“222891d94d909985”
],
“x”: 1475,
“y”: 280,
“wires”: []
},
{
“id”: “4a49b2d1036f9157”,
“type”: “link out”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “Pro 0”,
“mode”: “link”,
“links”: [
“cd33680e9a304df1”,
“02227c5d2a48142b”
],
“x”: 1475,
“y”: 140,
“wires”: []
},
{
“id”: “0d98570cf9f215df”,
“type”: “link out”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “Pro 1”,
“mode”: “link”,
“links”: [
“bc8b990492746c94”,
“1c969a86f7afab01”
],
“x”: 1475,
“y”: 220,
“wires”: []
},
{
“id”: “183a2fd853a14791”,
“type”: “change”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“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”: 1300,
“y”: 140,
“wires”: [
[
“4a49b2d1036f9157”
]
]
},
{
“id”: “6b3732ba6f3abccf”,
“type”: “change”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“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”: 1300,
“y”: 220,
“wires”: [
[
“0d98570cf9f215df”
]
]
},
{
“id”: “46e13fc273620be2”,
“type”: “change”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“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”: 1300,
“y”: 280,
“wires”: [
[
“09b5d1a25b211547”
]
]
},
{
“id”: “30c1ef382e0ff602”,
“type”: “change”,
“z”: “68c5e3c3eff4dfe1”,
“name”: “”,
“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”: 1300,
“y”: 340,
“wires”: [
[
“abd1dbd0ae79568a”
]
]
},
{
“id”: “ab51feb9.0ff75”,
“type”: “mqtt-broker”,
“name”: “MQTT”,
“broker”: “192.168.2.48”,
“port”: “1883”,
“clientid”: “”,
“autoConnect”: true,
“usetls”: false,
“compatmode”: false,
“protocolVersion”: “4”,
“keepalive”: “60”,
“cleansession”: true,
“birthTopic”: “”,
“birthQos”: “0”,
“birthPayload”: “”,
“birthMsg”: {},
“closeTopic”: “”,
“closeQos”: “0”,
“closePayload”: “”,
“closeMsg”: {},
“willTopic”: “”,
“willQos”: “0”,
“willPayload”: “”,
“willMsg”: {},
“sessionExpiry”: “”
},
{
“id”: “343e475464f16c37”,
“type”: “ui_group”,
“name”: “in1”,
“tab”: “bc3bf5abf44bdb1b”,
“order”: 1,
“disp”: false,
“width”: “3”,
“collapse”: false
},
{
“id”: “a57400f8988c6a8a”,
“type”: “ui_group”,
“name”: “kn1”,
“tab”: “bc3bf5abf44bdb1b”,
“order”: 2,
“disp”: false,
“width”: “1”,
“collapse”: false
},
{
“id”: “bc3bf5abf44bdb1b”,
“type”: “ui_tab”,
“name”: “schakelaar”,
“icon”: “fa-dot-circle-o”,
“order”: 1,
“disabled”: false,
“hidden”: false
}
]

Hey, thanks for all the info!

I read somewhere that you can configure Shellys with specific commands for quick input pulses (e.g. quick press on the button does x, 2 quick presses does something else).
Is this actually the case and if not directly with Shelly, is it possible in Home Assistant?

Thanks,

WIm

Hi, I’m using Shelly Pro 4PM via LAN and via MQTT…

But I have one problem and that is that input binary sensor are not defined until the state of input binary sensor is changed from 1 to 0 or from 0 to 1 after HA restart.
Does anybody know how to read input binary sensor? Discovery script do not solve my problem.
But switches (output) are updated after HA restart, only binary sensors (input) are not.

My binary input sensors:
binary_sensor.shelly_shellypro4pm_1_switch
binary_sensor.shelly_shellypro4pm_2_switch
binary_sensor.shelly_shellypro4pm_3_switch
binary_sensor.shelly_shellypro4pm_4_switch

My switches:
switch.shelly_pro_4pm_relay_1
switch.shelly_pro_4pm_relay_2
switch.shelly_pro_4pm_relay_3
switch.shelly_pro_4pm_relay_4

switch:
  - platform: mqtt
    name: "Shelly Pro 4PM Relay 1"
    unique_id: "shellypro4pm-kabinet-sw1"
    command_topic: "shellypro4pm-kabinet/rpc"
    payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 0, "on": true}}'
    payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 0, "on": false}}'
    state_topic: "shellypro4pm-kabinet/status/switch:0"
    value_template: "{{ value_json.output }}"
    state_on: true
    state_off: false
    qos: 1
  - platform: mqtt
    name: "Shelly Pro 4PM Relay 2"
    unique_id: "shellypro4pm-kabinet-sw2"
    command_topic: "shellypro4pm-kabinet/rpc"
    payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 1, "on": true}}'
    payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 1, "on": false}}'
    state_topic: "shellypro4pm-kabinet/status/switch:1"
    value_template: "{{ value_json.output }}"
    state_on: true
    state_off: false
    qos: 1
  - platform: mqtt
    name: "Shelly Pro 4PM Relay 3"
    unique_id: "shellypro4pm-kabinet-sw3"
    command_topic: "shellypro4pm-kabinet/rpc"
    payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 2, "on": true}}'
    payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 2, "on": false}}'
    state_topic: "shellypro4pm-kabinet/status/switch:2"
    value_template: "{{ value_json.output }}"
    state_on: true
    state_off: false
    qos: 1
  - platform: mqtt
    name: "Shelly Pro 4PM Relay 4"
    unique_id: "shellypro4pm-kabinet-sw4"
    command_topic: "shellypro4pm-kabinet/rpc"
    payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 3, "on": true}}'
    payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 3, "on": false}}'
    state_topic: "shellypro4pm-kabinet/status/switch:3"
    value_template: "{{ value_json.output }}"
    state_on: true
    state_off: false
    qos: 1

For binary sensor I did not needed anything as it was detected by integration…

Any help would be appreciated.

And my automation on Home Assistant startup:

# Shellies Announce
- id: '010'
  alias: Shellies Announce
  trigger:
    - platform: homeassistant
      event: start
    - platform: time_pattern
      hours: "/12"  # Modifying this if you are using Shelly Motion can drain your device's battery quickly.
  action:
    service: mqtt.publish
    data:
      topic: shellies/command
      payload: announce
  mode: single

# Shellies Discovery
- id: '011'
  alias: Shellies Discovery
  max: 999
  trigger:
    platform: mqtt
    topic: shellies/announce
  action:
    service: python_script.shellies_discovery
    data:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'
      model: '{{ trigger.payload_json.model }}'
      mode: '{{ trigger.payload_json.mode | default }}'
      host: '{{ trigger.payload_json.ip }}'
  mode: queued

- id: '014'
  alias: Shellies Announce Gen2
  trigger:
    - platform: homeassistant
      event: start
  variables:
    device_info_payload:  "{{ {'id': 1, 'src':'shellies_discovery', 'method':'Shelly.GetConfig'} | to_json }}"
  action:
    - service: mqtt.publish
      data:
        topic: "shellypro4pm-kabinet/rpc"  # shellypro4pm-aabbccddeeff is a device ID
        payload: "{{ device_info_payload }}"

- id: '015'
  alias: "Shellies Discovery Gen2"
  mode: queued
  max: 999
  trigger:
  - platform: mqtt
    topic: shellies_discovery/rpc
  action:
  - service: python_script.shellies_discovery_gen2
    data:
      id: "{{ trigger.payload_json.src }}"
      device_config: "{{ trigger.payload_json.result }}"

- id: '016'
  alias: "Shellies Status Gen2"
  trigger:
  - platform: time_pattern
    minutes: "/15"
  - platform: homeassistant
    event: start
  action:
  - service: mqtt.publish
    data:
      topic: shellypro4pm-kabinet/rpc
      payload: "{{ {'id': 1, 'src':'shellypro4pm-kabinet/status', 'method':'Shelly.GetStatus'} | to_json }}"  # shellypro4pm-aabbccddeeff is a device ID

Have you tried looking at mqtt messages with some client like mosquitto-sub?

I tried to look with MQTT-Explorer… but if I’m honest don’t know what I’m doing :smiley:

I can paste what I get…