Domoticz mqtt sonoff
In the previous tutorialwe tested the free online broker cloudMQTT. The free offer is limited to 5 simultaneous connections. It is more than enough to drive a home automation server even when you are not at home, but it is too little if you have developed many connected objects controlled MQTT.
The Raspberry Pi or any other mini-PC is suitable for this type of application. I still offer the Mosquitto broker in my projects but there are many others. No matter the broker employed, the principle will be the same.
All Node-RED tutorials. Make a double click to edit the parameters of the Node. Click on the pencil beside the Add new mqtt-broker selector. It is possible to publish messages automatically to know the status of the router by going to the Messages tab. All that remains is to connect the two Nodes and deploy the flow by clicking on Deploy in the upper right corner. Here, I also turned on a smart socket Sonoff S26 hacked with the firmware Tasmota.
The message with the stopped status was sent when the flow was deployed, which is perfectly normal. This configuration unfortunately only works in one direction.
To do this, we will have to send incoming messages back to cloudMQTT and send them back to the local broker. So that it works, we will filter the following messages the type of topic. Tasmota publishes messages on 3 different topics:.
The returns all of the Tasmota accessories. The second flow transfers the commands sent to cloudMQTT on the local broker on which the Sonoff — Tasmota accessories are connected. Past this code of this flow on your Node-RED then modify the connection parameters before deploying it.
Participate in the development by downloading the test version from the Apple Store or the Google Play Store. You are already over ! Thank you! To learn more about infomaniak's commitments to the environment.After some initial fiddling I have figured out all the commands to send to Domoticz using MQTT for all the different dummy sensors.
The default command for Domoticz is udevice so you can leave that out if you want to but I have included it in all of them. The barometer shows the atmospheric pressure and a prediction. You can send digits for the pressure. You can send digits for the temperature but only the first is displayed it is rounded off.
You can send digits for the pressure as well. The humidity only displays whole numbers chops off any digits. You can add digits after the decimal if needed. The wind sensor will show wind direction, velocity and gust speed. The humidity sensor will show humidity and an environment level.
You can only send whole numbers. For the temperature you can send digits after the decimal. For humidity anything after the decimal will be chopped off. The temperature sensor will show the temperature.
The pressure sensor will show the pressure in bar. The distance sensor will show the distance in cm. The scale sensor will show the weight of something in kg.
The thermostat setpoint sensor will show setpoint of a thermostat. The soil moisture sensor will show the soil moisture in centiBars. The sound level sensor will show the level of sound in decibel of something.
Digits after the decimal are dropped. The custom sensor will show what you want in the units you want. The ampere 1 phase sensor will show the power draw in A.
MQTT router with Node-RED, connect all your Sonoff Tasmota modules to cloudMQTT
The ampere 3 phase sensor will show the power draw in A for 3 phases. The voltage sensor will show the usage in Watt of something. The voltage sensor will show voltage of something.
The electric sensor will show the current usage of electricity in Watt and the cumulative usage in kWh. The P1 Smart meter sensor allows you to show you power consumption, low and high usage, low and high return, actual consumption and actual return. You can add digits after the decimal.For example, for a device at octet In the real world, you will regularly encounter missed packets with this approach it's as if the Sonoffs aren't always listening.
To check the current state of a Sonoff, we can use. Our script can check for either format automatically. The TaskName of 'relay' has a state of 0. Our script uses this approach to verify that the Sonoff received a command and will keep resending until the state changes as required. Our script is written in perl but when using it with Domoticz we will call it from a pre-processor script written in bash. The reason for this is that the perl script has a deliberate short sleep-delay built-in before it retries a failed command.
As Domoticz waits for scripts to finish before continuing its own execution, this delay would hold up Domoticz and we don't want that. Create a bash script called sonoffs. Make sure perl is installed it very likely is on a linux-based OS and then install the modules from CPAN that we need:.
Now create a perl script called sonoffs. That's it. You can debug things if necessary by running the perl script directly from the linux command line: e.
Also, if the bash script won't run from Domoticz, try specifying the full path to the bash file with a triple-slash:. Setup Our script is written in perl but when using it with Domoticz we will call it from a pre-processor script written in bash.
Navigation menu Personal tools Log in. Namespaces Page Discussion.
MQTT out for Domoticz
I just couldn't make it work. With every new Sonoff device I gave it a chance and the outcome was always the same.
Until now. Don't know what was wrong. Maybe an uncompatibility with some other service or app in my phone.
At some point the problem has been addressed and I could finally test it. It works, you can discover the device, force pair mode for any of the 4 available buttons and use them. But I just don't want to use it.
Hacking the Sonoff RF Bridge 433
Short section, right. There is really not much more about it. A sticker with a QR linking to the eWeLink user guide. Opening the box is quite easy with the help of a couple of plastic opening tools. Inside the box there is a single PCB with all the components. An 8-bit microcontroller by SiLabs that manages the radio communication. Moving the real-time encoding and decoding out of the ESP has benefits since those are very time-picky functionalities that could interfere with the WiFi communications.
You might have also noticed two quarter-wavelength wire antennae, one close to the receiver and the opposite one for transmitting. The communication is done via serial RX and TX and that could be a problem when trying to flash a new firmware. Moving the switch to the OFF position you effectively disconnect the communication between both microcontrollers. Enough about the PCB.
All you have to do is:. At that moment the ESP will boot into flash mode, ready to get a new firmware. If you are using PlatformIO recommendedjust checkouot the ESPurna repositorybrowse or open the Atom IDE on the code folder and build and flash the itead-sonoff-rfbridge environment.
From the console it would be something like:. Since 1. So we have a good enough API to work with. Check my post about secure access to your IoT devices from the intenetalso with Google Home.
That's all it takes. You can sniff and store as many codes as you want or use other apps or services to send them via MQTT. I have a couple of old RF switches sets at home. I have used them in the past and time has come to give them a second life.Welcome Guest. Domoticz docker. Viewed 1k times 0. All with the goal to have improved logging of historic state changes of HC2.
Also the -p options expose service ports. I noted that the time and date were out by three months and even though I had a valid network connection and pinging the NTP time servers was possible, the date and time would never update. You can find it here. Donations The Docker team has developed a clustering and scheduling tool for Docker containers, called swarm.
I came across a weblog from someone Home assistant who uses an awesome solution to cast a ipcamera to chromecast devices. A simple text file is sufficient to describe the machine to build. Content in this page is indended to improve my presentation skills as well as to make content useful to others who land on these pages. For support talk to us on our IRC channel or on the linuxserver. Make sure to open port It lets developers build, ship and run light-weight applications anywhere.
All gists Back to GitHub. Bilan du fonctionnement de Domoticz sous Docker. Viewed k times Previously I wrote about how and why I built a simple web-scrapig script to notify us about our favourite food.
The architectures supported by this image are: domoticz-docker Dockerfile for domoticz on raspberry pi. Main repository 5, 9,; Name Downloads Stars Docker Hub is the world's easiest way to create, manage, and deliver your teams' container applications.
It's based on Ubuntu I did a lot of reading in and the race was between Home assistant or Openhab I am going for Openhab because of the more stable system, blocky and Google home integration. After using 10 years Domoticz.Last December Itead Studio updated their Home Automation product line with a new and different product. The main difference is that it doesn't have a relay and it's mainly sensors and no actuator if we don't define a notifying LED as an actuator. But, such a collection of sensors, with 3 of them having analog interfaces, cannot be run from the single-ADC ESP so Itead has thrown in a good old ATMegaP to drive the sensors and report the Espressif with the data.
The first thing that draw your attention about the Sonoff SC is it's casing. It's kind of a truncated hexagonal-ish pyramid with a round grid on top and a rounded bottom. Seriously, somebody had a good time designing this.
It looks a lot like a intricate speaker and actually that's what it is. Side by side with the fake audio hole there is an microUSB connector that's only for powering the device no data lines connected and a microSD slot.
The microSD reader is connected to the ATMegaP and I'm not sure what original purpose it has but I can think on a couple of good things to do with it. Once the 4 screws are removed it can still be a little tricky to take the PCB out from the enclosure since the button shaft leaves little room to lift the PCB from the plastic holders. Meanwhile you try to remove it, take a look at the components on that bottom side of the PCB.
There you can find the controllers and programming headers. There are a couple of simple, almost out-of-the-box, upgrades you can do to your Sonoff SC. Both sensors are pin compatible. Off course replacing the sensor is not the full story, you will need to add support for the DHT22 to the firmware.
More on this later on. You will need a GND connection too but there are quite a few available and properly labelled on the board already. So after making myself comfortable with the hardware of the device I started putting together some pieces grabbing code from other projects like the ESPurna firmware. That means no cloudthat means MQTT.
The firmware is a good starting point but I don't like it's architectured. Everything is too coupled. So first thing was to create a communications library between both microcontrollers. I started looking for similar solutions and found out the SerialComm library by fjctp. It was almost what I was looking for but I liked the AT commands approach, one char keys are too minimal and naming is important. So I wrote the SerialLink library that allows me to:.
In the picture below you have a sample of the communication between both microcontrollers. I will create it's own repo soon. In this code fragment you can see how message keys are matched and messages are forwarded to three different clients: MQTT, Domoticz and broadcasted to websocket clients like the web interface.
Now, this is more like a game feature. Don't know if it's really useful but it's certainly fun to play with. Well, this feature is about that. My current approach is:.
This way I can encode clapping patterns as one byte codes. Three claps evenly spaced in time will be a b or 4. But if you leave a longer time less than a second between the second and third claps you get a b or 5. I admit it's somewhat weird but you easily get used to it. Right now clapping codes are sent by MQTT to a user defined topic. So it's a matter of having a service somewhere in you local network translating them to MQTT topics to perform different actions.
This is a my test flow in Node-RED at home:. Those are ESPurna devices, payload 2 means toggle relay.Node-RED  is a tool running in the Node. Flows can be then deployed to the runtime in a single-click. Domoticz supports a number of hardware devices natively rfxtrx, zwave, smartmeter etc.
There are zillions of other devices out there, with a lot of interfaces. Domoticz can also respond to actions requested by anyone and passed on by the MQTT-broker. Now something has to take care of creating and interpreting these messages. The Node-RED tool provides an alternative way to creating little programs flows to interface with anything you want. Or maybe you like to create programs in Node. So using Node-RED is not mandatory, it does however provide a fun and attractive way to handle messages.
So it also depends on your needs and preferences. It is highly recommended that if you are using Debian or Rasbian that you use the additional Mosquitto repositories. This will ensure you get the latest stable version of Mosquitto as determined by the project itself, rather than an outdated version via the Debian or Raspbian repositories.
Instructions can be found here: . Then publish a temperature measurement to the virtual sensor idx noted above example idx 1 like:. Owntracks [owntracks. A Node-RED script could subscribe to the owntracks-topic and republish the info in a Domoticz compatible message so Domoticz can use the location info. Note: If "command" is not set, it defaults to "udevice", the two following messages are equivalent:. Navigation menu Personal tools Log in.How to Sonoff RF bridge with Domoticz and Tasmota