Skip to content

Tasmota

ianmacs edited this page Dec 10, 2019 · 8 revisions

Avoid sending Wifi password over unencrypted connection

Option 1: compile password into firmware

The wifi password has to be compiled into the firmware to avoid sending it over the unencrypted open AP that newly flashed devices would start with otherwise. Instructions are here: https://github.com/arendst/Sonoff-Tasmota/wiki/PlatformIO. Git can be used to clone the Tasmota source. My changes are:

diff --git a/platformio.ini b/platformio.ini
index f4be6ad3..6e3b9279 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -11,7 +11,7 @@
 src_dir = sonoff
 
 ; *** Uncomment one of the lines below to build/upload only one environment
-;env_default = sonoff
+env_default = sonoff
 ;env_default = sonoff-minimal
 ;env_default = sonoff-basic
 ;env_default = sonoff-classic
@@ -129,12 +129,12 @@ build_flags               = ${esp82xx_defaults.build_flags}
 
 [core_active]
 ; Select one core set for platform and build_flags
-platform                  = ${core_2_3_0.platform}
-build_flags               = ${core_2_3_0.build_flags}
+;platform                  = ${core_2_3_0.platform}
+;build_flags               = ${core_2_3_0.build_flags}
 ;platform                  = ${core_2_4_2.platform}
 ;build_flags               = ${core_2_4_2.build_flags}
-;platform                  = ${core_2_5_2.platform}
-;build_flags               = ${core_2_5_2.build_flags}
+platform                  = ${core_2_5_2.platform}
+build_flags               = ${core_2_5_2.build_flags}
 ;platform                  = ${core_stage.platform}
 ;build_flags               = ${core_stage.build_flags}
 
@@ -165,7 +165,7 @@ upload_speed              = 115200
 upload_resetmethod        = nodemcu
 
 ; *** Upload Serial reset method for Wemos and NodeMCU
-upload_port               = COM5
+upload_port               = /dev/ttyUSB0
 extra_scripts             = pio/strip-floats.py
 
 ; *** Upload file to OTA server using SCP
diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h
index 5c692ee9..f902f2da 100644
--- a/sonoff/my_user_config.h
+++ b/sonoff/my_user_config.h
@@ -47,7 +47,7 @@
 #define CFG_HOLDER             4617              // [Reset 1] Change this value (max 32000) to load SECTION1 configuration parameters to flash
 
 // -- Project -------------------------------------
-#define PROJECT                "sonoff"          // PROJECT is used as the default topic delimiter
+#error define PROJECT                "u-purpose"        // PROJECT is used as the default topic delimiter
 
 // If not selected the default will be SONOFF_BASIC
 //#define MODULE                 SONOFF_BASIC      // [Module] Select default model from sonoff_template.h
@@ -62,8 +62,8 @@
 #define WIFI_SUBNETMASK        "255.255.255.0"   // [IpAddress3] If not using DHCP set Network mask
 #define WIFI_DNS               "192.168.1.1"     // [IpAddress4] If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY)
 
-#define STA_SSID1              ""                // [Ssid1] Wifi SSID
-#define STA_PASS1              ""                // [Password1] Wifi password
+#error define STA_SSID1              "WifiSSID"                // [Ssid1] Wifi SSID
+#error define STA_PASS1              "WifiPassword"                // [Password1] Wifi password
 #define STA_SSID2              ""                // [Ssid2] Optional alternate AP Wifi SSID
 #define STA_PASS2              ""                // [Password2] Optional alternate AP Wifi password
 #define WIFI_CONFIG_TOOL       WIFI_RETRY        // [WifiConfig] Default tool if wifi fails to connect
@@ -87,12 +87,12 @@
 // -- MQTT ----------------------------------------
 #define MQTT_USE               1                 // [SetOption3] Select default MQTT use (0 = Off, 1 = On)
 
-#define MQTT_HOST              ""                // [MqttHost]
+#define MQTT_HOST              "openhab.fritz.box"                // [MqttHost]
 #define MQTT_FINGERPRINT1      "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"  // [MqttFingerprint1]
 #define MQTT_FINGERPRINT2      "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07"  // [MqttFingerprint2]
 #define MQTT_PORT              1883              // [MqttPort] MQTT port (10123 on CloudMQTT)
-#define MQTT_USER              "DVES_USER"       // [MqttUser] MQTT user
-#define MQTT_PASS              "DVES_PASS"       // [MqttPassword] MQTT password
+#error define MQTT_USER              "mqttusername"       // [MqttUser] MQTT user
+#error define MQTT_PASS              "mqttpassword"       // [MqttPassword] MQTT password
 
 #define MQTT_BUTTON_RETAIN     0                 // [ButtonRetain] Button may send retain flag (0 = off, 1 = on)
 #define MQTT_POWER_RETAIN      0                 // [PowerRetain] Power status message may send retain flag (0 = off, 1 = on)
@@ -180,8 +180,8 @@
 #define TIME_STD_OFFSET        +60               // Offset from UTC in minutes (-780 to +780)
 
 // -- Location ------------------------------------
-#define LATITUDE               48.858360         // [Latitude] Your location to be used with sunrise and sunset
-#define LONGITUDE              2.294442          // [Longitude] Your location to be used with sunrise and sunset
+#error define LATITUDE               54.18943          // [Latitude] Your location to be used with sunrise and sunset
+#error define LONGITUDE              7.212712          // [Longitude] Your location to be used with sunrise and sunset
 
 // -- Application ---------------------------------
 #define APP_TIMEZONE           1                 // [Timezone] +1 hour (Amsterdam) (-13 .. 14 = hours from UTC, 99 = use TIME_DST/TIME_STD)

except for the errors.

Option 2: Stepstone Wifi

  • Create temporary encrypted Wifi access point.
  • Configure new Tasmota device through initial open access point to use the temporary access point.
  • Configure new Tasmota device through temporary encrypted Wifi access point, replace data for temporary access point with regular Wifi credentials.
  • Remove temporary encrypted Wifi access point.

Configure new Tasmota devices

  • Wifi credentials + hostname
  • MQTT host, credentials and topic
  • Module
  • Find the new device in router,
    • reserve its IP address,
    • disallow internet access.
  • Issue commands (see https://github.com/arendst/Sonoff-Tasmota/wiki/Commands):
    • PowerOnState OFF
    • NtpServer1 fritz.box
    • NtpServer2 0
    • NtpServer3 0
    • TimeSTD
    • TimeDST
    • Timezone 99
    • WebPassword secret
    • Latitude
    • Longitude
    • Altitude
    • CurrentSet
    • VoltageSet
    • PowerSet

Configure Tasmota timers

To switch a light on at sunset and off again at midnight, configure timers in the web console:

timer1 {"Arm":1, "Mode":0, "Time":"00:00","Output":1,"Action":0,"Days":"1111111","Repeat":1}

(switch off relay 1 at wall clock time midnight each night)

timer2 {"Arm":1, "Mode":2, "Time":"00:00","Output":1,"Action":1,"Days":"1111111","Repeat":1}

(switch on relay 1 at sunset + 0 each night)