HTTP Binding Tasmota 4-CH Device

Hi There,

I am trying to connect my Sonoff 4-CH Switch (running Tasmota Firmware) to my openHAB 4 Server.

If I do use these URL, I can user the Switch:

Status: http://10.1.1.147/cm?cmnd=Power2
ON: http://10.1.1.147/cm?cmnd=Power2%20ON
OFF: http://10.1.1.147/cm?cmnd=Power2%20OFF

My Things Config with Channel looks like:

UID: http:url:f26926a118
label: Terasse Licht
thingTypeUID: http:url
configuration:
  ignoreSSLErrors: false
  baseURL: http://10.1.1.147/cm?cmnd=Power2
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: Power2
    channelTypeUID: http:switch
    label: Terasse Licht
    description: ""
    configuration:
      onValue: "%20ON"
      offValue: "%20OFF"
      escapedUrl: true 

I am adding an Item (type:switch), but I can not activate/deactivate the switch - nothing happens.
I’m sure I miss sth. but after 2h I really prefer to get in touch with the community :slight_smile:

appreciating your help

Hi, why are you using the http binding ? The “usual” way would have been either to use mqtt (which implies a mosquitto broker), flash the sonoff with esphome (and use the new esphome binding), or even use the sonoff firmware (there’s also a binding for that).

I had several problems with the http binding whenever I used “special” characters such as %, so I’m using the SmartHome J/HTTP Binding instead.

Right now there is the Tasmota Plug binding but it currently supports only one channel. I think it could extended to 4 channels.

Thanks, I was not aware of this binding. But I prefer to have the web interface disabled which rules out http commands. And when I enable web interface it is protected by userid:password

Just a suggestion, you may add pulsetime support to your binding.

The marketplace binding was updated to support channels 2,3 & 4.

Wow guys - you are amazing.

Actually I was not successfull with mqtt (mosquitto was working with device - tested with mqtt explorer).
But I was not able to find the correct config within openhab.

I will check the plugin in marketplace by next week And will Come back with a Resultat.

@mlobstein: Great job!

as there is no kudos without a question mark: :wink:

Maybe you are also able to expand that binding to read also other (mostly) values from Tasmota like temperature, pressure a.s.o. ???
I run a LOT of Tasmota-Stuff here, which not only have switches, but also provide other information and I would love to have them integrated without MQTT.

The issue might be, that it be not easy, as one do not really know, what kind of data is provided. I even do not know (as I´m not a coder), whether it is possible to get the data via the api (and how). Nevertheless, as said, I run a lot of them and can help with testing and proves.

Good idea. The only issue I see is that there are many different types of data provided depending on the device. On mine it provides energy usage information:

I will look into it to see what is possible.
@moody_blue I have added username/password support to the marketplace binding.

the plugin from marketplace works like a charm - many thanks for this!

I have added energy monitoring channels to the binding. Can you post the output of this URL: http://$plug-ip/cm?cmnd=Status%2010 so that I can see what the JSON output is for the temperature and other sensors? It should be possible to add those to the binding as well.

I´m in the meantime away from openHAB and changed my whole system at home, sorry.
Nevertheless, this is the requested output of one of these devices

{"StatusSNS":{"Time":"2024-03-12T21:34:49","ENERGY":{"TotalStartTime":"2022-12-30T14:11:40","Total":126.659,"Yesterday":0.015,"Today":0.013,"Power": 1,"ApparentPower": 2,"ReactivePower": 2,"Factor":0.26,"Voltage":233,"Current":0.010}}}

The device is one of them: https://www.amazon.de/Tasmota-Steckdose-NOUS-A1T-stromverbrauch/dp/B0054PSI46/ref=sr_1_1_sspa?crid=3G3RMYHORAIYZ&dib=eyJ2IjoiMSJ9.ixPcv0ORuHb3cIpoSsQORHt89Ojwyt-spa0QvBZEPcftLJAJ2k-CVlb5ic65TkfKkqgYqKv5TrCB9-ZQ9k4Jyfe6CEtHY4WqjP92F4w5jmFsNu-2kfCANRhw-QFS_48aA2ba8pUKbqqtA8hI02d8d7BeoaSheQFpf7ZBZvaEMj-XdNHCaepQ5MNEE_HVxU0P_U_Joht5YvG_8GTVmksLcukzfU7kD2rf4zrmCdLXguNYU2HLKRsl6y9Xa3JNk_rwxKkX649RSypcZVNzcoxN-eGLcMxKzmwddV97LBERGVM.H1BNztvZrFJTr-lxVuC_Y6RXtOctbzCYru6TaMwR5bo&dib_tag=se&keywords=nous+tasmota&qid=1710275771&sprefix=nous+tasmota%2Caps%2C136&sr=8-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1

Good. That looks exactly like what mine outputs and what was implemented. If you have a chance, please post the output of the one with a temperature sensor.

Below is a compiled jar with the new energy monitoring channels: https://github.com/mlobstein/openhab-addons/releases/download/v4.2.0-snapshot/org.openhab.binding.tasmotaplug-4.2.0-SNAPSHOT.jar

I can give you that:

{"StatusSNS":{"Time":"2024-03-13T07:05:21","DS18B20-1":{"Id":"0317714BBCFF","Temperature":32.6},"DS18B20-2":{"Id":"031771786EFF","Temperature":48.7},"DS18B20-3":{"Id":"031771805BFF","Temperature":36.1},"DS18B20-4":{"Id":"0317718310FF","Temperature":36.9},"DS18B20-5":{"Id":"031771A53AFF","Temperature":49.3},"SR04":{"Distance":52.2},"TempUnit":"C"}}

or that:

{"StatusSNS":{"Time":"2024-03-13T07:07:52","DS18B20":{"Id":"000006150809","Temperature":9.6},"BME280":{"Temperature":12.2,"Humidity":47.1,"DewPoint":1.2,"Pressure":963.4},"SR04":{"Distance":32.5},"PressureUnit":"hPa","TempUnit":"C"}}

I have this device:

my result for that is - anything wrong here? running latest tasmota 13.4.0.2:

{
    "StatusSNS": {
        "Time": "2024-03-14T06:50:35"
    }
}```

I don’t think all devices contain the energy monitoring bits.