ITEAD Sonoff switches and sockets - cheap ESP8266 Wifi+MQTT hardware

The B1 is officially supported but no clear instructions are yet available. https://github.com/arendst/Sonoff-Tasmota/issues/676 You might need to wait a few days for someone to upload pictures or you can try yourself. Be sure to post pictures!

I have several Sonoff basics working fine in Openhab with Tamsota via MQTT.

I also have a POW variant which I also want to flash with Tamsota and add to my Openhab system.

How do I go about using the power data it gathers to display in Openhab/HABPanel?

hyperseven…

That’s basically the answer, yes.

There you’ll find how to define the needed items. After that you can display these on your sitemap, use them in rules or have them persisted to e.g. Grafana. Your choice :raised_hands:

Hey,

I don’t know if you have solved the problem, but do not get crazy… I have had also a lot of problems with the mqtt binding and get a error with the eclipse framework (also a lot of other people in the different communities in the interntt). This error is known since some months but there is no really solution. For me, I solved this with installing the openhab 2.2 unstable version. Since then it works… It also not stops anymore when installing the binding or anything else. But there is another problem you should be aware of, if you reboot the system, sometimes the mqtt not work anymore, you have just to uninstall the mqqt action and install it again, then it will work. Don’t ask me why, I’m just user.
And if you still have problems, maybe you should have a look to iobroker. At the beginning it not looking so nice and easy and clean, but at the end you will have to use the command line in both versions…

Not sure what you are referring to. The openHAB MQTT binding is doing its job reliably and “sometimes the mqtt not work anymore” is something I hear for the first time.

90% of the issues with the Binding I’ve encountered in the community forum originate in a wrongful user configuration. That’s why there is now a tutorial for that aspect of a new users first experience:

1 Like

I, have been following this article with great interest and reading as much as possible on mqtt and openhab2, not that I understand much, anyway I have also a problem with turning on a lamp with a flashed sonoff basic module. Followed all the advice from “ThomDietrich” and have progressed a long way, but still no response from sonoff module. As far as I can tell site map and items are installed correctly, seems to get response from sonoff to MQTT.FX, and able to see commands sent from openhab2 to MQTT.FX to power on sonoff, but still no response from relay. After reading this tutorial regarding MQTT binding, I have an error which I do not understand. Hopefully someone can make sense of it…and that maybe why I get no response from relay…

2017-09-08 09:42:38.590 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-09-08 09:42:38.591 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2017-09-08 09:42:38.596 [ERROR] [org.apache.felix.configadmin        ] - Cannot use configuration org.openhab.mqtt for [org.openhab.core.scriptengine.action.ActionService, org.osgi.service.cm.ManagedService, id=293, bundle=190/mvn:org.openhab.action/org.openhab.action.mqtt/1.10.0]: No visibility to configuration bound to mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.10.0

Hello,
following a hunch here: There is a bug where a wrong configuration is not fully purged from the openHAB memory. Please double check that your mqtt.cfg config file is correct, unistall the MQTT binding, delete the file /var/lib/openhab2/config/org/openhab/mqtt.config (linux apt installation), then restart openHAB and reinstall the binding.

Thanks for getting back to me. Did as you said it seemed to have removed that error message but still can not turn on sonoff relay from openhab2. You probably have heard it all before (see post from Travalon). Basically I have flashed sonoff basic as per your instruction using arduino ide, all went well. Started with a brand new installation of openhab2 with mosquito on raspberry pi3. Loaded site map and items file. All okay up to this point. Went into openhab2 basic ui and operated switch to turn sonoff relay on…MQTT.fx reports that it has received message from openhab2 but relay still not coming on. When i operate the sonoff relay with physical button on switch, relay operates and I get a message on MQTT.fx that it has received that message… MQTT binding installed along with MQTT actions…NEED HELP PLEASE…Include mqtt.cfg file, items file, sitemap…

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
broker.url=tcp://192.168.1.233:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.
broker.user=openhabian

# Optional. Password to authenticate with the broker.
broker.pwd=password (not really)

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

site map

sitemap home label="Woodys-SmartHouse"
{
       Frame label="Gamesroom"
       {
	       Switch item=DVES_A7FA7E
       }
		
}

items…

//This is the Items File

//Sonoff
Switch DVES_A7FA7E "Gameroom" <light> (LR,glight)
    { mqtt=">[broker:cmnd/DVES-A7FA7E/POWER:command:*:default],
            <[broker:stat/DVES-A7FA7E/POWER:state:default]" }

Hey,
your explanation sounds a bit confusing. Are you sure the Sonoff is connected to the MQTT broker? Did you try to manually switch the Sonoff from MQTT.fx?

You will see that everything is easier if you go at it step by step…

Thats my biggest problem, not knowing how MQTT works. I know that I put a “#” in the box and subscribe and it shows me the status of each device, or "cmnd/DVES_A7FA7E/POWER will just show me the status of that device, but thats it i,m afraid to say. Could you please tell me how I get MQTT.fx to speak directly to my device?. Would the command be

mosquitto_pub -h mqtt_server_name.com -t cmnd/DVES_A7FA7E/power -m 1

if so not sure what server name is or where to put this command in MQTT.fx…
Sorry to be a pain…

Ok, I’m just beginning to understand MQTT a little, it took me a couple of hours toget automatic updates/restart/queryFW to work, but getting it running gave a good feeling!:smiley:
Is the name you use as your topic correct? (DVES_A7FA7E), when I look at mij Sonoff Basic’s web interface i see this:

image

When I wan’t to use it I send something to MQTT Topic “sonoff-5” ie, “cmnd/sonoff-5/” and NOT to DVES_9D57D0

Ray

1 Like

That’s understandable. When new to the world of home automation you are confronted with dozens of technologies and methods you need to understand. Nonetheless, the best way to bet comfortable with them and to enjoy tinkering with your smarthome, you need to learn how XYZ (here: MQTT) works.

I’d advice to go back to MQTT Binding (v1.11) Getting Started 101 and go through the initial list of resources. There you’ll find the MQTT Essentials. An online article series containing everything you need to know. Nothing will replace the few minutes you invest reading these.

Could you please tell me how I get MQTT.fx to speak directly to my device?

There is no such thing. MQTT follows the publish-subscribe principle. Equal clients connect to a broker, then subscribe to topics and publish messages to topics. When a message is being published to a topic a client has subscribed, this client will then react on it. Therefore what you need to do to switch the Sonoff-Tasmota device is (see here) publish an “ON” or “OFF” payload message to the topic cmnd/DVES-A7FA7E/POWER.
That will become clear during the Essentials series.

1 Like

Many thanks to "X-Ray181, and "ThornDietrich. Yep I guess I need to go back to the books (ebooks) to read and understand. Once again Thanks to both of you, have it working now but going back to study…P.S yep you were right X-Ray181, got confused with topic, and fallback topic…

1 Like

Looks like there is a way to reflash without soldering (haven’t tested it yet):

Got the info from here:

3 Likes

Jup, never used it though. Also see: https://github.com/arendst/Sonoff-Tasmota/wiki/SonOTA

2 Likes

I have flashed Sonoff B1 bulb with SonOTA, worked quite well.

2 Likes

I just flashed a Sonoff Basic with this. Worked like a charm.

1 Like

is possible to have a bindings of SONOFF without flashing?

No. The original firmware is proprietary and only works with the provided app.
Sonoff-Tasmota on the other hand is free, open and extremely versatile.

1 Like