Sonoff;mqtt;openhab

mqtt
mqttsonoff
Tags: #<Tag:0x00007f1e5fc21648> #<Tag:0x00007f1e5fc21468>
(Udo Hartmann) #3

a very easy to use mqtt broker is mosquitto, which is available for raspberry, and you could even use the embedded mqtt broker which is delivered within openHAB2.4 (maybe also OH2.3?) You may find it in
Paper UI -> Add-ons -> MISC -> Embedded MQTT Broker

0 Likes

(Jürgen Baginski) #4

Did you consider reading This?.

If that doesn’t help, you should consider reading the beginners documentation of OPENHAB (use the link Documentation on top of this page).

0 Likes

(NATI D) #5

Thank you very much vzorglub and Udo_Hartmann for your help
I really appreciate people who give themselves and their wisdom to others in particular when I feel that I do not understand anything
Ok
So I understand that I can turn the RASPBERRY into MQTT BROKER, which means I do not need anything other than the RASPBERRY hardware.
The RASPBERRY of course is connected to the router and to the network where all the switches are located.
So I installed MQTT BROKER as you wrote through ADD-ON and I set a name and password and did not define a port (I’m right?) And did not understand what the “secure” means.
I also installed the MQTT BINDING via ADD-ON.
I understand that now I need to set the DEVICES SONOFF to the name and password I defined in MQTT BROKER, right ?.
So step by step …
Installing the TASMOTA on the SONOFF,
Installing OPENHAB on the RASPBERRY ,.
Installing MQTT BROKER on the OPENHAB
Setting the name and password of the MQTT BROKER
Sets the name and password on the SONOFF
Installing the MQTT BINDING on the OPENHAB
What next?
And again thank you for your help

0 Likes

(NATI D) #6

HI opus
I read all the documents for beginners
And that mostly made me a blackout
I understood a small part and the majority seemed to me like gibberish
And I know myself that I understand much better with personal guidance
And thanks again for that

0 Likes

(Jürgen Baginski) #7

Those documents have been written to give guidance ( the persons answering in here migth even be the ones that have written the document).
One advice, go step by step, for example start openHAB and create a single item and show it on the sitemap . Having mastered that then try to add a device. In case of sonoff/tasmota the page I have linked above does give all the needed steps ( even if you have to follow a link to understand mqtt).
If you have a specific questions at ANY step there are lots of people willing the help!

I was in the same position as you are right now, the learning curve was step but with the help of the forum members it was a peace of cake.

0 Likes

(Vincent Regaud) #8

You can also follow this:

and

0 Likes

(NATI D) #9

The truth is that after I read some of the documents, I gave up
I’m not interested in becoming an expert
I just want to connect my devices to OPENHAB
I can install, set some, but no more than that.
I can not learn Arduino just to install TASMOTA on the SONOFF
And I can not study Linux just for installing OPENHABIAN on the RASPBERRY
And I can not study dozens of MQTT documents just for MQTT BROKER set
Etc. etc’
I do not want to learn MQTT, I just want to use a simple panel and control my home
I need the guide who tells me the minimum information I need to reach the goal
And every guide given here (and I tried to read them believe me.) Requires a few reading pages about things I just can not figure out
Anyway thank you for trying

0 Likes

(Vincent Regaud) #10

If you are not willing to put some time in it you’ll never have a good home automation system.
Just buy a ready made one for big bucks

0 Likes

(NATI D) #11

Yes…
Just a pity that I invested in the RASPBERRY.
You may have an idea about such a finished product to invest in.
thanks anyway

0 Likes

(Vincent Regaud) #12

That will be quite an investment. They are very expensive

0 Likes

(Gad Ofir) #13

Hi Nati please call me 0523519988 :slight_smile:

0 Likes

(NATI D) #14

After I gave up, I saw this guy’s series


And everything became clearer
Highly recommend for beginner

0 Likes

(Rick Marshall) #15

Suginach, I thank you for your frankness. I too am a beginner and do not with to become an expert just want an inexpensive HA system. The problem I see is that the documentation written is not for beginners and the documentation is very confusing because many documents are out of date with old and wrong info. Also there are many ways to achieve the same goal. So for you and me it sends us off in lala land. I learn by simple trial and error, have a dyslexic mind. If the experts here would just supply a simple “what it takes to set up a simple device” it would make for more pleasing community. I now have my house 80% lighting on a PI and Openhab. Just entered the world of MQTT and I must say there are few examples of complete documentation of just what it takes. I DO appreciate the experts here that help, I just ask them to be patient with people who have full working lives that can not spend days learning, but could contribute.

0 Likes

(Udo Hartmann) #16

Really? Which documentation? This one https://www.openhab.org/docs/ is not out of date, as it’s automatically built every time openHAB is rebuilt.
It’s created from the sources, so it should be always cutting-edge.
In fact, it’s even possible to switch between versions (if there is an old version available, right upper corner)

Please be aware that openHAB is a highly complex piece of software, it’s used to merge hundreds of different (and in most cases completely incompatible) systems to one big system.
You will need deep knowledge of every part of your system, as there is no “just put A + B + C + D together, ta-dah, magic, working exactly as you want it to”, you have to tell all components what to do, not only openHAB but also every other part.

Learn it or leave it, it’s as simple as that.

Guess why professional home automation is so expensive? Because the manufacturer has to do all the work for you…

In fact, you don’t need to be a Linux expert to build a Raspberry openHAB system, but you will have to

  • download at least some software to flash the openhabian image to a SD card
  • download the correct image
  • follow the instructions “by heart”
  • learn how to use the raspberry the correct way (no, it’s not a windows desktop)
  • learn how to use windows shares from a GNU/Linux system correctly
  • learn how to connect all your components together to openHAB
  • learn how to configure openHAB the right way

If using hardware which isn’t meant to be used in an open way (such as sonoff) you will have to learn how to flash an alternative firmware (oh no, more to read, more to learn: download a flash tool, download the firmware, connect sonoff to the computer the correct way - four wires, confusing - flash…)

And yes, even then you will have to learn all sort of stuff like building rules…

Either spend many thousand bucks to let others do the job or learn how to do it yourself :slight_smile:

1 Like

(Rick Marshall) #17

Udo, you seem to me to be missing my point! OR I haven’t explained myself clearly.
Please let me explain! I mean no offense to your or anyone else’s efforts.

I just read a document from " David Graeff posted on Sunday, 16 December 2018" . Very well done! I am using a PI, with Milestone 2.5, and trying to understand MQTT. As I follow this document, I get to the part to configure the binding, guess what? My binding, the only binding available, via paper ui, to me, well it doesn’t give me the ability to do as the document explains. What do I do now? I have, from my many attempts, corrupted one setup after many hours of trying to configure MQTT. Luckily I have backup images so I don’t have to start from scratch. I have dyslexia, so reading extensive blah, blah I can not do it. I know it’s my problem. If it weren’t for those great youtube experts I would have never got so far. I am a retired computer/network admin, I don’t have lots of money, I like a challenge, but not all of us here have the same knowledge of programming lingo. YES Openhab is an “open source” makes it difficult. So maybe listen when dummies like me say they need help. Why can’t there be a simple document with the requirements to make something work? Or better yet, documentation that explains the setup parameters within a thing or binding. I read these posts where people fumble over installing “MQTT” and not knowing what components are needed to make it al work. So I am not the only one with issues.

Again sorry if I offended you, not my intent. just find the documentation hard to follow. Hoping one day I can help others.

0 Likes

(Udo Hartmann) #18

Oh, I wasn*t offended at all :slight_smile: and I didn’t want to offend you either…

There are several possible ways to do the configuration, starting from the real hardware and the exact firmware, e.g. if using the most recent version of tasmota, you will have the option to automagically detect your hardware from within openHAB2 with mqtt2 (home assistant part).

To get working setup, you will need at least openHAB2.4 stable.
There is a builtin mqtt broker which can be installed from Paper UI (addons -> misc) but you can also use mosquitto or even another broker.
To get openHAB connected to your broker you will have to setup the mqtt2 addon (Paper UI -> bindings), create a bridge (Paper UI Inbox -> + -> add mqtt -> bridge …) with a connection to your mqtt broker.
And you will need at least one generic mqtt thing (Paper UI Inbox -> + add mqtt -> generic mqtt thing).

Then add channels to that thing (Paper UI -> configuration -> Things -> the generic mqtt thing created in the last step -> add channels with the +)
For each channel setup at least one topic for receive or transmit, this topic is typically in the
form stat/nameOfSonoffThing/POWER for receiving the state
and cmnd/nameOfSonoffThing/POWER for transmitting a command.
If simple mode is active (Paper UI -> Configuration -> System -> Items(?) ) you will automatically get items to control the channels.
Take a look at Paper UI control, your generic mqtt thing should emerge with all your channels.
If simple mode is switched off, you will have to create the items yourself (Paper UI -> Configuration -> Items) and link the channels to the items (done in the channel of the generic mqtt thing).

I don’t have access to my openHAB system for now, so maybe I made some small mistakes, but in general this should suffice.

0 Likes

(Rick Marshall) #19

Thank you for your reply! This I understand better.
I have had Mosquitto working thanks to "https://www.smarthomeblog.net/mqtt-openhab/ " and tested. This is where I am stumped.
So your information gets me to: Adding a channel.


So where do I find info to fill out the template?

I am in simple mode and there are no items, or do the channels have to be created first?

I am familiar with the differences using OH data base and using file based control. I use VC to do most of my items, thing,rules and sitemap. Luckily for me VC crates the channels which totally baffle me.
Also when selecting a generic thing, there are other option I have been unable to find explanations of those things.


Can you point me ia direction?
Thank you very much for your help. At this time I have a Sonoff Dual flashed with Tasmota and working, but still ??? on some terminology setup issues. like “topic” & “full topic”.
I am an American married to a Chinese wife, I have the same problems with her. ;-). Note and she has with me…

0 Likes

(Udo Hartmann) #20

Items get created when a channel is added.
The Channel ID is the name the channel gets identified by openHAB (e.g. to link the channel to an item)
The Label is the default label set for this channel.

MQTT state topic is the topic to get the state of the channel (from your device, so you need to get that information from your device, in general you may have set at least a part of that topic yourself)

MQTT command topic is the same, but the other direction, so when switching in openHAB, a command is sent to that topic. The Broker gets the command and publishes it to your device. The device is switched.

MQTT is a commonly used protocol for IoT devices, if you owe some Homie or HomeAssistant components, you can use openHAB to control them without all the manual configuration, as these two systems are already builtin. MQTT then will autodiscover the devices and add them automatically if you approve the things in your Inbox. MQTT broker is the bridge to the broker. openHAB can send information about itself to MQTT, this is the System MQTT Broker part (afaik, did not test this yet).

0 Likes

(Rick Marshall) #21

Thanks Udo, with your help and finding a few documents from David Graeff I solved my issue and understanding of MQTT. To help others who see this post, to save the many hours I struggled, I wrote up a document, (hopefully no errors) that explains my accomplishments. I think it can help newbies.

Pi Model 3 B+, 32 gig Sd card, Openhabian; accessing via Windows 10

New build: onto my Pi SD card using BalenaEtcher and current Pi Image.

  1. Fresh load onto my Pi SD card using BalenaEtcher and current Pi Image.
  2. SSH > Sudo - openhabian-config upgrade to milestone (41) 2nd option “testing build”. Then reboot!
  3. SSH > Sudo – openhabian-config Update then upgrade then Log Viewer then Mosquito (no password)
  4. Back-up image #1
  5. Web access - Select Standard build
  6. System config + Simple Mode set.
  7. Install & configure Zwave binding.
  8. Setup Zwave things discovered 1-12 Things already on Z wave stick from a previous load.
    Naming convention: (Area_Location, Item, Item location) = (Bath_ Light_Ceiling)
    Select Channels, all in simple mode.
  9. Installed MQTT Binding, then MQTT setup: Inbox > “+” > MQTT Thing Binding > Add Manually > MQTT Broker > ‘Add PI IP address’ .
    Checked Sonoff-Tasmota App, device > console it’s connected! :slight_smile:
  10. Back-up image! #2
  11. Create and link MQTT to Sonoff device.
    Inbox > “+” > MQTT Binding > Add Manually > Generic MQTT Thing > Bridge Selection > Name: Sonoff_Dual_1 > Save.
    Create a Channel, Things > Sonoff_Dual_1 > ‘Channel +’ > Chanel Type: On/Off switch > Channel id: Sonoff_Dual_1_1 > Label: Heater_Sw1 > MQTT State: stat/sonoff/power1 > cmnd/sonoff/power1. Tested in PaperUI > Control, yeah!
    Another Channel, Things > Sonoff_Dual_1 > ‘Channel +’ > Chanel Type: On/Off switch > Channel id: Sonoff_Dual_1_2 > Label: Sw2 > MQTT State: stat/sonoff/power2 > cmnd/sonoff/power2. Tested in PaperUI > Control, yeah! (NOTE: Pay attention to upper/lower case, it counts)
    Accomplished this hurddle!

Now to use VC and hard code Things. Items, Sitemaps, Rules and Config files for security.

Then will move to Boot from SD and data on USB! On goes the challenges.

0 Likes

(Sascha Billian) #22

You also basically coud make an image of the SD, restore that image on a USB SSD and you would not need the SD card at all.

0 Likes