sonoff

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
sonoff [08.12.2018 09:50] – [MQTT interface for digitalSTROM] Pascal Sutersonoff [30.11.2020 13:58] – [Falshing Tasmota Firmware] Pascal Suter
Line 39: Line 39:
 I personally went for flashing over a USB TTL adapter using the Arduino IDE. It is important to notice, that the TTL adapter needs to provide 3.3V, not 5V! Also i recommend using a PL2303 based USB TTL adapter, as others did not work for me (spent hours trying until I finally gave up and tried with a PL2303 based one I had laying around). Another important Point was, how to enter the programming mode: Hold down the pushbutton while connecting only the power pins. Leave at least one of the two data pins disconnected. Then let go of the button and connect the RX and TX (crossed). Flasing did not work for me when i connected all wires at the same time while holding down the button.  I personally went for flashing over a USB TTL adapter using the Arduino IDE. It is important to notice, that the TTL adapter needs to provide 3.3V, not 5V! Also i recommend using a PL2303 based USB TTL adapter, as others did not work for me (spent hours trying until I finally gave up and tried with a PL2303 based one I had laying around). Another important Point was, how to enter the programming mode: Hold down the pushbutton while connecting only the power pins. Leave at least one of the two data pins disconnected. Then let go of the button and connect the RX and TX (crossed). Flasing did not work for me when i connected all wires at the same time while holding down the button. 
  
-I strongly recommend to edit the settings before compiling and adding your wifi credentials, this will save some time and hassle when configuring the device later on. It will simply connect to your wifi and you can access its webpage to do the rest of the configuration. +<del>I strongly recommend to edit the settings before compiling and adding your wifi credentials, this will save some time and hassle when configuring the device later on. It will simply connect to your wifi and you can access its webpage to do the rest of the configuration. </del> **Update**: don't do this! whenever possible, flash the stock ''tasmota.bin'' file, it is alot easier to do so and your sonoff will fall back to a setup mode if the wifi password has changed and it can no longer login.. also with new tools such as Tasmotizer, the credentials can be configured after flashing over the serial connection which makes it much easier than hardcoding and compiling your settings.  
  
 Here are the steps it took to flash the stock sonoff (current and more detailed instructions can be found in the [[https://github.com/arendst/Sonoff-Tasmota/wiki/Arduino-IDE|Tasmota wiki]] Here are the steps it took to flash the stock sonoff (current and more detailed instructions can be found in the [[https://github.com/arendst/Sonoff-Tasmota/wiki/Arduino-IDE|Tasmota wiki]]
 +
 +**Update**: again, the instructions below are obsolete and may only be valid if you want to re-compile tasmota.. but you rarely will have to do that.. Instead i recommend using [[https://github.com/tasmota/tasmotizer|Tasmotizer]], a very simple python gui which can be installed using pip3 on Windows, linux and mac (for widows there is even an exe installer). besides flashing your tasmota compatible device it can also set your wifi settings and subsequently show the ip of the device as long as it is still attached to the serial interface. 
 +
 +here are the steps using Tasmotizer: 
 +  * install tasmotizer: <code
 +pip3 install --upgrade pip wheel
 +pip3 install tasmotizer
 +tasmotizer.py</code>
 +  * under "Select Image" choose "release" and then select whatever image you want to flash, in most cases this will be ''tasmota.bin'' 
 +  * connect your sonoff to the serial2usb adapter WITH MAINS DISCONNECTED!! hold down the push button and plug-in the usb adapter. 
 +  * let go of the push button and click "refresh" next to the "Select Port" drop down. most likely this will see and select your usb adapter 
 +  * click "Tasmotize" and wait for it to erase and reflash your device. 
 +  * once that is done, unplug your usb adapter and plug it back in, to reset the sonof 
 +  * now click on send config and enter your desired config, then upload it. 
 +  * a few seconds later, your sonoff sould be connected to your network and with Get IP you can now see the ip it got from your DHCP. 
 +
 +
 +If you really want to compile tasmota yourself, you should read the official documentation, as what follows now is already several years old and probably no longer exactly true. however, I wrote it, so here it is anyway :) .. 
 +
   - [[setup arduino IDE for ESP8266]]   - [[setup arduino IDE for ESP8266]]
   - download the sourcecode tar.gz or zip package from the [[https://github.com/arendst/Sonoff-Tasmota/releases|Tasmota releases page]]   - download the sourcecode tar.gz or zip package from the [[https://github.com/arendst/Sonoff-Tasmota/releases|Tasmota releases page]]
Line 131: Line 151:
   mosquitto_pub -h mqtt.psuter.ch -u sonoffs -P sonoff -t set/dss/apartment/zones/Garden/groups/1/lastCalledScene -m 5   mosquitto_pub -h mqtt.psuter.ch -u sonoffs -P sonoff -t set/dss/apartment/zones/Garden/groups/1/lastCalledScene -m 5
  
-==== retention and QoS ==== 
-the mqtt-dss-bridge is a bit of a special service regarding retention and QoS since the state of our DigitalStrom environment is not lost when the service is restarted.. so DigitalSTROM has basically its built-in retention. when the mqtt-dss-bridge service is started it publishes the sate for all properties of our DigitalSTROM environment to the mqtt server. this includes things that where published before. By Default the  mqtt-dss-bridge uses a QoS of 1 which means, every message will be sent out at least once. In my case i have created a rule that turns all the lights in the entire hous off as soon as one room enters the deep off state.. this allows me to press and hold the light switch for 3 seconds in the bedroom and the entire house will turn dark. unfortunately though, due to this qos setting of 1 the message will be re-sent as soon as the mqtt-dss-service is restarted. so as soon as at least one room in my house is in the deep-off state all lights will go out when i restart the service. to avoid this, i set the QoS to 0, so the mqtt server will ignore the re-published message upon restart of the mqtt server. To set the qos you need to edit the file in ''/usr/local/lib/node_modules/mqtt-dss-bridge/lib/dss.js'', search for qos and set the value accordingly.. in my case i set it to ''qos: config.client.qos'' and then added a qos line in the ''config.js'' file for that right below the ''baseTopic'' value.  
- 
-a similar issue araises if you use for example node-red to create the above mentioned rule and set the retention flag to true or leave it unset which is true by default in node-red. the lights-off command will be kept on the mqtt server and it will be sent to the digitalstrom bus each time the dss bridge is reloaded. this is of course correct but not wanted in our case. so remember to set that flag to false in node-red for your dss nodes if you don't want to redo the last command on that node each time the mqtt-dss-bridge is restarted.  
  
 ===== Rules Engine - node-red ===== ===== Rules Engine - node-red =====
Line 164: Line 180:
 and here is what it looks like:  and here is what it looks like: 
 {{ :node-red:flow.png |}} {{ :node-red:flow.png |}}
 +==== a word about retention ====
 +it seems node-red sets the retention flag of mqtt by default. I learned this when i used it together with the mqtt-dss-connector: i created a rule that turned the light in the bathroom on. if i turned it off later (not via node-red) and then restarted the mqtt-dss-bridge the light in my bathroom went on again "for no reason" .. this was because that on command was published with the retention flag set to on (or actually not set to anything in node-red). so i set it to "false" and the problem was resolved. 
 +
 ===== Making the installation permanent ===== ===== Making the installation permanent =====
 this might be different in your setup, but I would like to install the npm modules globally and then run them as non-root users through a systemd script to make sure they are auto-startet as soon as my system boots. this might be different in your setup, but I would like to install the npm modules globally and then run them as non-root users through a systemd script to make sure they are auto-startet as soon as my system boots.
  • sonoff.txt
  • Last modified: 07.09.2021 05:52
  • by Pascal Suter