HI all
I’m trying to get my shelly plug s to work via mqtt, I get it so far that the device publish data to mqtt broker but I fail on getting it into openhab. I prefer mqtt so I don’t have to set static IP:s to all devices, and i allready have a shelly 1 pro running via mqtt.
Heres is my thing configuration for generic mqtt thing.
UID: mqtt:topic:bc3e71556e:50fe53dd5a
label: Martinskänk
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:bc3e71556e
channels:
- id: Relay0
channelTypeUID: mqtt:switch
label: Relay0
description: null
configuration:
formatBeforePublish: '{"src":"MQTT0","method":"Switch.Set", "params":{"id":0,"on":%s}}'
commandTopic: shellies/shellyplug-s-livigroom_south/relay/0/command,on="on",off="off"
stateTopic: shellies/shellyplug-s-livigroom_south/relay/0, on="on",off="off"
Cplant
(Cplant)
December 20, 2022, 8:22am
#2
What’s the problem you’re facing?
rossko57
(Rossko57)
December 20, 2022, 10:08am
#3
That doesn’t look like a sensible MQTT topic.
Have a look at some other examples.
Maybe more like just
shellies/shellyplug-s-livigroom_south/relay/0
although there is typo in livig/living perhaps
Cplant
(Cplant)
December 20, 2022, 11:13am
#4
@Marcus_Carlsson I hooked up a couple of Nous A1’s (running Tasmota) to OH by looking up what MQTT strings arrive at OH and then built the generic MQTT thing-configuration around this. Am not a pro, but after some iteration it worked.
Maybe what I came up with helps you for your exercise.
UID: mqtt:topic:7519737e0f:schaltstecker_tv
label: Schaltstecker TV
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:7519737e0f
location: Wohnzimmer
channels:
- id: reachable
channelTypeUID: mqtt:string
label: Reachable
description: null
configuration:
postCommand: false
retained: false
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/LWT
- id: power
channelTypeUID: mqtt:switch
label: Power
description: null
configuration:
commandTopic: cmnd/schaltstecker_tv/POWER
postCommand: false
retained: false
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/STATE
transformationPattern: JSONPATH:$.POWER
- id: powerload
channelTypeUID: mqtt:number
label: Power load
description: null
configuration:
postCommand: false
retained: false
step: 1
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/SENSOR
transformationPattern: JSONPATH:$.ENERGY.Power
- id: voltage
channelTypeUID: mqtt:number
label: Line voltage
description: null
configuration:
postCommand: false
retained: false
step: 1
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/SENSOR
transformationPattern: JSONPATH:$.ENERGY.Voltage
- id: current
channelTypeUID: mqtt:number
label: Line current
description: null
configuration:
postCommand: false
retained: false
step: 1
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/SENSOR
transformationPattern: JSONPATH:$.ENERGY.Current
- id: totaltoday
channelTypeUID: mqtt:number
label: Total energy today
description: null
configuration:
postCommand: false
retained: false
step: 1
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/SENSOR
transformationPattern: JSONPATH:$.ENERGY.Today
- id: totalyest
channelTypeUID: mqtt:number
label: Total energy yesterday
description: null
configuration:
postCommand: false
retained: false
step: 1
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/SENSOR
transformationPattern: JSONPATH:$.ENERGY.Yesterday
- id: total
channelTypeUID: mqtt:number
label: Total energy
description: null
configuration:
postCommand: false
retained: false
step: 1
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/SENSOR
transformationPattern: JSONPATH:$.ENERGY.Total
- id: rssi
channelTypeUID: mqtt:number
label: WiFi Signal Strength
description: null
configuration:
postCommand: false
retained: false
step: 1
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/STATE
transformationPattern: JSONPATH:$.Wifi.RSSI
- id: totalstart
channelTypeUID: mqtt:string
label: Total since
description: null
configuration:
postCommand: false
retained: false
formatBeforePublish: "%s"
stateTopic: tele/schaltstecker_tv/SENSOR
transformationPattern: JSONPATH:$.ENERGY.TotalStartTime
rfuh
(RFUH)
December 20, 2022, 1:34pm
#5
why do you need this “formatBeforePublish” part?
Also, on and off should be defined in separate lines of the configuration, like
configuration:
commandTopic: shellies/shellyplug-s-livigroom_south/relay/0/command
stateTopic: shellies/shellyplug-s-livigroom_south/relay/0
off: off
on: on
rfu
Thanks for all hints I did just have a working example of a shell pro 1 module and tried to reverse that and that didn’t go well. No it seem like it works as supposed to. I just need to figure out how to make channles for energy and power, maybe also temperature.
Also the typoo was already made in configuration of shelly topic so in openhab it was correct.
And if somone stumbles across this i post my updated config, I used gui to create new channels because mu code wouldn’t get saved when typing into code page of generic mqtt thing.
UID: mqtt:topic:bc3e71556e:50fe53dd5a
label: Martinskänk
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:bc3e71556e
channels:
- id: Relay0
channelTypeUID: mqtt:switch
label: Relay0
description: null
configuration:
commandTopic: shellies/shellyplug-s-livigroom_south/relay/0/command
stateTopic: shellies/shellyplug-s-livigroom_south/relay/0
off: off
on: on
- id: PowerConsumption
channelTypeUID: mqtt:number
label: Powerconsumption
description: ""
configuration:
stateTopic: shellies/shellyplug-s-livigroom_south/relay/0/power
min: 0
- id: Energyconsumption
channelTypeUID: mqtt:number
label: Energyconsumption
description: ""
configuration:
stateTopic: shellies/shellyplug-s-livigroom_south/relay/0/energy
min: 0