My nightmare with ESP8266 and openhab

Hay all, I am a newbye with OH and I am finding it very complicated to setup. I wonder if it is me or the system is actually complicated. I am a selfmade hobbyst with good skills.
Now…I am trying to make something work. Started with ESP8266 and some nodeMCU looking forward to raspberry.
First test trying to control an ESP8266 thorugh openhab but no success…I havebeen reading and watching video but every single one is different from the other.
I have win 10, OH 2.5.1 and MQTT binding 2.5.1, ESPEasy correctly set up and MQTT fx working properly as I can send messages, publish, subscribe and have the relays activated through MQTT fx as well through ESPeasy GUI.
I am having big trouble trying to “control” through openhab. The nightmare is setting/linking channels.
I installed MQTT addons and bindings, I can see the thing in the control panel but NO WAY to have the panel switch actually activating the relays.
What do I do wrong? Is there a guide for proper understanding?
Thank you.

Welcome to the openHAB Community :heart:

I will state something people will disagree with :smiley: but it’s my personal opinion.

Configuring MQTT 2.X Things, Chanels and Links via PaperUI is the best/easiest way. (In my point of view).

First I create my broker openhab:8080/paperui/index.html#/inbox/setup/add/mqtt:broker

Then I create my MQTT Generic Thing, and add a Chanel for each Topic.

Example a Sonoff 4CH Outdoor.

Now I configure the Chanel with the command and state topic.

Link my item to control it.

BAM Done.

I would suggest reading the MQTT docs again :confused:

2 Likes

In addition to that here is one of my ESPEasy driven relays:

Switch Relay <switch> { channel="mqtt:topic:esp8266two:gpio4" }

With ESPEasy in default setup make sure you are using a leading slash for your command topic.

It’s actually complicated.

Which ones?

To answer that we need much more information. Elias and sihui have provided some examples which hopefully will help.

The general way to be successful in OH is:

  1. Understand the concepts (Things, Items, Channels, Links, Rules, etc). To do that you need to read the docs.

  2. Understand the base technology at least a little bit. In this case MQTT. A wikipedia level understanding is usually all that’s needed. You probably have this step down.

  3. Read the binding docs for the binding you are using. For many technologies, MQTT being one, there are two or more add-ons. A 1.x version and a 2.x version and sometimes additional Action add-ons. You need to be sure of which binding you’ve installed (note: when there is a 2.x version of a binding, the 1.x version is hidden by default unless you check the Show Legacy 1.x option in PaperUI or on the add-ons search page of the docs. Make sure that what ever configuration you are are trying to use matches the version of the binding you are trying to use. If you see an item with { mqtt=">[... you are looking at an MQTT v1 configuration which will not work with v2. If you see talk about Things and Channels, you are dealing with a v2 binding. When searching the forum, only pay attention to those posts that explicitly mention it’s for v2 (2.5, 2.4, v2, etc).

In general, no, there isn’t one end-to-end guide. Such a guide is impossible. See How to get started (there is no step-by-step tutorial) for an full discussion of why and a list of a whole bunch of getting started resources you can use.

For MQTT in particular, there are a number of tutorial postings various users have made. OpenHAB 2.4 MQTT beginner experience *principal conclusions* from a post-newbie

IMHO leading / is not needed … I don’t use it and works without any problems - depends how you setup the topic, but generally it’s not required. Just my 2 cents.

1 Like

With a default setup of ESPEasy it is required, though.
It depends on this setting:

grafik

Hm, maybe depends on the version. In the very latest codebase I’m using it’s without the leading /. You can also check here

event->String2 = F("%sysname%/%tskname%/%valname%");

EDIT: yes, leading slash was removed ~7 months ago - see details

1 Like

Thx, good to know.
I don’t reflash my devices very often as they are working very reliable.

1 Like

Thank You all for you advice. I will read carefully trying to better understand. The basic concept of OH are quite clear. The problem I am having is ti correctly setup. I also have a Samsung TV and it is automatically “discovered” but I still can not get it be controlled by OH.
One …silly (maybe) question…as of my understanding to have the ystem working it is necessary to have the PC running OH always powered…am I right?

Yes. That’s why most use an SBC such as a Raspberry to run OH.

Thanks, just for my knowledge, what would be a solution to have home automation not linked to an always powered PC? I mean in my first steps in IoT I will work with very simple layout…let say light and heating control with switch on/off. This is the reason why I am using a 4 relay module. Moreover I need to have clear understanding of the system before moving to a Raspberry… or should I start immediately with a Raspberry?

Abandon the idea of a HUB that bridges between all your IoT devices and code everything to talk to each other directly. Of course this is usually only possible when you have all DIY devices and you end up with your behaviors diffused across dozens of devices which becomes exceptionally challenging to manage and maintain.

well you could implement all logic in your devices (or intermediate systems to be always on), but that would be even more of a nightmare and isn’t feasible for higher-level automation beyond what say your heating autonomously does today.
So short answer: there is no real alternative. Get a 24/7 server or die trying.

Ok thanks. BTW I am looking forward to get the ESP working for better understanding.
I had a look at the video and pages you suggested…but honestly I feel worse than before…it actually looks as a nightmare. I am stucked to this fuc… channel setup and link them to the device.
I have one thing “MQTT broker” and it is ONLINE. Broker ID is embedded-mqtt-broker
I also have a thing named “LCTech” and it is ONLINE. Bridge is: MQTT Broker - mqtt:systemBroker:embedded-mqtt-broker. It is a Genereic MQTT Thing with mqtt:topic:7263475c.

So I believe it should be fine.

What I am not able to do or better I keep reading and I get more confusion in my head is to set up is the fuc… channels. I guess I need four channels for rel 1, rel 2 and so on.

It would be a heck of lot easier to help if you provided more details about what you’ve done, what you’ve tried and exactly where things are going wrong.

What version of OH?
How did you install?
You indicated you have the ESP8266’s talking correctly, using OH’s internal broker or Mosquitto or something else?
Show you Items
Show your Things
Show the topics you are needing to subscribe to and the messages received
Show the topics you are needing to publish to and the expected messages

This stuff isn’t easy. Dealing with MQTT as your first binding out of the gate is making things even more complex, particularly if you don’t understand MQTT. But it’s doubly hard to try to help without any information.

2 Likes

Hey, I understand your words. I am not an expert but I feel frustrated by this thing!
Please consider that english is not my first language so I could misunderstand some concept also because there are no documents in italian language.
Let me give you some details.
Hardware:
PC with win 10. ESP8266 (I am currently using this but I have nodemMCUs well) installed on 4 relays module.
Software:
Win 10, OH 2.5.1. MQTT 1.7.1. ESPeasy_mega_P165_1M_128kSlwip20_PUYA.
OH is on IP 192.168.1.8:8080 (static)
ESP8266 is on IP 192.168.1.21
ESPEasy shows proper connection to wifi and to MQTT I get this log:
MQTT : Connected to broker with client ID: ESP_Client_DC:4f etc
Subscribed to: LCTech/cmd
EVENT:MQTT#Connected
Controller subscribe in ESPeasy is set to: LCTech/cmd
Controller Publish: set to LCTech.
Protocol OpenHAB MQTT

MQTT profile is ok (green light)
LCTech( name of ESP8266) is working correctly when using MQTT fx.
I log in, in Publish page I write LCTech/cmd in the small box, then the command “relay,1,1” in the big box, hit publish and the relay works.
In the subscribe page I subscribe to LCtech and I can see the sent input in the blackbox.

OH

This is not clear to me. I am not sure what and how to show you.
I can say that I followed the video “Complete Guide OpenHAB MQTT 2.4 Binding / Embedded Broker” and even if it applies to 2.4 I did not notice many differencies in setting up. I ended having two things ONLINE. One is LCTech (Generic MQTT thing ; mqtttopic:7263475c)
the other one is MQTT broker (System MQTT Broker; mqtt:systemBroker:embedded-mqtt-broker).
My need is to control 4 relays on/off each one with a single channell…I suppose

Understandable.

Hey that’s totally fine, but you never declared that in your first post, so no one knew about it and could adapt to it. :slight_smile:

Also the maintainers will NEVER write documentation in a different language then englisch.
If you want Italian documentation, welcome to this open source project! Feel free to contribute a translation.

If you reference a video why not share the URL to the video in first place so we can understand what you did :slight_smile:

We all try to help but we need help from you too.
I would really suggest you should read this topic here.
If you follow this guide, with your future questions, you will get faster responses with a higher quality.
I can guaranty it!

1 Like

Thanks for your kind reply :wink:

BTW finally I succedeed in having it work. Now I have the control panel working.
I did not know what to write under cannel configuration Custom On/Open value and Custom Off/Closed value.
I wrote the command: relay,1,1 and relay 1,0 and I can now control the relay form the control panel.
My MQTT Command Topic is set to LCTech/cmd :blush: …so far so good.
Next step is to get control over the web…let’s what happens now.

Well, I was also able to use OH over the internet installing OH Cloud connector.
Despite the initial difficulties I believe it is a great tool having the possibility to link together “things”.
I am doing some tests. I wish to thank the community for the support received so far.

3 Likes