2018-05-19 16:31:55 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
2019-10-27 11:04:08 +00:00
|
|
|
decode-status.py - decode status for Tasmota
|
2018-05-19 16:31:55 +01:00
|
|
|
|
2021-01-01 12:57:04 +00:00
|
|
|
Copyright (C) 2021 Theo Arends
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Requirements:
|
|
|
|
- Python
|
2020-07-04 16:39:56 +01:00
|
|
|
- pip json requests
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
Instructions:
|
|
|
|
Execute command with option -d to retrieve status report from device or
|
|
|
|
get a copy of the status message with http command http://sonoff/cm?cmnd=status%200
|
|
|
|
and store it in file status.json
|
|
|
|
|
|
|
|
Usage:
|
2018-09-14 15:39:06 +01:00
|
|
|
./decode-status.py -d <hostname or IP address> [-u username] [-p password]
|
2018-05-19 16:31:55 +01:00
|
|
|
or
|
|
|
|
./decode-status.py -f <JSON status information file>
|
|
|
|
|
|
|
|
Example:
|
|
|
|
./decode-status.py -d sonoff1
|
2018-09-14 15:39:06 +01:00
|
|
|
./decode-status.py -d sonoff1 -p 12345678
|
2018-05-19 16:31:55 +01:00
|
|
|
or
|
|
|
|
./decode-status.py -f status.json
|
|
|
|
"""
|
|
|
|
|
|
|
|
import io
|
|
|
|
import os.path
|
|
|
|
import json
|
2020-07-04 16:39:56 +01:00
|
|
|
import requests
|
|
|
|
import urllib
|
2018-05-19 16:31:55 +01:00
|
|
|
from sys import exit
|
|
|
|
from optparse import OptionParser
|
|
|
|
|
|
|
|
a_on_off = ["OFF","ON "]
|
|
|
|
|
2018-07-25 11:42:53 +01:00
|
|
|
a_setoption = [[
|
2020-11-29 14:59:40 +00:00
|
|
|
"(Settings) Save power state (1) and use after restart",
|
|
|
|
"(Button) Control button single press (1) or multipress (0)",
|
2021-09-01 08:42:10 +01:00
|
|
|
"(MQTT) Add global temperature/humidity/pressure info to JSON sensor message",
|
2020-11-29 14:59:40 +00:00
|
|
|
"(MQTT) Enable (1)",
|
|
|
|
"(MQTT) Switch between RESULT (0) or COMMAND (1)",
|
|
|
|
"(MQTT) Retain on Power",
|
|
|
|
"(MQTT) Retain on Button",
|
|
|
|
"(MQTT) Retain on Switch",
|
|
|
|
"(Temperature) Switch between Celsius (0) or Fahrenheit (1)",
|
|
|
|
"(MQTT) Retain on Sensor",
|
|
|
|
"(MQTT) Control LWT message format, Offline (1) or none (0)",
|
|
|
|
"(Button) Swap (1) button single and double press functionality",
|
|
|
|
"(Settings) Switch between dynamic (0) or fixed (1) slot flash save location",
|
|
|
|
"(Button) Support only single press (1) to speed up button press recognition",
|
|
|
|
"(Interlock) Power interlock mode",
|
|
|
|
"(Light) Switch between commands PWM (1) or COLOR/DIMMER/CT/CHANNEL (0)",
|
|
|
|
"(WS2812) Switch between clockwise (0) or counter-clockwise (1)",
|
|
|
|
"(Light) Switch between decimal (1) or hexadecimal (0) output",
|
|
|
|
"(Light) Pair light signal (1) with CO2 sensor",
|
|
|
|
"(HAss) Control automatic discovery (1) (See SetOption59)",
|
|
|
|
"(Light) Control power in relation to Dimmer/Color/Ct changes (1)",
|
|
|
|
"(Energy) Show voltage even if powered off (1)",
|
|
|
|
"(MQTT) Serial",
|
|
|
|
"(MQTT) Serial binary",
|
|
|
|
"(Pressure) switch between hPa (0)or mmHg (1) unit",
|
|
|
|
"(KNX) Enabled",
|
|
|
|
"(MQTT, HAss) Switch between POWER (0) or POWER1 (1)",
|
|
|
|
"(KNX) Enhancement",
|
|
|
|
"(RF) Receive data format hexadecimal (0) or decimal (1)",
|
|
|
|
"(IR) Receive data format hexadecimal (0) or decimal (1)",
|
|
|
|
"(HAss) enforce autodiscovery as light (1)",
|
|
|
|
"(Wifi, MQTT) Control link led blinking (1)"
|
2018-07-25 11:42:53 +01:00
|
|
|
],[
|
2020-11-29 14:59:40 +00:00
|
|
|
"(Button) Key hold time (ms)",
|
|
|
|
"(Pow) Sonoff POW Max_Power_Retry",
|
|
|
|
"(Backlog) Delay (ms)",
|
2019-02-04 10:41:51 +00:00
|
|
|
"(not used) mDNS delayed start (Sec)",
|
2020-11-29 14:59:40 +00:00
|
|
|
"(Boot loop) Retry offset (0 = disable)",
|
|
|
|
"(Light) RGBWW remap",
|
|
|
|
"(IR) Unknown threshold",
|
|
|
|
"(CSE7766) invalid power margin",
|
|
|
|
"(Button) Ignore hold time (s)",
|
|
|
|
"(Wifi) Gratuitous ARP repeat time",
|
|
|
|
"(Temperature) Over temperature threshold (celsius)",
|
2021-01-11 13:13:20 +00:00
|
|
|
"(Rotary) Max allowed steps",
|
2019-09-08 10:26:54 +01:00
|
|
|
"(not used) Tuya MCU voltage Id",
|
|
|
|
"(not used) Tuya MCU current Id",
|
|
|
|
"(not used) Tuya MCU power Id",
|
2019-10-31 11:12:48 +00:00
|
|
|
"(not used) Energy Tariff1 start hour",
|
|
|
|
"(not used) Energy Tariff2 start hour",
|
2019-08-01 14:42:58 +01:00
|
|
|
"",
|
2019-02-04 00:04:42 +00:00
|
|
|
],[
|
2020-11-29 14:59:40 +00:00
|
|
|
"(Timers) Enabled",
|
|
|
|
"(GPIO) Enable ESP8285 user GPIO's (1)",
|
|
|
|
"(Time) Append timezone to JSON time (1)",
|
|
|
|
"(GUI) Show hostname and IP address in GUI main menu (1)",
|
|
|
|
"(Tuya) Apply SetOption20 settings to Tuya device (1)",
|
|
|
|
"(mDNS) Service on (1) or off (0)",
|
|
|
|
"(Wifi) Scan network at restart for configured AP's (1) or used stored AP (0)",
|
|
|
|
"(Wifi) Scan network every 44 minutes for configured AP's (1)",
|
|
|
|
"(IR) Add IR Raw data to JSON message (1)",
|
|
|
|
"(MQTT) Send tele/%topic%/STATE in addition to stat/%topic%/RESULT (1)",
|
|
|
|
"(Sleep) Enable normal sleep (1) instead of dynamic sleep (0)",
|
|
|
|
"(Button, Switch) Force local operation (1) when button/switch topic is set",
|
|
|
|
"(MQTT) Don't use retain flag on HOLD messages (1)",
|
|
|
|
"(Power) Don't scan relay power state at restart (1)",
|
|
|
|
"(JSON) Enable '_' (1) instead of '-' (0) as sensor index separator",
|
|
|
|
"(QPC) Disable (1) fast power cycle detection for device reset",
|
|
|
|
"(Tuya) Enable (1) TuyaMcuReceived messages over Mqtt",
|
|
|
|
"(Buzzer) Enable (1) buzzer when available",
|
|
|
|
"(Light) Enable multi-channels PWM (1) instead of Color PWM (0)",
|
|
|
|
"(not used) Limits Tuya dimmers to minimum of 10% (25) when enabled",
|
|
|
|
"(Energy) Enable Weekend Energy Tariff",
|
|
|
|
"(DDS2382) Select different Modbus registers (1) for Active Energy (#6531)",
|
|
|
|
"(Energy) Enable (1) hardware energy total counter as reference (#6561)",
|
|
|
|
"(Button) Detach buttons from relays (1) and enable MQTT action state for multipress",
|
|
|
|
"(DS18x20) Enable internal pullup (1) for single DS18x20 sensor",
|
|
|
|
"(MQTT) GroupTopic replaces %topic% (0) or fixed topic cmnd/grouptopic (1)",
|
|
|
|
"(Deepsleep) Enable incrementing bootcount (1) when deepsleep is enabled",
|
|
|
|
"(Light) Do not power off (1) if slider moved to far left",
|
|
|
|
"(not used) Disable OTA compatibility check",
|
|
|
|
"(Counter) Enable resetting of counters (1) after telemetry was sent",
|
|
|
|
"(Shutter) Enable shutter support (1)",
|
|
|
|
"(PCF8574) Invert all ports on PCF8574 devices (1)"
|
2019-10-31 11:12:48 +00:00
|
|
|
],[
|
2020-11-29 14:59:40 +00:00
|
|
|
"(Alexa) Reduced CT range for Alexa (1)",
|
|
|
|
"(Zigbee) Use FriendlyNames (1) instead of ShortAddresses (0) when possible",
|
|
|
|
"(AWS IoT) publish MQTT state to a device shadow (1)",
|
|
|
|
"(DevGroups) Enable Device Groups (1)",
|
|
|
|
"(PWM Dimmer) Turn brightness LED's off (1) 5 seconds after last change",
|
|
|
|
"(PWM Dimmer) Turn red LED on (1) when powered off",
|
|
|
|
"(DevGroups) Enable relays in separate device groups/PWM Dimmer Buttons control remote devices (1)",
|
|
|
|
"(MQTT, Zigbee) Distinct MQTT topics per device for Zigbee (1) (#7835)",
|
|
|
|
"(MQTT) Disable non-json MQTT response (1)",
|
|
|
|
"(Light) Enable light fading at start/power on (1)",
|
|
|
|
"(Light) Set PWM Mode from regular PWM (0) to ColorTemp (1) control (Xiaomi Philips ...)",
|
|
|
|
"(Compress) Keep uncompressed rules in memory to avoid CPU load of uncompressing at each tick (1)",
|
|
|
|
"(MAXxxx) Implement simpler MAX6675 protocol (1) instead of MAX31855 (0)",
|
|
|
|
"(Wifi) Enable Wifi",
|
|
|
|
"(Eth) Enable Ethernet (ESP32)",
|
|
|
|
"(Tuya) Set Baud rate for TuyaMCU serial communication to 9600 (0) or 115200 (1)",
|
|
|
|
"(Rotary) Use rules (1) instead of light control (0)",
|
|
|
|
"(PWM Dimmer) Enable zerocross dimmer (1)",
|
|
|
|
"(Zigbee) Remove ZbReceived form JSON message (1)",
|
|
|
|
"(Zigbee) Add the source endpoint as suffix to attributes, ex `Power3` (1) instead of `Power` (0) if sent from endpoint 3",
|
|
|
|
"(Teleinfo) Set Baud rate for Teleinfo communication to 1200 (0) or 9600 (1)",
|
|
|
|
"(MQTT TLS) Enable TLS mode (1) (requires TLS version)",
|
|
|
|
"(MQTT) No Retain (1) - disable all MQTT retained messages, some brokers don't support it: AWS IoT, Losant",
|
|
|
|
"(Light) White Blend Mode (1) - used to be `RGBWWTable` last value `0`, now deprecated in favor of this option",
|
|
|
|
"(Light) Virtual CT (1) - Creates a virtual White ColorTemp for RGBW lights",
|
|
|
|
"(Light) Virtual CT Channel (1) - signals whether the hardware white is cold CW (true) or warm WW (false)",
|
|
|
|
"(Teleinfo) Enable Teleinfo + Tasmota Energy device (0) or Teleinfo raw data only (1)",
|
|
|
|
"(Alexa) Gen1 mode (1) - if you only have Echo Dot 2nd gen devices",
|
|
|
|
"(Zigbee) Disable auto-config (1) when pairing new devices",
|
|
|
|
"(Buzzer) Use frequency output (1) for buzzer pin instead of on/off signal (0)",
|
|
|
|
"(Zigbee) Use friendly name in zigbee topic (1) (use with SetOption89)",
|
|
|
|
"(Rotary) Set dimmer low on rotary dial after power off (1)"
|
2020-08-13 15:59:51 +01:00
|
|
|
],[
|
2020-11-29 14:59:40 +00:00
|
|
|
"(Switch) Detach Switches from relays and enable MQTT action state for all the SwitchModes (1)",
|
|
|
|
"(ESP32 BLE) Enable ESP32 MI32 BLE (1)",
|
|
|
|
"(Zigbee) Disable auto-query of zigbee lights and devices (1)",
|
2021-01-03 16:04:14 +00:00
|
|
|
"(Light) run fading at fixed duration instead of fixed slew rate",
|
|
|
|
"(Zigbee) Move ZbReceived from JSON message and into the subtopic replacing SENSOR default",
|
|
|
|
"(Zigbee) Remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic",
|
2021-02-22 12:59:45 +00:00
|
|
|
"(Zigbee) Append endpoint number to topic if device dependent (use with SetOption89)",
|
|
|
|
"(MQTT) Retain on State",
|
|
|
|
"(MQTT) Retain on Info",
|
2021-03-23 11:57:56 +00:00
|
|
|
"(Wiegand) switch tag number output to hex format (1)",
|
|
|
|
"(Wiegand) send key pad stroke as single char (0) or one tag (ending char #) (1)",
|
|
|
|
"(Zigbee) Hide bridge topic from zigbee topic (use with SetOption89) (1)",
|
2021-04-02 10:43:31 +01:00
|
|
|
"(DS18x20) Enable arithmetic mean over teleperiod for JSON temperature (1)",
|
2021-07-05 13:50:33 +01:00
|
|
|
"(Wifi) Keep wifi in no-sleep mode, prevents some occasional unresponsiveness",
|
2021-10-08 12:59:11 +01:00
|
|
|
"(Web) Allow access without referer check",
|
|
|
|
"(Energy) Show phase information",
|
|
|
|
"(Debug) Show heap with logging timestamp",
|
2021-11-30 15:03:57 +00:00
|
|
|
"(Tuya) Allow save dimmer = 0 receved by MCU",
|
2021-12-05 13:49:49 +00:00
|
|
|
"(TLS) Use fingerprint validation instead of CA based",
|
|
|
|
"(Shift595) Invert outputs of 74x595 shift registers",
|
2022-03-25 15:27:57 +00:00
|
|
|
"(PWM) force PWM lights to start at same phase, default is to spread phases to minimze overlap (also needed for H-bridge)",
|
|
|
|
"(Display & LVGL) force disabling default splash screen",
|
|
|
|
"(TuyaSNS) When ON disable publish single SNS value on Tuya Receive (keep Teleperiod)",
|
2022-04-02 10:43:29 +01:00
|
|
|
"(Tuya) When Set, avoid the (mqtt-) publish of Tuya MCU Heartbeat response if SetOption66 is active",
|
2022-04-19 13:45:26 +01:00
|
|
|
"(GUI) Align (energy) table values left (0) or right (1)",
|
|
|
|
"(Pressure) Switch between mmHg (0) or inHg (1) when SO24 1",
|
2022-05-04 14:34:26 +01:00
|
|
|
"(MQTT) MQTT clean session (0 = default) or persistent session (1)",
|
2022-05-29 14:49:57 +01:00
|
|
|
"(GUI) Disable display of GUI module name (1)",
|
|
|
|
"","","",""
|
|
|
|
],[
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
2020-08-13 15:59:51 +01:00
|
|
|
"","","",""
|
2018-07-25 11:42:53 +01:00
|
|
|
]]
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
a_features = [[
|
2019-08-01 14:42:58 +01:00
|
|
|
"USE_ENERGY_MARGIN_DETECTION","USE_LIGHT","USE_I2C","USE_SPI",
|
2018-05-19 16:31:55 +01:00
|
|
|
"USE_DISCOVERY","USE_ARDUINO_OTA","USE_MQTT_TLS","USE_WEBSERVER",
|
2019-05-20 14:09:42 +01:00
|
|
|
"WEBSERVER_ADVERTISE","USE_EMULATION_HUE","MQTT_PUBSUBCLIENT","MQTT_TASMOTAMQTT",
|
2018-05-19 16:31:55 +01:00
|
|
|
"MQTT_ESPMQTTARDUINO","MQTT_HOST_DISCOVERY","USE_ARILUX_RF","USE_WS2812",
|
|
|
|
"USE_WS2812_DMA","USE_IR_REMOTE","USE_IR_HVAC","USE_IR_RECEIVE",
|
|
|
|
"USE_DOMOTICZ","USE_DISPLAY","USE_HOME_ASSISTANT","USE_SERIAL_BRIDGE",
|
|
|
|
"USE_TIMERS","USE_SUNRISE","USE_TIMERS_WEB","USE_RULES",
|
2019-08-01 14:42:58 +01:00
|
|
|
"USE_KNX","USE_WPS","USE_SMARTCONFIG","USE_ENERGY_POWER_LIMIT"
|
2018-06-26 10:38:30 +01:00
|
|
|
],[
|
2019-02-08 13:55:45 +00:00
|
|
|
"USE_CONFIG_OVERRIDE","FIRMWARE_MINIMAL","FIRMWARE_SENSORS","FIRMWARE_CLASSIC",
|
|
|
|
"FIRMWARE_KNX_NO_EMULATION","USE_DISPLAY_MODES1TO5","USE_DISPLAY_GRAPH","USE_DISPLAY_LCD",
|
2022-01-13 20:38:56 +00:00
|
|
|
"USE_DISPLAY_SSD1306","USE_DISPLAY_MATRIX","USE_DISPLAY_ILI9341","USE_DISPLAY_EPAPER_29",
|
|
|
|
"USE_DISPLAY_SH1106","USE_MP3_PLAYER","USE_PCA9685","USE_TUYA_MCU",
|
2019-05-20 14:09:42 +01:00
|
|
|
"USE_RC_SWITCH","USE_ARMTRONIX_DIMMERS","USE_SM16716","USE_SCRIPT",
|
2019-08-10 16:52:26 +01:00
|
|
|
"USE_EMULATION_WEMO","USE_SONOFF_IFAN","USE_ZIGBEE","NO_EXTRA_4K_HEAP",
|
2018-09-09 13:31:40 +01:00
|
|
|
"VTABLES_IN_IRAM","VTABLES_IN_DRAM","VTABLES_IN_FLASH","PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH",
|
2018-06-26 10:38:30 +01:00
|
|
|
"PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY","PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH","DEBUG_THEO","USE_DEBUG_DRIVER"
|
|
|
|
],[
|
2019-08-01 14:42:58 +01:00
|
|
|
"USE_COUNTER","USE_ADC_VCC","USE_ENERGY_SENSOR","USE_PZEM004T",
|
2018-05-19 16:31:55 +01:00
|
|
|
"USE_DS18B20","USE_DS18x20_LEGACY","USE_DS18x20","USE_DHT",
|
2022-01-19 16:05:39 +00:00
|
|
|
"USE_SHT","USE_HTU","USE_BMP","USE_BME68X",
|
2018-05-19 16:31:55 +01:00
|
|
|
"USE_BH1750","USE_VEML6070","USE_ADS1115_I2CDEV","USE_ADS1115",
|
|
|
|
"USE_INA219","USE_SHT3X","USE_MHZ19","USE_TSL2561",
|
|
|
|
"USE_SENSEAIR","USE_PMS5003","USE_MGS","USE_NOVA_SDS",
|
|
|
|
"USE_SGP30","USE_SR04","USE_SDM120","USE_SI1145",
|
2018-06-29 10:15:27 +01:00
|
|
|
"USE_SDM630","USE_LM75AD","USE_APDS9960","USE_TM1638"
|
2018-06-26 10:38:30 +01:00
|
|
|
],[
|
2018-07-31 10:49:23 +01:00
|
|
|
"USE_MCP230xx","USE_MPR121","USE_CCS811","USE_MPU6050",
|
2018-09-06 17:08:10 +01:00
|
|
|
"USE_MCP230xx_OUTPUT","USE_MCP230xx_DISPLAYOUTPUT","USE_HLW8012","USE_CSE7766",
|
2018-10-17 11:27:05 +01:00
|
|
|
"USE_MCP39F501","USE_PZEM_AC","USE_DS3231","USE_HX711",
|
2018-12-11 13:24:52 +00:00
|
|
|
"USE_PZEM_DC","USE_TX20_WIND_SENSOR","USE_MGC3130","USE_RF_SENSOR",
|
2019-01-01 12:45:44 +00:00
|
|
|
"USE_THEO_V2","USE_ALECTO_V2","USE_AZ7798","USE_MAX31855",
|
2022-01-13 20:38:56 +00:00
|
|
|
"USE_PN532_HSU","USE_MAX44009","USE_SCD30","USE_HRE",
|
2019-08-01 14:42:58 +01:00
|
|
|
"USE_ADE7953","USE_SPS30","USE_VL53L0X","USE_MLX90614",
|
2019-08-19 10:47:59 +01:00
|
|
|
"USE_MAX31865","USE_CHIRP","USE_SOLAX_X1","USE_PAJ7620"
|
2019-08-10 16:52:26 +01:00
|
|
|
],[
|
2019-09-08 10:26:54 +01:00
|
|
|
"USE_BUZZER","USE_RDM6300","USE_IBEACON","USE_SML_M",
|
2019-10-17 14:28:46 +01:00
|
|
|
"USE_INA226","USE_A4988_STEPPER","USE_DDS2382","USE_SM2135",
|
2019-10-14 16:01:24 +01:00
|
|
|
"USE_SHUTTER","USE_PCF8574","USE_DDSU666","USE_DEEPSLEEP",
|
2019-10-18 16:29:19 +01:00
|
|
|
"USE_SONOFF_SC","USE_SONOFF_RF","USE_SONOFF_L1","USE_EXS_DIMMER",
|
2022-01-13 20:38:56 +00:00
|
|
|
"USE_TASMOTA_CLIENT","USE_HIH6","USE_HPMA","USE_TSL2591",
|
2019-12-30 13:24:00 +00:00
|
|
|
"USE_DHT12","USE_DS1624","USE_GPS","USE_HOTPLUG",
|
2020-02-10 14:18:11 +00:00
|
|
|
"USE_NRF24","USE_MIBLE","USE_HM10","USE_LE01MR",
|
2020-02-27 14:10:42 +00:00
|
|
|
"USE_AHT1x","USE_WEMOS_MOTOR_V1","USE_DEVICE_GROUPS","USE_PWM_DIMMER"
|
2020-02-10 14:18:11 +00:00
|
|
|
],[
|
2020-03-14 11:43:02 +00:00
|
|
|
"USE_KEELOQ","USE_HRXL","USE_SONOFF_D1","USE_HDC1080",
|
2020-04-11 13:51:08 +01:00
|
|
|
"USE_IAQ","USE_DISPLAY_SEVENSEG","USE_AS3935","USE_PING",
|
2020-05-22 14:16:01 +01:00
|
|
|
"USE_WINDMETER","USE_OPENTHERM","USE_THERMOSTAT","USE_VEML6075",
|
2021-09-21 17:25:52 +01:00
|
|
|
"USE_VEML7700","USE_MCP9808","USE_BL09XX","USE_TELEGRAM",
|
2020-06-17 16:22:41 +01:00
|
|
|
"USE_HP303B","USE_TCP_BRIDGE","USE_TELEINFO","USE_LMT01",
|
2020-09-06 17:41:39 +01:00
|
|
|
"USE_PROMETHEUS","USE_IEM3000","USE_DYP","USE_I2S_AUDIO",
|
2020-10-02 15:37:43 +01:00
|
|
|
"USE_MLX90640","USE_VL53L1X","USE_MIEL_HVAC","USE_WE517",
|
2020-10-18 14:36:17 +01:00
|
|
|
"USE_EZOPH","USE_TTGO_WATCH","USE_ETHERNET","USE_WEBCAM"
|
2020-08-17 15:25:24 +01:00
|
|
|
],[
|
2020-10-24 11:41:08 +01:00
|
|
|
"USE_EZOORP","USE_EZORTD","USE_EZOHUM","USE_EZOEC",
|
2020-11-01 14:15:10 +00:00
|
|
|
"USE_EZOCO2","USE_EZOO2","USE_EZOPRS","USE_EZOFLO",
|
2020-11-10 14:04:45 +00:00
|
|
|
"USE_EZODO","USE_EZORGB","USE_EZOPMP","USE_AS608",
|
2021-01-01 14:05:58 +00:00
|
|
|
"USE_SHELLY_DIMMER","USE_RC522","USE_FTC532","USE_DISPLAY_EPAPER_42",
|
|
|
|
"USE_DISPLAY_ILI9488","USE_DISPLAY_SSD1351","USE_DISPLAY_RA8876","USE_DISPLAY_ST7789",
|
2021-01-07 14:12:07 +00:00
|
|
|
"USE_DISPLAY_SSD1331","USE_UFILESYS","USE_TIMEPROP","USE_PID",
|
2021-01-20 14:06:27 +00:00
|
|
|
"USE_BS814A2","USE_SEESAW_SOIL","USE_WIEGAND","USE_NEOPOOL",
|
2021-02-27 21:28:29 +00:00
|
|
|
"USE_TOF10120","USE_SDM72","USE_DISPLAY_TM1637","USE_PROJECTOR_CTRL"
|
2021-01-22 16:15:58 +00:00
|
|
|
],[
|
2021-06-27 12:53:19 +01:00
|
|
|
"USE_MPU_ACCEL","USE_TFMINIPLUS","USE_CSE7761","USE_BERRY",
|
2021-07-13 10:40:13 +01:00
|
|
|
"USE_BM8563","USE_ENERGY_DUMMY","USE_AM2320","USE_T67XX",
|
2021-08-12 21:43:53 +01:00
|
|
|
"USE_MCP2515","USE_TASMESH","USE_WIFI_RANGE_EXTENDER","USE_INFLUXDB",
|
2021-10-08 12:59:11 +01:00
|
|
|
"USE_HRG15","USE_VINDRIKTNING","USE_SCD40","USE_HM330X",
|
2021-12-05 13:49:49 +00:00
|
|
|
"USE_HDC2010","USE_LSC_MCSL","USE_SONOFF_SPM","USE_SHIFT595",
|
2022-03-11 15:54:57 +00:00
|
|
|
"USE_SDM230","USE_CM110x","USE_BL6523","USE_ADE7880",
|
2022-05-04 14:34:26 +01:00
|
|
|
"USE_PCF85363","USE_DS3502","USE_IMPROV","USE_FLOWRATEMETER",
|
2021-01-22 16:15:58 +00:00
|
|
|
"","","",""
|
2022-05-29 14:49:57 +01:00
|
|
|
],[
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","",""
|
2019-08-10 16:52:26 +01:00
|
|
|
]]
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
usage = "usage: decode-status {-d | -f} arg"
|
|
|
|
parser = OptionParser(usage)
|
|
|
|
parser.add_option("-d", "--dev", action="store", type="string",
|
|
|
|
dest="device", help="device to retrieve status from")
|
2018-09-14 15:39:06 +01:00
|
|
|
parser.add_option("-u", "--username", action="store", type="string",
|
|
|
|
dest="username", help="username for login", default="admin")
|
|
|
|
parser.add_option("-p", "--password", action="store", type="string",
|
|
|
|
dest="password", help="password for login", default=None)
|
2018-05-19 16:31:55 +01:00
|
|
|
parser.add_option("-f", "--file", metavar="FILE",
|
|
|
|
dest="jsonfile", default="status.json", help="status json file (default: status.json)")
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
if (options.device):
|
2018-09-14 15:39:06 +01:00
|
|
|
loginstr = ""
|
|
|
|
if options.password is not None:
|
2020-07-04 16:39:56 +01:00
|
|
|
loginstr = "user={}&password={}&".format(urllib.parse.quote(options.username), urllib.parse.quote(options.password))
|
2018-09-14 15:39:06 +01:00
|
|
|
url = str("http://{}/cm?{}cmnd=status%200".format(options.device, loginstr))
|
2020-07-04 16:39:56 +01:00
|
|
|
res = requests.get(url)
|
|
|
|
obj = json.loads(res.content)
|
2018-05-19 16:31:55 +01:00
|
|
|
else:
|
|
|
|
jsonfile = options.jsonfile
|
2019-02-04 10:41:51 +00:00
|
|
|
with open(jsonfile, "r") as fp:
|
2019-02-04 00:04:42 +00:00
|
|
|
obj = json.load(fp)
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
def StartDecode():
|
2022-05-29 14:49:57 +01:00
|
|
|
print ("\n*** decode-status.py v11.1.0.3 by Theo Arends and Jacek Ziolkowski ***")
|
2018-07-25 11:42:53 +01:00
|
|
|
|
2018-05-19 16:31:55 +01:00
|
|
|
# print("Decoding\n{}".format(obj))
|
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if "StatusSNS" in obj:
|
|
|
|
if "Time" in obj["StatusSNS"]:
|
2018-07-17 15:07:03 +01:00
|
|
|
time = str(" from status report taken at {}".format(obj["StatusSNS"]["Time"]))
|
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if "Status" in obj:
|
|
|
|
if "FriendlyName" in obj["Status"]:
|
2018-07-25 11:42:53 +01:00
|
|
|
print("Decoding information for device {}{}".format(obj["Status"]["FriendlyName"][0], time))
|
2018-07-17 15:07:03 +01:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if "StatusLOG" in obj:
|
|
|
|
if "SetOption" in obj["StatusLOG"]:
|
2018-07-17 15:07:03 +01:00
|
|
|
options = []
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
i = 0
|
2019-02-04 10:41:51 +00:00
|
|
|
for r,opt_group in enumerate(a_setoption):
|
2019-02-04 00:04:42 +00:00
|
|
|
register = obj["StatusLOG"]["SetOption"][r]
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if r > 0 and len(obj["StatusLOG"]["SetOption"]) == 2: # old firmware: array consisted only of SetOptions 0..31 and resolution
|
2019-02-04 10:41:51 +00:00
|
|
|
break
|
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if r == 1:
|
|
|
|
if len(register) == 8: # pre 6.1.1.14: array consisted of SetOptions 0..31, resolution, and SetOptions 50..81
|
|
|
|
i += 18 # adjust option index and skip 2nd register
|
|
|
|
continue
|
2019-02-04 10:41:51 +00:00
|
|
|
|
|
|
|
elif len(register) == 36: # 6.1.1.14: array consists of SetOptions 0..31, SetOptions 32..49, and SetOptions 50..81
|
2020-08-13 15:59:51 +01:00
|
|
|
# 8.4.0.2: adds another SetOptions 114..145
|
2019-02-04 00:04:42 +00:00
|
|
|
split_register = [int(register[opt*2:opt*2+2],16) for opt in range(18)] # split register into 18 values
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
for opt_idx, option in enumerate(opt_group):
|
2020-11-29 14:59:40 +00:00
|
|
|
options.append(str("{0:3d} ({1:3d}) {2}".format(i, split_register[opt_idx], option)))
|
2019-02-04 00:04:42 +00:00
|
|
|
i += 1
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2022-05-29 14:49:57 +01:00
|
|
|
if r in (0, 2, 3, 4, 5): # register 1 holds binary values
|
2019-02-04 00:04:42 +00:00
|
|
|
for opt_idx, option in enumerate(opt_group):
|
2022-05-29 14:49:57 +01:00
|
|
|
if len(option) == 0:
|
|
|
|
continue # Skip empty line
|
2019-02-04 00:04:42 +00:00
|
|
|
i_register = int(register,16)
|
|
|
|
state = (i_register >> opt_idx) & 1
|
2020-11-29 14:59:40 +00:00
|
|
|
options.append(str("{0:3d} ({1}) {2}".format(i, a_on_off[state], option)))
|
2019-02-04 00:04:42 +00:00
|
|
|
i += 1
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2022-05-29 14:49:57 +01:00
|
|
|
if r >= len(obj["StatusLOG"]["SetOption"]) -1:
|
|
|
|
break # Versions before 11.1.0.3 hold SO until 145
|
|
|
|
|
2018-07-17 15:07:03 +01:00
|
|
|
print("\nOptions")
|
2019-02-04 00:04:42 +00:00
|
|
|
for o in options:
|
|
|
|
print(" {}".format(o))
|
2018-07-17 15:07:03 +01:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if "StatusMEM" in obj:
|
|
|
|
if "Features" in obj["StatusMEM"]:
|
2018-07-17 15:07:03 +01:00
|
|
|
features = []
|
2021-05-12 22:20:16 +01:00
|
|
|
maxfeatures = len(obj["StatusMEM"]["Features"]) - 1
|
2021-05-12 17:44:13 +01:00
|
|
|
if maxfeatures > len(a_features):
|
|
|
|
print("decode-status.py too old, does not support all feature bits")
|
|
|
|
maxfeatures = min(maxfeatures, len(a_features))
|
|
|
|
for f in range(maxfeatures + 1):
|
2018-07-17 15:07:03 +01:00
|
|
|
feature = obj["StatusMEM"]["Features"][f]
|
|
|
|
i_feature = int(feature,16)
|
2019-02-04 00:04:42 +00:00
|
|
|
if f == 0:
|
2018-07-17 15:07:03 +01:00
|
|
|
features.append(str("Language LCID = {}".format(i_feature & 0xFFFF)))
|
|
|
|
else:
|
|
|
|
for i in range(len(a_features[f -1])):
|
2019-02-04 00:04:42 +00:00
|
|
|
if (i_feature >> i) & 1:
|
2018-07-17 15:07:03 +01:00
|
|
|
features.append(a_features[f -1][i])
|
|
|
|
|
|
|
|
features.sort()
|
|
|
|
print("\nFeatures")
|
2019-02-04 00:04:42 +00:00
|
|
|
for f in features:
|
|
|
|
print(" {}".format(f))
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
StartDecode()
|
|
|
|
except Exception as e:
|
2018-09-14 15:39:06 +01:00
|
|
|
print("E: {}".format(e))
|