====== Relay tasmota ====== https://www.instructables.com/Tasmotized-NodeMCU-8CH-Sonoff-Relay/ ====== Headline ====== https://oneguyoneblog.com/2020/02/29/flashing-tasmota-on-sonoff-basic-r2-using-linux/ https://tasmota.github.io/docs/Upgrading/#migration-path LedState 0 time timezone timer sonoff ====== HTTP ====== http://10.11.13.162/cm?cmnd=status%2010 * only with urllib import urllib.request contents = urllib.request.urlopen("http://10.11.13.162/cm?cmnd=status%2010").read() * with json + urllib import json import urllib.request urlData = "http://10.11.13.162/cm?cmnd=status%2010" webURL = urllib.request.urlopen(urlData) data = webURL.read() encoding = webURL.info().get_content_charset('utf-8') json.loads(data.decode(encoding)) th16 = json.loads(data.decode(encoding)) >>> type(th16) TEMPDS18B20 = th16["StatusSNS"]["DS18B20"]["Temperature"] TEMPDHT11 = th16["StatusSNS"]["DHT11"]["Temperature"] HUMDHT11 = th16["StatusSNS"]["DHT11"]["Humidity"] * function #!/usr/bin/env python3 import json import urllib.request urlData = "http://10.11.13.162/cm?cmnd=status%2010" def get_temp(): webURL = urllib.request.urlopen(urlData) data = webURL.read() encoding = webURL.info().get_content_charset('utf-8') th16 = json.loads(data.decode(encoding)) TEMPDS18B20 = th16["StatusSNS"]["DS18B20"]["Temperature"] TEMPDHT11 = th16["StatusSNS"]["DHT11"]["Temperature"] HUMDHT11 = th16["StatusSNS"]["DHT11"]["Humidity"] #print(TEMPDS18B20) #print(TEMPDHT11) #print(TEMPDHT11) return TEMPDS18B20 #return TEMPDHT11 #return HUMDHT11 get_temp() import json import urllib.request urlData = "http://10.11.13.162/cm?cmnd=status%2010" def get_temp(): webURL = urllib.request.urlopen(urlData) data = webURL.read() encoding = webURL.info().get_content_charset('utf-8') th16 = json.loads(data.decode(encoding)) TEMPDS18B20 = th16["StatusSNS"]["DS18B20"]["Temperature"] return TEMPDS18B20 get_temp() https://electronicshobbyists.com/raspberry-pi-sending-data-to-thingspeak-simplest-raspberry-pi-iot-project/ ====== TH16 things speak ====== #!/usr/bin/env python3 import sys import json import urllib from urllib import request from time import sleep urlData = "http://10.11.13.162/cm?cmnd=status%2010" # Enter Your API key here myAPI = '2NHTXFEKINQP5ZGN' # URL where we will send the data, Don't change it baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI def get_temp(): webURL = urllib.request.urlopen(urlData) data = webURL.read() encoding = webURL.info().get_content_charset('utf-8') th16 = json.loads(data.decode(encoding)) TEMPDHT11 = th16["StatusSNS"]["DHT11"]["Temperature"] HUMDHT11 = th16["StatusSNS"]["DHT11"]["Humidity"] return TEMPDHT11, HUMDHT11 while True: try: HUMDHT11, TEMPDHT11 = get_temp() # If Reading is valid if isinstance(HUMDHT11, float) and isinstance(TEMPDHT11, float): # Formatting to two decimal places HUMDHT11 = '%.2f' % HUMDHT11 TEMPDHT11 = '%.2f' % TEMPDHT11 # Sending the data to thingspeak conn = request.urlopen(baseURL + '&field1=%s&field2=%s' % (TEMPDHT11, HUMDHT11)) #print(conn.read()) # Closing the connection conn.close() else: print('Error') # DHT22 requires 2 seconds to give a reading, so make sure to add delay of above 2 seconds. sleep(20) except: break ====== bash temperature ====== temperatur=$(curl -s "http://10.11.13.162/cm?[user=admin&password=joker&]cmnd=status%2010") #Beispiel von meinem TH10 #!/bin/bash temperatur=$(curl -s "http://10.11.13.162/cm?cmnd=status%2010"); wert1=$(echo $temperatur | jq ".[].DHT11.Temperature"); wert2=$(echo $temperatur | jq ".[].DS18B20.Temperature"); wert3=$(echo $temperatur | jq ".[].DHT11.Humidity"); echo "Temperatur ist: "$wert1; echo "Temperatur ist: "$wert2; echo "Humidity ist: "$wert3; #Mögliche Fortsetzung (Prinzip) #Wenn $wert <15 dann Heizung an ( if ... then ... else) ====== Tasmota mini ====== https://forum.creationx.de/forum/index.php?thread/2373-sonoff-mini-wird-beim-flashen-nicht-erkannt/ https://dm1cr.de/sonoff-mini-r2-tasmotizing-und-einbau https://tasmota.github.io/docs/devices/Sonoff-Mini/ https://github.com/itead/Sonoff_Devices_DIY_Tools/issues/103 * flashing https://community.home-assistant.io/t/solved-sonoff-mini-no-diy-jumper-pins-on-board-and-no-clue-how-to-tasmotize-it/242748/6 13:08:26.574571 IP ESP_10ACD9.lan.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR eWeLink_1001040222._ewelink._tcp.local., (Cache flush) TXT "txtvers=1" "id=1001040222" "type=diy_plug" "apivers=1" "seq=1" "data1={"switch":"off","startup":"off","pulse":"off","fwVersion":"3.6.0","pulseWidth":500,"rssi":-77}", (Cache flush) SRV eWeLink_1001040222.local.:8081 0 0, (Cache flush) A 10.11.13.148 (353) * DIY mode https://tasmota.github.io/docs/Sonoff-DIY/ what you do is this: 1) Pair the device with the eWeLink app and update firmware. The wifi network you connect to during this step will need to be reachable in order to enter DIY mode. 2) Follow instructions how to enter DIY mode from Sonoff. This is the excerpt from it: a) Long press the button for 5 seconds to enter pairing mode, then press another 5 seconds to ender Compatible Pairing Mode (AP). The LED indicator should blink continuously. b) From mobile phone or PC WiFi setting, an Access Point of the device named ITEAD-XXXXXXXX will be found, connect it with default password 12345678 c) Open the browser and access http://10.10.7.1/ d) Next, Fill in WiFi SSID and password. Once successfully connected, the device is in DIY mode. Note: I needed to manually change IP address to 10.10.7.2, 255.0.0.0 with gateway 10.10.7.1 in adapter TCP/IPv4 settings to access that IP address. 3.1) Use Fing or any similar local network scanning app on your smartphone or PC to find IP address of your Sonoff Mini device. MAC Vendor most likely is Espressif and the device has 8081 port open. 3.2) Check that diy mode is working properly. https://delightnet.nl/index.php/sonoff/13-how-to-flash-sonoff-mini-with-tasmota-firmware curl -XPOST --header "Content-Type: application/json" --data-raw '{"1001040222": "", "data": {}}' http://10.11.13.148:8081/zeroconf/info https://nerdiy.de/en/tasmota-nachlaufen-eines-relais-einstellen/