Openhab Shelly Pro 4PM MQTT

Hi,

i tried to get mqtt also working. Switching Channels works fine, but Openhab doesn’t recognise the status yet. So when i switch in shelly cloud, openhab doesn’t get the new state.

Here is my mqtt client code:

UID: mqtt:topic:76310a1e3f:b38bdd3f41
label: Bewaesserung
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:76310a1e3f
channels:
  - id: BewasserungCourt1
    channelTypeUID: mqtt:switch
    label: BewasserungCourt1
    description: ""
    configuration:
      retained: true
      qos: 2
      formatBeforePublish: '{"id":123,"src":"chan1","method":"Switch.Set",
        "params":{"id":0,"on":%s}}'
      commandTopic: shellypro4pm-083af2bf3250/rpc
      stateTopic: shellypro4pm-083af2bf3250/events/rpc
      transformationPattern: REGEX:(.switch:0.)∩JSONPATH:$.params.switch:0.output
      off: "false"
      on: "true"
  - id: BewasserungCourt2
    channelTypeUID: mqtt:switch
    label: BewasserungCourt2
    description: ""
    configuration:
      retained: true
      qos: 2
      formatBeforePublish: '{"id":2,"src":"light","method":"Switch.Set", "params":{"id":1,"on":%s}}'
      commandTopic: shellypro4pm-083af2bf3250/rpc
      stateTopic: shellypro4pm-083af2bf3250/events/rpc
      transformationPattern: REGEX:(.switch:1.)∩JSONPATH:$.params.switch:1.output
      off: "false"
      on: "true"

michael, you made my day…uhhh, how complicate this shelly staff with mqtt, since pro versions…? i’m woundering how to find out the right code and syntax. can you explain, how you found the right path? would be helpfuel to me for future issues…thanks!
andy

I used iOS app MQTT analyzer for this

Hi there,

did anybody already configure the inputs to be read out if configured to detached on shelly channel input/output configuration?

I’ve tried the following which does not seem to work:

  • id: Wohn_Input
    channelTypeUID: mqtt:switch
    label: Wohnzimmer_Input
    description: null
    configuration:
    stateTopic: shellies/shellypro4pm-30C6F783568C/status/input:0
    transformationPattern: JSONPATH:$.state

I’ve just checked again and realised that the other state read outs, like posted as a sample earlier in this this threat do not work either, such as voltage for example. Did anybody test anything else then the switches?

Solved it, sorry. Forgot to install the JSON Transform add on

Hi @htttito .
Just came accros your post.
Are you getting status updates on your channel if the switch gets initiated by any other source than openHAB (e.g. Shelly WebGUI or touchscreen on the device)?

Your stateTopics looks off to me, should rather be something like this to work properly - correct? :

stateTopic: shellypro4pm-84cca87d86bc/events/rpc
transformationPattern: REGEX:(.*\"switch:0\".*\"output\".*)∩JSONPATH:$.params.switch:0.output

I’m using a thing file:

Type switch: relay1   "Relais"   [stateTopic="shellypro4pm-c8f09e87eec8/events/rpc", transformationPattern="REGEX:(.*\"switch:0\".*\"output\".*)∩JSONPATH:$.params.switch:0.output", 
                                  commandTopic="shellypro4pm-c8f09e87eec8/rpc", formatBeforePublish="{\"id\":0, \"src\":\"openHAB\", \"method\":\"Switch.Set\", \"params\":{\"id\":0,\"on\":%s}}", on="true", off="false"]