FYI: Shelly 2PM Gen3 - MQTT Config

Example Shelly 2PM Gen3 - MQTT Config

UID: mqtt:topic:111111111111:tg_mqtt_shelly2pmg3-000000000000
label: tg_mqtt_shelly2pmg3-000000000000
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: "false"
  availabilityTopic: shellies/shelly2pmg3-000000000000/online
  payloadAvailable: "true"
bridgeUID: mqtt:broker:000000000000
channels:
  - id: switch0
    channelTypeUID: mqtt:switch
    label: switch0
    description: ""
    configuration:
      commandTopic: shellies/shelly2pmg3-000000000000/command/switch:0
      stateTopic: shellies/shelly2pmg3-000000000000/status/switch:0
      transformationPattern: JS:| JSON.parse(input).output==true?'on':'off'
      off: off
      on: on
  - id: switch1
    channelTypeUID: mqtt:switch
    label: switch1
    configuration:
      commandTopic: shellies/shelly2pmg3-000000000000/command/switch:1
      stateTopic: shellies/shelly2pmg3-000000000000/status/switch:1
      transformationPattern: JS:| JSON.parse(input).output==true?'on':'off'
      off: off
      on: on
  - id: switch0power
    channelTypeUID: mqtt:number
    label: switch0power
    description: ""
    configuration:
      stateTopic: shellies/shelly2pmg3-000000000000/status/switch:0
      transformationPattern: JSONPATH:$.apower
  - id: switch1power
    channelTypeUID: mqtt:number
    label: switch1power
    configuration:
      stateTopic: shellies/shelly2pmg3-000000000000/status/switch:1
      transformationPattern: JSONPATH:$.apower
  - id: switch0voltage
    channelTypeUID: mqtt:number
    label: switch0voltage
    configuration:
      stateTopic: shellies/shelly2pmg3-000000000000/status/switch:0
      transformationPattern: JSONPATH:$.voltage
  - id: switch1voltage
    channelTypeUID: mqtt:number
    label: switch1voltage
    configuration:
      stateTopic: shellies/shelly2pmg3-000000000000/status/switch:1
      transformationPattern: JSONPATH:$.voltage
  - id: switch0current
    channelTypeUID: mqtt:number
    label: switch0current
    configuration:
      stateTopic: shellies/shelly2pmg3-000000000000/status/switch:0
      transformationPattern: JSONPATH:$.current
  - id: switch1current
    channelTypeUID: mqtt:number
    label: switch1current
    configuration:
      stateTopic: shellies/shelly2pmg3-000000000000/status/switch:1
      transformationPattern: JSONPATH:$.current

Shelly PlusPlugUK MQTT Config example

UID: mqtt:topic: xxxxxxxxxxxx:0a34a78255
label: tg_mqtt_shelly_shellypluspluguk-xxxxxxxxxxxx
thingTypeUID: mqtt:topic
configuration:
  availabilityTopic: shellies/shellypluspluguk-xxxxxxxxxxxx/online
  payloadAvailable: "true"
bridgeUID: mqtt:broker: xxxxxxxxxxxx
channels:
  - id: switch0
    channelTypeUID: mqtt:switch
    label: switch
    description: ""
    configuration:
      commandTopic: shellies/shellypluspluguk-xxxxxxxxxxxx/command/switch:0
      stateTopic: shellies/shellypluspluguk-xxxxxxxxxxxx/events/rpc
      transformationPattern:
        - "JS:| JSON.parse(input).params[\"switch:0\"].output === true ? 'on' :
          JSON.parse(input).params[\"switch:0\"].output === false ? 'off' :
          undefined"
      off: off
      on: on
  - id: power
    channelTypeUID: mqtt:number
    label: power
    description: ""
    configuration:
      stateTopic: shellies/shellypluspluguk-xxxxxxxxxxxx/events/rpc
      transformationPattern:
        - JSONPATH:$.params.switch:0.apower
      min: 0

I also use Generic MQTT Thing instead of shelly binding and for transformation I use JSONPATH for state and MAP for output command. I add it here as another conf alternative.

  - id: relay
    channelTypeUID: mqtt:switch
    label: Relay
    configuration:
      commandTopic: shelly-base-topic/command/switch:0
      transformationPatternOut:
        - MAP:boolean2onoff.map
      stateTopic: shelly-base-topic/status/switch:0
      transformationPattern:
        - JSONPATH:$.output
      off: "false"
      on: "true"

and /etc/openhab/transform/boolean2onoff.map :

true=on
on=true
false=off
off=false

1 Like

Hi,

is there an example for rollershutter usage with the old text-files syntax (things / items) available?
It seems to be very different compared to Shelly 2.5 …