I am trying to understand how to use Sonoff/Tasmota switches with OH2.
What do I want to do:
I do have a running OH2 with Z-Wave+ and FS20 CUL. Just did now successfully my first steps with great support here in the forum.
Now I would like to extend the OH with some Sonoff/Tasmota switches.
What I need:
I am using a classic PIR with a closer relay to switch the sonoff switch for a second.
(Therefore the PIR relay will close PIN 4 and 5 on my Sonoff)
This Sonoff switch signal I want to read with OH2 in order to switch a Z-Wave switch via OH2.
What I don´t understand: Is it enough to just install the MQTT Binding or do I need to install JSON or something else?
I am not a developer and therefore I don´really understand this MQTT and
even less what is JSON and how to read such a signal from the sonoff via MQTT.
Who can help? Yes, I was reading in the forum, but to be honest this is a real confusing
topic for me.
OK I was reading and now need to come back with some questions.
As I wrote this isn´t easy!
For my example I need to get an information from a Sonoff Tasmota switch that it was switched on. So I assume that this command below is pointing in the right direction, right?
Switch mySwitch {mqtt=">[mybroker:myhouse/office/light:command:*:Switch ${itemName} was turned ${command}]"}
I would like to read only the command “ON” because it is an PIR signal, so I need to change to:
Switch mySwitch {mqtt=">[mybroker:myhouse/office/light:command:ON:Switch ${itemName} was turned ${command}]"} right?
But what the hell is this - this is only the item definition, usually I only do define the device with it´s address details in the items. So why the hell I need to define a outbound item for a command ON?
When I want to send an switch command from OH2 to the switch is this an outbound or an inbound required in this switch item definition?
How do I get this MQTT switch to send the status “ON” to my OH2, is this somewhere a variable in a log?
And how do I use the received status ON in my OH2 rules, to e.g.
when status is “ON”
then activate a ZWAVE switch
The Tasmota ESP will publish a MQTT message with a topic and a payload
OH can receive these messages, it’s called subscribing. An item can subscribe to a particular topic, or two or three…
The Binding syntax tells openHAB what to do with that payload when it receives a payload on that topic.
But because the payload is in JSON format this will not work, we need to “TRANSFORM” the JSON into the state that a switch can take ON or OFF
I don’t know what your json from TASMOTA looks like so
FOLLOW ME:
Do you have a way to monitor MQTT messages? MQTT.fx or MQTT-spy installed?
Is your MQTT broker up and running?
Is openHAB connected to your broker?
We will do this step by step and get you up and running
Thanks a lot for your support, but I need to postpone a bit. I didn´t install the binding yet.
The sonoffs aren´t defined yet … So still in theoretical mode
Keep it simple to start with. Get a Sonoff device installed, and connected, and simply turning the output on/off, both from within OH and from the device itself.
Maybe someone can help me to get my first sonoff up and running, I can read a lot and it brings me closerr but still just to difficult.
What I would like to get is a coonection to that sonoff, what allows me to switch it and more important what reflects the status of the device “ON” or “OFF”.
There is not much setting right?
The sonoff tasmota device is on 192.168.1.4
The IP in mqtt.cfg is the IP from the sonoff tasmota
The user and password are also these setup in the sonoff tasmota
No Typo but not working, what´s wrong here?
I already tried all combinations means user/pwd from Openhab and used
domus1 instead of the IP but no luck.
This is the MQTT settings in sonoff tasmota device (the broker)
And don´t know exactly what you mean but I am using a sonoff tasmota basic device and these settings I copied above are the once from that device, it is up and running I can access it via this IP address and I can see the console showing me wrong connections. Copy of this console output is also three messages above.
So Yes I assume the Broker (this sonoff tasmota device) is up and running
To exchange messages tasmota and oh use mqtt. It’s a light weight messaging system.
It needs to be installed and running on your network before the information can pass between tasmota and OH.
Hm Sure?
The only thing I can see is under add-ons/Bindings - here the MQTT Binding (installed)
and there is something under add-ons/Actions - MQTT-Action (not installed)