Issues controlling a sonoff tasmota device

Hi there,

I have issues getting a sonoff tasmota pow to run with openhab.

Here is what I already tried / assured:

  • installation is openhab 2 on a synology
  • mqtt broker is configured in paper ui and showing as “online”, user/password data is entered according the configuration from mosquitto
  • mosquitto is running on the same synology dsm
  • the sonoff device is equipped with its own topic, mqtt server is configured
  • controlling the sonoff is working when using ssh by

./mosquitto_pub -u sonoff -P my_password -h 192.168.178.9 -t cmnd/sonoff_pow1/POWER -m “off”

  • also receiving status and publishing via MQTT.fx software is working

This is how my item looks, that I created:

Switch Sonoff_Switch_1 {mqtt=">[homie:cmnd/sonoff_pow1/POWER:command:ON:1],>[homie:cmnd/sonoff_pow1/POWER:command:OFF:0],>[homie:cmnd/sonoff_pow1/STATUS:command:*:8],<[homie:stat/sonoff_pow1/POWER:state:default]"}

Instead of “homie” I also tried with localhost.
localhost is the mqtt adress, “homie” is the mqtt broker name, I have choosen within openhab.
the device topic is “sonoff_pow1”

Now, my switch does lead to no reaction at all. I don’t receive useful logs, just that I pushed the swith on the sitemap.

Anything I might have forgotten?
Is the snytax wrong?

Thanks and appreciate your feedback!
Christian

Good morning,
You have obviously installed the version 2 binding of mqtt ( otherwise you wouldn’t have a broker thing online). However you are using the version 1 syntax for the items.
You need to create Generic MQTT Things, select your broker thing as the bridge an create channels. All is written in the documentation, see Here

Thanks Jürgen!

I got it working now.
Was easier for me, to switch to the MQTT 1.x binding as for now.

Switching the sonoff and reading Voltage and Power is working.

Great support, thanks,
Christian

Sounds “old-fashioned” :rofl:

A thing definition is pretty straightforward once you’ve done it a few times.

Here’s part of my Sonoff Tasmota setup for the 2.4 MQTT binding:

// MQTT
Bridge mqtt:broker:mosquitto "Mosquitto" [ host="localhost", port=1883, secure=false, username="", password="", clientID="openHab2" ] {
// Switches
    Thing topic sonoff_s26_0 "Sonoff S26-0" @ "Loungeroom" {
    Channels:
        Type switch : power     "Power"                 [stateTopic="sonoff/s26_0/stat/POWER", commandTopic="sonoff/s26_0/cmnd/POWER"]
        Type number : rssi      "WiFi Signal Strength"  [stateTopic="sonoff/s26_0/tele/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : reachable "Reachable"             [stateTopic="sonoff/s26_0/tele/LWT"]
    }
    Thing topic sonoff_s26_1 "Sonoff S26-1" @ "Bedroom" {
    Channels:
        Type switch : power     "Power"                 [stateTopic="sonoff/s26_1/stat/POWER", commandTopic="sonoff/s26_1/cmnd/POWER"]
        Type number : rssi      "WiFi Signal Strength"  [stateTopic="sonoff/s26_1/tele/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : reachable "Reachable"             [stateTopic="sonoff/s26_1/tele/LWT"]
    }
    Thing topic sonoff_s26_2 "Sonoff S26-2" @ "Unused" {
    Channels:
        Type switch : power     "Power"                 [stateTopic="sonoff/s26_2/stat/POWER", commandTopic="sonoff/s26_2/cmnd/POWER"]
        Type number : rssi      "WiFi Signal Strength"  [stateTopic="sonoff/s26_2/tele/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : reachable "Reachable"             [stateTopic="sonoff/s26_2/tele/LWT"]
    }
// more S26's then some POWs:
    Thing topic sonoff_pow2_0 "Sonoff POW2-0" @ "Bedroom" {
    Channels:
        Type switch : power     "Power"                 [stateTopic="sonoff/pow2_0/stat/POWER",  commandTopic="sonoff/pow2_0/cmnd/POWER"]
        Type number : rssi      "WiFi Signal Strength"  [stateTopic="sonoff/pow2_0/tele/STATE",  transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : reachable "Reachable"             [stateTopic="sonoff/pow2_0/tele/LWT"]
        Type number : voltage   "Line Voltage"          [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]
        Type number : powerload "Power Load"            [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : app_power "Apparent Power"        [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.ApparentPower"]
        Type number : current   "Line Current"          [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current"]
        Type number : vcc       "VCC"                   [stateTopic="sonoff/pow2_0/tele/STATE",  transformationPattern="JSONPATH:$.Vcc"]
        Type number : today     "Energy Used Today"     [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today"]
        Type number : yesterday "Energy Used Yesterday" [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday"]
        Type number : total     "Total Energy Used"     [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]
        Type string : uptime    "Uptime"                [stateTopic="sonoff/pow2_0/tele/STATE",  transformationPattern="JSONPATH:$.Uptime"]
        Type number : react_pwr "Reactive Power"        [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.ReactivePower"]
        Type number : period    "Energy Period"         [stateTopic="sonoff/pow2_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Period"]
    }
    Thing topic sonoff_pow_0 "Sonoff POW-0" @ "Bedroom" {
    Channels:
        Type switch : power     "Power"                 [stateTopic="sonoff/pow_0/stat/POWER", commandTopic="sonoff/pow_0/cmnd/POWER"]
        Type number : rssi      "WiFi Signal Strength"  [stateTopic="sonoff/pow_0/tele/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : reachable "Reachable"             [stateTopic="sonoff/pow_0/tele/LWT"]
        Type number : voltage   "Line Voltage"          [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]
        Type number : powerload "Power Load"            [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : app_power "Apparent Power"        [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.ApparentPower"]
        Type number : current   "Line Current"          [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current"]
        Type number : vcc       "VCC"                   [stateTopic="sonoff/pow_0/tele/STATE",  transformationPattern="JSONPATH:$.Vcc"]
        Type number : today     "Energy Used Today"     [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today"]
        Type number : yesterday "Energy Used Yesterday" [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday"]
        Type number : total     "Total Energy Used"     [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]
        Type string : uptime    "Uptime"                [stateTopic="sonoff/pow_0/tele/STATE",  transformationPattern="JSONPATH:$.Uptime"]
        Type number : react_pwr "Reactive Power"        [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.ReactivePower"]
        Type number : period    "Energy Period"         [stateTopic="sonoff/pow_0/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Period"]
    }
}
// More POW's but you should get the idea.

Item defs:

// Switches
Switch sonoff_s26_0             "Fuji Colour Laser [%s]"                                <laser_printer_32>      (Lounge,Switches)       ["Switchable"]  {channel="mqtt:topic:mosquitto:sonoff_s26_0:power"}
Number sonoff_s26_0_RSSI        "Fuji Colour Laser WiFi Signal [JS(sonoffRSSI.js):%s]"  <signal>                (Lounge,wSwitches)      ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_s26_0:rssi"}
String sonoff_s26_0_Reachable   "Fuji Colour Laser Online Status [%s]"                  <network>               (Lounge,wSwitches)      ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_s26_0:reachable"}

Switch sonoff_s26_1             "Bedside Plug [%s]"                                     <socket2>               (Bedroom,Switches)      ["Switchable"]  {channel="mqtt:topic:mosquitto:sonoff_s26_1:power"}
Number sonoff_s26_1_RSSI        "Bedside Plug WiFi Signal [JS(sonoffRSSI.js):%s]"       <signal>                (Bedroom,wSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_s26_1:rssi"}
String sonoff_s26_1_Reachable   "Bedside Plug Online Status [%s]"                       <network>               (Bedroom,wSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_s26_1:reachable"}

Switch sonoff_s26_2             "Google Home Mini Switch [%s]"                          <poweroutlet_au>        (Bedroom,Switches)      ["Switchable"]  {channel="mqtt:topic:mosquitto:sonoff_s26_2:power"}
Number sonoff_s26_2_RSSI        "Google Home Mini WiFi Signal [JS(sonoffRSSI.js):%s]"   <signal>                (Bedroom,wSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_s26_2:rssi"}
String sonoff_s26_2_Reachable   "Google Home Mini Online Status [%s]"                   <network>               (Bedroom,wSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_s26_2:reachable"}

Switch sonoff_s26_3             "Echo Dot 3rd Gen Switch [%s]"                          <poweroutlet_au>        (Home,Switches)         ["Switchable"]  {channel="mqtt:topic:mosquitto:sonoff_s26_3:power"}
Number sonoff_s26_3_RSSI        "Echo Dot 3rd Gen - WiFi Signal [JS(sonoffRSSI.js):%s]" <signal>                (Home,wSwitches)        ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_s26_3:rssi"}
String sonoff_s26_3_Reachable   "Echo Dot 3rd Gen - Online Status [%s]"                 <network>               (Home,wSwitches)        ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_s26_3:reachable"}
// ....... more stuff

Switch sonoff_pow2_0                    "3D Printer [%s]"                               <3dprinter_32>          (Bedroom,Switches)      ["Switchable"]  {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:power"}
Number sonoff_pow2_0_RSSI               "3D Printer WiFi Signal [JS(sonoffRSSI.js):%s]" <signal>                (Bedroom,wSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:rssi"}
String sonoff_pow2_0_Reachable          "3D Printer Online Status [%s]"                 <network>               (Bedroom,wSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:reachable"}
Number sonoff_pow2_0_Voltage            "3D Printer Line Voltage [%.1f V]"              <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:voltage"}
Number sonoff_pow2_0_Load               "3D Printer Powerload [%.1f W]"                 <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:powerload"}
Number sonoff_pow2_0_AppPower           "3D Printer Apperent Power [%.1f W]"            <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:app_power"}
Number sonoff_pow2_0_Current            "3D Printer Line Current [%.3f A]"              <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:current"}
Number sonoff_pow2_0_VCC                "3D Printer VCC [%.3f VDC]"                     <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:vcc"}
Number sonoff_pow2_0_Today              "3D Printer Energy Today [%.3f kWh]"            <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:today"}
Number sonoff_pow2_0_Yesterday          "3D Printer Energy Yesterday [%.3f kWh]"        <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:yesterday"}
Number sonoff_pow2_0_Total              "3D Printer Total Energy Used [%.3f kWh]"       <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:total"}
String sonoff_pow2_0_Uptime             "3D Printer Uptime [JS(sonoffUp.js):%s]"        <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:uptime"}
Number sonoff_pow2_0_Period             "3D Printer Energy Period [%d Day(s)]"          <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:period"}
Number sonoff_pow2_0_ReactPower         "3D Printer Reactive Power [%.1f W]"            <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow2_0:react_pwr"}

Switch sonoff_pow_0                     "UPS [%s]"                                      <ups_2_32>              (Bedroom,Switches)      ["Switchable"]  {channel="m
qtt:topic:mosquitto:sonoff_pow_0:power"}
Number sonoff_pow_0_RSSI                "UPS WiFi Signal [JS(sonoffRSSI.js):%s]"        <signal>                (Bedroom,wSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow_0:rssi"}
String sonoff_pow_0_Reachable           "UPS Online Status [%s]"                        <network>               (Bedroom,wSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow_0:reachable"}
Number sonoff_pow_0_Voltage             "UPS Line Voltage [%.1f V]"                     <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="m
qtt:topic:mosquitto:sonoff_pow_0:voltage"}
Number sonoff_pow_0_Load                "UPS Powerload [%.1f W]"                        <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:powerload"}
Number sonoff_pow_0_AppPower            "UPS Apperent https://github.com/arendst/Sonoff-Tasmota/wiki/Sonoff-Pow-and-Pow-R2Power [%.1f W]"                   <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:app_power"}
Number sonoff_pow_0_Current             "UPS Line Current [%.3f A]"                     <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:current"}
Number sonoff_pow_0_VCC                 "UPS VCC [%.3f VDC]"                            <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:vcc"}
Number sonoff_pow_0_Today               "UPS Energy Today [%.3f kWh]"                   <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:today"}
Number sonoff_pow_0_Yesterday           "UPS Energy Yesterday [%.3f kWh]"               <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:yesterday"}
Number sonoff_pow_0_Total               "UPS Total Energy Used [%.3f kWh]"              <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:total"}
String sonoff_pow_0_Uptime              "UPS Uptime [JS(sonoffUp.js):%s]"               <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:uptime"}
Number sonoff_pow_0_Period              "UPS Energy Period [%d Day(s)]"                 <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:period"}
Number sonoff_pow_0_ReactPower          "UPS Reactive Power [%.1f W]"                   <energy>                (Bedroom,pSwitches)     ["Data"]        {channel="mqtt:topic:mosquitto:sonoff_pow_0:react_pwr"}

You didn’t mention if you used Tasmota or the stock firmware, if you go with the Tasmota you won’t regret it, you can confire the POW’s MQTT to the nth degree that way. Check this out:

If you want sitemap stuff just let me know, mine’s pretty involved.

Let me be old school for the moment :joy:

I’m sure I’m trying the new binding soon. For now I wanted to have a proof for working.

Thanks for your answers and the detailed sample. I am sure that it will be very helpful for me.

Enjoy your weekend!

Can i please see the sitemap for the sonoff_pow modul please

Here it is:

Frame {
 Text item=sonoff_pow2_0_RSSI
 Text item=sonoff_pow2_0_Reachable icon=network_on valuecolor=[==Online="#a9f7b8"] visibility=[sonoff_pow2_0_Reachable==Online]
 Text item=sonoff_pow2_0_Reachable icon=network_off valuecolor=[!=Online="#f8a9ad"] visibility=[sonoff_pow2_0_Reachable!=Online]
 Switch item=sonoff_pow2_0 icon=switch valuecolor=[==ON="#a9f7b8", ==OFF="#f8a9ad"] visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_Voltage visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_Load visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_AppPower visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_Current visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_VCC visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_Today visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_Yesterday visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_Total visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_Uptime visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_TotalStarted visibility=[sonoff_pow2_0_Reachable=="Online"]
 Text item=sonoff_pow2_0_UpdateTime visibility=[sonoff_pow2_0_Reachable=="Online"]
}
1 Like