Shelly1 and mqtt 2.4.0 Binding

mqtt
mqtt-binding
shelly
Tags: #<Tag:0x00007f51e4780770> #<Tag:0x00007f51e4780540> #<Tag:0x00007f51e47803d8>

(Pekka) #1

Just a quick reference: Using the original firmware, you can control your shelly 1 switch with the new mqtt 2.4.0 binding as follows:

Create a mqtt broker, providing your broker’s data, and create a MQTT Thing. In the MQTT Thing configuration, create a new channel with the followin Data:

  • Channel type: On/Off switch
  • Channel ID, Label: As you like
  • Channel configuration:
    • MQTT state topic: shellies/shelly1-123ABC/relay/0
    • MQTT command topic: shellies/shelly1-123ABC/relay/0/command
  • Show More:
    • On/Open value: on
    • Off/Closed value: off

(replacing shelly1-123ABC by your shelly’s ID)


You can then use the channel to link to a Switch item to control your shelly.


[SOLVED] MQTT Broker correct initialization
Shelly Bulb via MQTT 2.4
(Elenio) #2

Sorry, this string in the THING file cause Bridge not start (not visible in Paper UI)
[ stateTopic=“shellies/shelly1-4FFC66/online/0”, commandTopic=“shellies/shelly1-4FFC66/online/0/command”, on=“on” off=“off”]

Instead this is fully operational and Paper UI show both Bridge and thing channel configuration
[ stateTopic=“shellies/shelly1-4FFC66/relay/0”, commandTopic=“shellies/shelly1-4FFC66/relay/0/command”]

So it seems I’m wrong with the aliases configuration at the and (on and off)…
Preceeding lines in thing file for Bridge configuration is
Bridge mqtt:broker:brignoudBroker [ host=“192.168.xx.xx”, secure=false, username=“openhabian”, password=“xxxx” ]
{
Thing topic shellies {
Channels:
Type switch : shelly1-4FFC66 “Kitchen Lamp”


(Pekka) #3

There is no /online/ in my example…


(Kevin) #4

Hi,

Below is the things config that works for me, I only use cli no paper ui, if this helps.

Bridge  mqtt:broker:mosquitto "Mosquitto" [ host="0.0.0.0", secure=false, username="openhab", password="Xxxxxxx", clientID="openHAB2"  ]
{
        Thing topic StudyShelly1 "Shelly1" @ "Study" {
                Channels:
                Type switch : power "Power" [ stateTopic="shellies/shelly1-056DD7/relay/0", on="on", off="off", commandTopic="shellies/shelly1-056DD7/relay/0/command", on="on", off="off" ] 
        }
}

And my single item

Switch MQTT_Test2 "Study Shelly1" <switch>  (SF_Study) [ "Lighting" ] { channel="mqtt:topic:mosquitto:StudyShelly1:power" }

Done from my phone so hopefully copied ok.

K


Shelly 1 setup with embedded MQTT broker
(Elenio) #5

Replicated your config step by step except the shelly ID and some minor
I got nothing but the broker and the thing available and still didn.’ see the value passing throught MQTTfx
I defined a Switch in sitemap that seems to do nothing alterning the state

In my Shelly panel configuration I got this
Does it misleading with the OpenHab configuration files we shared ?
image

I regulary see value in transit when I operate from the phisical button or virtual Shelly app so MQTT is fully working I assume


(Kevin) #6

Hi,

Just checked mine from the phone and it shows the same message in the “Will Topic”, but that doesn’t change regardless of if I turn the Shelly off via the Shelly web app or OH switch.

Have you tried enabling full logging on mosquito and watch the messages for state changes?

Do you use habmin and if so does the broker and Shelly switch show as available under configuration/ things?

K


(Elenio) #7

Just checked the last (?) thing, I just wanted to try adding the port to the Bridge configuration
It’s works now as expected!

By the way, port number is the standard (1883) but it seems configuration need it anyway
Don’t know if is normal behaviour or if it has dignity to pay attention to it by the OH mantainers
Thank you all for supporting, you made me understand a lot with MQTT


(Elenio) #8

can you explain me what this syntax means the “@”?


(Kevin) #9

Hi,
Like a lot of people here I’ve been using other people’s examples to get my own working with the new mqtt 2.4, the link below is where I started with some of this.

But if I made an educated guess the first “Shelly 1” is just a nice name for the topic, so in Habmin is see Shelly 1 under things instead of StudyShelly1, @ “Study” is just a nice location name but not sure if it has any other use.
The docs don’t really mention the use from what I’ve seen.

K


(Hakan Tandogan) #10

The word after the “@” ist the “Location” in the “Control” Tab in the Paper UI. I’m not aware of any other place that this information is used.


(Oliver Albold) #11

Did anybody create a channel for the shelly1 input?
Topic: shellies/shelly1-XXXXXXXX/input/0

How should this look like. It reports 0 and 1 depending on the state.


(Stefan Haupt) #12

works out of the box without mapping 0 or 1 to OFF or ON with these settings:

things:
Type string : extSwitch "External Switch" [ stateTopic="shellies/shelly1-55521D/input/0" ]

items:
String Shelly1_01_extSwitch "Shelly1-01 Ext Switch" { channel="mqtt:topic:mosquitto:Shelly1-01:extSwitch" }


(Stefan Haupt) #13

any idea how I can use the JSON transform to display the out of the box firmware of a specific shelly switch? For example this is what I see via MQTT:

shellies/announce {“id”:“shelly1-55521D”,“mac”:“B6E62D55521D”,“ip”:“192.168.2.32”,“new_fw”:false, “fw_ver”:“20190122-162034/v1.4.5@5cbc6229”}
shellies/announce {“id”:“shellyswitch-5A4CE4”,“mac”:“B6E62D5A4CE4”,“ip”:“192.168.2.31”,“new_fw”:false, “fw_ver”:“20190122-162045/v1.4.5@5cbc6229”}

as you can see, they both use the same topic. thus I need to check fw_ver value only if id = %desired device%

Or any idea how to use this regex?