mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' of https://github.com/arendst/Tasmota into pwm-dimmer3
This commit is contained in:
commit
fec34434a6
|
@ -54,28 +54,28 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
|
||||
### Version 8.1.0.11
|
||||
|
||||
- Change default my_user_config.h driver and sensor support removing most sensors and adding most drivers
|
||||
- Change default my_user_config.h driver and sensor support removing most sensors and adding most drivers to tasmota.bin
|
||||
- Change DHT driver (#7468, #7717)
|
||||
- Change Lights: simplified gamma correction and 10 bits internal computation
|
||||
- Change commands ``Prefix``, ``Ssid``, ``StateText``, ``NTPServer``, and ``FriendlyName`` displaying all items
|
||||
- Change IRremoteESP8266 library updated to v2.7.4
|
||||
- Change Zigbee command prefix from ``Zigbee*`` to ``Zb*``
|
||||
- Change MQTT message size with additional 200 characters
|
||||
- Change display of some date and time messages from "Wed Feb 19 10:45:12 2020" to "2020-02-19T10:45:12"
|
||||
- Fix Sonoff Bridge, Sc, L1, iFan03 and CSE7766 serial interface to forced speed, config and disable logging
|
||||
- Fix commands ``Display`` and ``Counter`` from overruling command processing (#7322)
|
||||
- Change IRremoteESP8266 library updated to v2.7.4
|
||||
- Fix ``PowerDelta`` zero power detection (#7515)
|
||||
- Fix ``White`` added to light status (#7142)
|
||||
- Fix ``WakeUp <x>`` ignores provided value (#7473)
|
||||
- Fix ``RGBWWTable`` ignored (#7572)
|
||||
- Fix commands ``Display`` and ``Counter`` from overruling command processing (#7322)
|
||||
- Fix Sonoff Bridge, Sc, L1, iFan03 and CSE7766 serial interface to forced speed, config and disable logging
|
||||
- Fix Improved fade linearity with gamma correction
|
||||
- Fix PWM flickering at low levels (#7415)
|
||||
- Fix LCD line and column positioning (#7387)
|
||||
- Fix Display handling of hexadecimal escape characters (#7387)
|
||||
- Fix ``WakeUp <x>`` ignores provided value (#7473)
|
||||
- Fix exception 9 restart on log message in Ticker interrupt service routines NTP, Wemos and Hue emulation (#7496)
|
||||
- Fix ``PowerDelta`` zero power detection (#7515)
|
||||
- Fix ``RGBWWTable`` ignored (#7572)
|
||||
- Fix PWM flickering at low levels (#7415)
|
||||
- Fix Hass sensor discovery part 1/4 by Federico Leoni (#7582, #7548)
|
||||
- Fix Hass sensor discovery by Federico Leoni (#7582, #7548)
|
||||
- Fix MaxPower functionality (#7647)
|
||||
- Fix relation between RSSI and signal strength
|
||||
- Fix relation between Wifi RSSI and signal strength
|
||||
- Add command ``SetOption79 0/1`` to enable reset of counters at teleperiod time by Andre Thomas (#7355)
|
||||
- Add command ``SetOption82 0/1`` to limit the CT range for Alexa to 200..380
|
||||
- Add command ``SetOption84 0/1`` to send AWS IoT device shadow updates (alternative to retained)
|
||||
|
@ -89,33 +89,35 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
- Add commands ``SwitchMode 11`` PushHoldMulti and ``SwitchMode 12`` PushHoldInverted (#7603)
|
||||
- Add commands ``SwitchMode 13`` PushOn and ``SwitchMode 14`` PushOnInverted (#7912)
|
||||
- Add command ``Buzzer -1`` for infinite mode and command ``Buzzer -2`` for following led mode (#7623)
|
||||
- Add SerialConfig to ``Status 1``
|
||||
- Add WifiPower to ``Status 5``
|
||||
- Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev
|
||||
- Add Zigbee attribute decoder for Xiaomi Aqara Cube
|
||||
- Add support for ``AdcParam`` parameters to control ADC0 Current Transformer Apparent Power formula by Jodi Dillon (#7100)
|
||||
- Add optional support for Prometheus using file xsns_91_prometheus.ino (#7216)
|
||||
- Add experimental support for NRF24L01 as BLE-bridge for Mijia Bluetooth sensors by Christian Baars (#7394)
|
||||
- Add support to BMP driver to enter reset state (sleep enable) when deep sleep is used in Tasmota
|
||||
- Add support for gzipped binaries
|
||||
- Add optional parameter ``<startcolor>`` to command ``Scheme <scheme>, <startcolor>`` to control initial start color
|
||||
- Add web page sliders when ``SetOption37 128`` is active allowing control of white(s)
|
||||
- Add most SetOptions as defines to my_user_config.h
|
||||
- Add SoftwareSerial to CSE7766 driver allowing different GPIOs (#7563)
|
||||
- Add optional parameter <startcolor> to command ``Scheme <scheme>, <startcolor>`` to control initial start color
|
||||
- Add rule trigger on one level deeper using syntax with two ``#`` like ``on zigbeereceived#vibration_sensor#aqaracubeside=0 do ...``
|
||||
- Add support for sensors DS18x20 and DHT family on Shelly 1 and Shelly 1PM using Shelly Add-On adapter (#7469)
|
||||
- Add support for MI-BLE sensors using HM-10 Bluetooth 4.0 module by Christian Staars (#7683)
|
||||
- Add SerialConfig to ``Status 1``
|
||||
- Add BootCount Reset Time as BCResetTime to ``Status 1``
|
||||
- Add ``ZbZNPReceived``and ``ZbZCLReceived`` being published to MQTT when ``SetOption66 1``
|
||||
- Add WifiPower to ``Status 5``
|
||||
- Add most SetOptions as defines to my_user_config.h
|
||||
- Add optional Wifi AccessPoint passphrase define WIFI_AP_PASSPHRASE in my_user_config.h (#7690)
|
||||
- Add support for FiF LE-01MR energy meter by saper-2 (#7584)
|
||||
- Add initial support for Sensors AHT10 and AHT15 by Martin Wagner (#7596)
|
||||
- Add support for Wemos Motor Shield V1 by Denis Sborets (#7764)
|
||||
- Add SoftwareSerial to CSE7766 driver allowing different GPIOs (#7563)
|
||||
- Add rule trigger on one level deeper using syntax with two ``#`` like ``on zbreceived#vibration_sensor#aqaracubeside=0 do ...``
|
||||
- Add Zigbee attribute decoder for Xiaomi Aqara Cube
|
||||
- Add ``ZbZNPReceived``and ``ZbZCLReceived`` being published to MQTT when ``SetOption66 1``
|
||||
- Add Zigbee enhanced commands decoding, added ``ZbPing``
|
||||
- Add Zigbee features and improvements
|
||||
- Add Zigbee support for Hue emulation by Stefan Hadinger
|
||||
- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901)
|
||||
- Add optional support for Prometheus using file xsns_91_prometheus.ino (#7216)
|
||||
- Add support for gzipped binaries
|
||||
- Add support for Romanian language translations by Augustin Marti
|
||||
- Add support for sensors DS18x20 and DHT family on Shelly 1 and Shelly 1PM using Shelly Add-On adapter (#7469)
|
||||
- Add support to BMP driver to enter reset state (sleep enable) when deep sleep is used in Tasmota
|
||||
- Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev
|
||||
- Add support for NRF24L01 as BLE-bridge for Mijia Bluetooth sensors by Christian Baars (#7394)
|
||||
- Add support for MI-BLE sensors using HM-10 Bluetooth 4.0 module by Christian Staars (#7683)
|
||||
- Add support for FiF LE-01MR energy meter by saper-2 (#7584)
|
||||
- Add support for Sensors AHT10 and AHT15 by Martin Wagner (#7596)
|
||||
- Add support for Wemos Motor Shield V1 by Denis Sborets (#7764)
|
||||
- Add support for Martin Jerry/acenx/Tessan/NTONPOWER SD0x PWM dimmer switches by Paul Diem (#7791)
|
||||
- Add support for UDP Group control without MQTT by Paul Diem (#7790)
|
||||
- Add support for Jarolift rollers by Keeloq algorithm
|
||||
- Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders by Jon Little (#7814)
|
||||
- Add support for Romanian language translations by Augustin Marti
|
||||
- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901)
|
||||
- Add support for HDC1080 Temperature and Humidity sensor by Luis Teixeira (#7888)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901)
|
||||
- Add support for HDC1080 Temperature and Humidity sensor by Luis Teixeira (#7888)
|
||||
- Add commands ``SwitchMode 13`` PushOn and ``SwitchMode 14`` PushOnInverted (#7912)
|
||||
- Add Zigbee support for Hue emulation by Stefan Hadinger
|
||||
|
||||
### 8.1.0.10 20200227
|
||||
|
||||
|
@ -75,7 +76,7 @@
|
|||
- Add Zigbee persistence and friendly names
|
||||
- Add most SetOptions as defines to my_user_config.h
|
||||
- Add SoftwareSerial to CSE7766 driver allowing different GPIOs (#7563)
|
||||
- Add optional parameter <startcolor> to command ``Scheme <scheme>, <startcolor>`` to control initial start color
|
||||
- Add optional parameter ``<startcolor>`` to command ``Scheme <scheme>, <startcolor>`` to control initial start color
|
||||
- Add rule trigger on one level deeper using syntax with two ``#`` like ``on zigbeereceived#vibration_sensor#aqaracubeside=0 do ...``
|
||||
|
||||
### 8.1.0.3 20200106
|
||||
|
|
|
@ -476,7 +476,6 @@
|
|||
#define D_ZIGBEE_NOT_STARTED "Zigbee not started (yet)"
|
||||
#define D_CMND_ZIGBEE_PERMITJOIN "PermitJoin"
|
||||
#define D_CMND_ZIGBEE_STATUS "Status"
|
||||
#define D_JSON_ZIGBEE_Status "Status"
|
||||
#define D_CMND_ZIGBEE_RESET "Reset"
|
||||
#define D_JSON_ZIGBEE_CC2530 "CC2530"
|
||||
#define D_CMND_ZIGBEEZNPRECEIVE "ZNPReceive" // only for debug
|
||||
|
@ -488,6 +487,7 @@
|
|||
#define D_JSON_ZIGBEEZCL_RAW_RECEIVED "ZbZCLRawReceived"
|
||||
#define D_JSON_ZIGBEE_DEVICE "Device"
|
||||
#define D_JSON_ZIGBEE_NAME "Name"
|
||||
#define D_JSON_ZIGBEE_CONFIRM "ZbConfirm"
|
||||
#define D_CMND_ZIGBEE_NAME "Name"
|
||||
#define D_CMND_ZIGBEE_MODELID "ModelId"
|
||||
#define D_JSON_ZIGBEE_MODELID "ModelId"
|
||||
|
@ -510,6 +510,8 @@
|
|||
#define D_JSON_ZIGBEE_CMD "Command"
|
||||
#define D_JSON_ZIGBEE_STATUS "Status"
|
||||
#define D_JSON_ZIGBEE_STATUS_MSG "StatusMessage"
|
||||
#define D_CMND_ZIGBEE_LIGHT "Light"
|
||||
#define D_JSON_ZIGBEE_LIGHT "Light"
|
||||
|
||||
// Commands xdrv_25_A4988_Stepper.ino
|
||||
#define D_CMND_MOTOR "MOTOR"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "Ю"
|
||||
#define D_TX20_WEST "З"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Няма"
|
||||
#define D_SENSOR_USER "Потребит."
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "J"
|
||||
#define D_TX20_WEST "Z"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Není"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Verbrauch"
|
||||
#define D_TPWROUT "Einspeisung"
|
||||
#define D_TPWRCURR "Aktueller Verbrauch"
|
||||
#define D_TPWRCURR1 "Verbrauch P1"
|
||||
#define D_TPWRCURR2 "Verbrauch P2"
|
||||
#define D_TPWRCURR3 "Verbrauch P3"
|
||||
#define D_Strom_L1 "Strom L1"
|
||||
#define D_Strom_L2 "Strom L2"
|
||||
#define D_Strom_L3 "Strom L3"
|
||||
#define D_Spannung_L1 "Spannung L1"
|
||||
#define D_Spannung_L2 "Spannung L2"
|
||||
#define D_Spannung_L3 "Spannung L3"
|
||||
#define D_METERNR "Zähler Nr"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Zählerstand" // Gas-Verbrauch
|
||||
#define D_H2oIN "Zählerstand" // H2o-Verbrauch
|
||||
#define D_StL1L2L3 "Ströme L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Spannung L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "None"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "Ν"
|
||||
#define D_TX20_WEST "Δ"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Κανένα"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter" // Gas-Verbrauch
|
||||
#define D_H2oIN "Counter" // H2o-Verbrauch
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "None"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "O"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total de Entrada"
|
||||
#define D_TPWROUT "Total de Salida"
|
||||
#define D_TPWRCURR "Corriente-En/Sal"
|
||||
#define D_TPWRCURR1 "Corriente-Entr p1"
|
||||
#define D_TPWRCURR2 "Corriente-Entr p2"
|
||||
#define D_TPWRCURR3 "Corriente-Entr p3"
|
||||
#define D_Strom_L1 "Corriente L1"
|
||||
#define D_Strom_L2 "Corriente L2"
|
||||
#define D_Strom_L3 "Corriente L3"
|
||||
#define D_Spannung_L1 "Voltaje L1"
|
||||
#define D_Spannung_L2 "Voltaje L2"
|
||||
#define D_Spannung_L3 "Voltaje L3"
|
||||
#define D_METERNR "Número de Medidor"
|
||||
#define D_METERSID "ID de Servicio"
|
||||
#define D_GasIN "Contador"
|
||||
#define D_H2oIN "Contador"
|
||||
#define D_StL1L2L3 "Corriente L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Ninguno"
|
||||
#define D_SENSOR_USER "Por Usuario"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "O"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Aucun"
|
||||
#define D_SENSOR_USER "Utilisateur"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "None"
|
||||
#define D_SENSOR_USER "משתמש"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "D"
|
||||
#define D_TX20_WEST "NY"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Nincs"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "O"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Nessuno"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "없음"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Geen"
|
||||
#define D_SENSOR_USER "Gebruiker"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Brak"
|
||||
#define D_SENSOR_USER "Użytkownik"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "O"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Nenhum"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "O"
|
||||
|
||||
//xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-Consumo"
|
||||
#define D_TPWROUT "Total-Geração"
|
||||
#define D_TPWRCURR "Corrente-Consumo/Geração"
|
||||
#define D_TPWRCURR1 "Corrente-Consumo F1"
|
||||
#define D_TPWRCURR2 "Corrente-Consumo F2"
|
||||
#define D_TPWRCURR3 "Corrente-Consumo F3"
|
||||
#define D_Strom_L1 "Corrente F1"
|
||||
#define D_Strom_L2 "Corrente F2"
|
||||
#define D_Strom_L3 "Corrente F3"
|
||||
#define D_Spannung_L1 "Tensão F1"
|
||||
#define D_Spannung_L2 "Tensão F2"
|
||||
#define D_Spannung_L3 "Tensão F3"
|
||||
#define D_METERNR "Número_Contador"
|
||||
#define D_METERSID "ID Serviço"
|
||||
#define D_GasIN "Contador"
|
||||
#define D_H2oIN "Contador"
|
||||
#define D_StL1L2L3 "Corrente F1+F2+F3"
|
||||
#define D_SpL1L2L3 "Tensão F1+F2+F3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Nenhum"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "V"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Fără"
|
||||
#define D_SENSOR_USER "Utilizator"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "-нет-"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "J"
|
||||
#define D_TX20_WEST "Z"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Žiaden"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "V"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Ingen"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "None"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "Пд"
|
||||
#define D_TX20_WEST "Зх"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "Немає"
|
||||
#define D_SENSOR_USER "Користувач"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "南"
|
||||
#define D_TX20_WEST "西"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "无"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -512,6 +512,26 @@
|
|||
#define D_TX20_SOUTH "S"
|
||||
#define D_TX20_WEST "W"
|
||||
|
||||
// xsns_53_sml.ino
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter"
|
||||
#define D_H2oIN "Counter"
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
// tasmota_template.h - keep them as short as possible to be able to fit them in GUI drop down box
|
||||
#define D_SENSOR_NONE "None"
|
||||
#define D_SENSOR_USER "User"
|
||||
|
|
|
@ -612,7 +612,7 @@
|
|||
#define IR_RCV_MIN_UNKNOWN_SIZE 6 // Set the smallest sized "UNKNOWN" message packets we actually care about (default 6, max 255)
|
||||
|
||||
// -- Zigbee interface ----------------------------
|
||||
//#define USE_ZIGBEE // Enable serial communication with Zigbee CC2530 flashed with ZNP (+35k code, +3.2k mem)
|
||||
//#define USE_ZIGBEE // Enable serial communication with Zigbee CC2530 flashed with ZNP (+49k code, +3k mem)
|
||||
#define USE_ZIGBEE_PANID 0x1A63 // arbitrary PAN ID for Zigbee network, must be unique in the home
|
||||
#define USE_ZIGBEE_EXTPANID 0xCCCCCCCCCCCCCCCCL // arbitrary extended PAN ID
|
||||
#define USE_ZIGBEE_CHANNEL 11 // Zigbee Channel (11-26)
|
||||
|
|
|
@ -1669,6 +1669,8 @@ void AddLog(uint32_t loglevel)
|
|||
|
||||
if (!global_state.wifi_down &&
|
||||
(loglevel <= syslog_level)) { Syslog(); }
|
||||
|
||||
prepped_loglevel = 0;
|
||||
}
|
||||
|
||||
void AddLog_P(uint32_t loglevel, const char *formatP)
|
||||
|
|
|
@ -70,7 +70,8 @@ bool SwitchState(uint32_t index)
|
|||
(PUSHBUTTON_INV == switchmode) ||
|
||||
(PUSHBUTTONHOLD_INV == switchmode) ||
|
||||
(FOLLOWMULTI_INV == switchmode) ||
|
||||
(PUSHHOLDMULTI_INV == switchmode)
|
||||
(PUSHHOLDMULTI_INV == switchmode) ||
|
||||
(PUSHON_INV == switchmode)
|
||||
) ^ Switch.last_state[index];
|
||||
}
|
||||
|
||||
|
|
|
@ -803,7 +803,6 @@ void Every100mSeconds(void)
|
|||
|
||||
if (prepped_loglevel) {
|
||||
AddLog(prepped_loglevel);
|
||||
prepped_loglevel = 0;
|
||||
}
|
||||
|
||||
if (latching_relay_pulse) {
|
||||
|
|
|
@ -86,7 +86,7 @@ void PollUdp(void)
|
|||
|
||||
// Simple Service Discovery Protocol (SSDP)
|
||||
if (Settings.flag2.emulation) {
|
||||
#ifdef USE_SCRIPT_HUE
|
||||
#if defined(USE_SCRIPT_HUE) || defined(USE_ZIGBEE)
|
||||
if (!udp_response_mutex && (strstr_P(packet_buffer, PSTR("M-SEARCH")) != nullptr)) {
|
||||
#else
|
||||
if (devices_present && !udp_response_mutex && (strstr_P(packet_buffer, PSTR("M-SEARCH")) != nullptr)) {
|
||||
|
|
|
@ -1941,17 +1941,26 @@ void OtherSaveSettings(void)
|
|||
}
|
||||
AddLog_P(LOG_LEVEL_INFO, message);
|
||||
|
||||
/*
|
||||
// This sometimes provides intermittent watchdog
|
||||
bool template_activate = WebServer->hasArg("t2"); // Try this to tackle intermittent watchdog after execution of Template command
|
||||
WebGetArg("t1", tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) { // {"NAME":"12345678901234","GPIO":[255,255,255,255,255,255,255,255,255,255,255,255,255],"FLAG":255,"BASE":255}
|
||||
char svalue[128];
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_TEMPLATE " %s"), tmp);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
|
||||
if (WebServer->hasArg("t2")) {
|
||||
if (template_activate) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_MODULE " 0"));
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
|
||||
}
|
||||
// Try async execution of commands
|
||||
*/
|
||||
WebGetArg("t1", tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) { // {"NAME":"12345678901234","GPIO":[255,255,255,255,255,255,255,255,255,255,255,255,255],"FLAG":255,"BASE":255}
|
||||
snprintf_P(message, sizeof(message), PSTR(D_CMND_BACKLOG " " D_CMND_TEMPLATE " %s%s"), tmp, (WebServer->hasArg("t2")) ? "; " D_CMND_MODULE " 0" : "");
|
||||
ExecuteWebCommand(message, SRC_WEBGUI);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,12 @@ const char HASS_DISCOVER_BIN_SWITCH[] PROGMEM =
|
|||
"\"pl_on\":\"%s\"," // ON
|
||||
"\"pl_off\":\"%s\""; // OFF
|
||||
|
||||
const char HASS_DISCOVER_BIN_PIR[] PROGMEM =
|
||||
",\"val_tpl\":\"{{value_json.%s}}\"," // STATE
|
||||
"\"frc_upd\":true," // In ON/OFF case, enable force_update to make automations work
|
||||
"\"pl_on\":\"%s\"," // ON
|
||||
"\"off_dly\":1"; // Switchmode13 and Switchmode14 doesn't transmit an OFF state.
|
||||
|
||||
const char HASS_DISCOVER_LIGHT_DIMMER[] PROGMEM =
|
||||
",\"bri_cmd_t\":\"%s\"," // cmnd/led2/Dimmer
|
||||
"\"bri_stat_t\":\"%s\"," // stat/led2/RESULT
|
||||
|
@ -290,7 +296,7 @@ void HAssAnnouncerTriggers(uint8_t device, uint8_t present, uint8_t key, uint8_t
|
|||
}
|
||||
}
|
||||
|
||||
void HAssAnnouncerBinSensors(uint8_t device, uint8_t present, uint8_t dual, uint8_t toggle)
|
||||
void HAssAnnouncerBinSensors(uint8_t device, uint8_t present, uint8_t dual, uint8_t toggle, uint8_t pir)
|
||||
{
|
||||
char stopic[TOPSZ];
|
||||
char stemp1[TOPSZ];
|
||||
|
@ -319,7 +325,11 @@ void HAssAnnouncerBinSensors(uint8_t device, uint8_t present, uint8_t dual, uint
|
|||
|
||||
snprintf_P(name, sizeof(name), PSTR("%s Switch%d"), SettingsText(SET_FRIENDLYNAME1), device + 1);
|
||||
Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic);
|
||||
TryResponseAppend_P(HASS_DISCOVER_BIN_SWITCH, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT2), SettingsText(SET_STATE_TXT1));
|
||||
if (!pir) {
|
||||
TryResponseAppend_P(HASS_DISCOVER_BIN_SWITCH, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT2), SettingsText(SET_STATE_TXT1));
|
||||
} else {
|
||||
TryResponseAppend_P(HASS_DISCOVER_BIN_PIR, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT2));
|
||||
}
|
||||
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP.getChipId());
|
||||
TryResponseAppend_P(PSTR("}"));
|
||||
}
|
||||
|
@ -335,6 +345,7 @@ void HAssAnnounceSwitches(void)
|
|||
uint8_t dual = 0;
|
||||
uint8_t toggle = 1;
|
||||
uint8_t hold = 0;
|
||||
uint8_t pir = 0;
|
||||
|
||||
if (pin[GPIO_SWT1 + switch_index] < 99) { switch_present = 1; }
|
||||
|
||||
|
@ -365,34 +376,38 @@ void HAssAnnounceSwitches(void)
|
|||
uint8_t swmode = Settings.switchmode[switch_index];
|
||||
|
||||
switch (swmode) {
|
||||
case 1:
|
||||
case 2:
|
||||
case FOLLOW:
|
||||
case FOLLOW_INV:
|
||||
toggle = 0; // Binary sensor and no triggers
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
case PUSHBUTTON:
|
||||
case PUSHBUTTON_INV:
|
||||
dual = 1; // Binary sensor and TOGGLE (button_short_press) trigger
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
case PUSHBUTTONHOLD:
|
||||
case PUSHBUTTONHOLD_INV:
|
||||
dual = 1; // Binary sensor, TOGGLE (button_short_press) and HOLD (button_long_press) triggers
|
||||
hold = 2;
|
||||
break;
|
||||
case 8:
|
||||
case TOGGLEMULTI:
|
||||
hold = 3; // TOGGLE (button_short_press) and HOLD (button_double_press) triggers
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case FOLLOWMULTI:
|
||||
case FOLLOWMULTI_INV:
|
||||
dual = 1; // Binary sensor and HOLD (button_long_press) trigger
|
||||
toggle = 0;
|
||||
hold = 3;
|
||||
break;
|
||||
case PUSHON:
|
||||
case PUSHON_INV:
|
||||
toggle = 0;
|
||||
pir = 1; // Binary sensor with only ON state and automatic OFF after 1 second.
|
||||
}
|
||||
|
||||
} else { switch_present = 0;}
|
||||
|
||||
HAssAnnouncerTriggers(switch_index, switch_present, 1, toggle, hold);
|
||||
HAssAnnouncerBinSensors(switch_index, switch_present, dual, toggle);
|
||||
HAssAnnouncerBinSensors(switch_index, switch_present, dual, toggle, pir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,6 +546,7 @@ void HAssAnnounceSensors(void)
|
|||
snprintf_P(sensordata, sizeof(sensordata), PSTR("%s}"), sensordata); // {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089}}
|
||||
// USE THE FOLLOWING LINE TO TEST JSON
|
||||
//snprintf_P(sensordata, sizeof(sensordata), PSTR("{\"HX711\":{\"Weight\":[22,34,1023.4], \"Battery\":25}}"));
|
||||
|
||||
StaticJsonBuffer<500> jsonBuffer;
|
||||
JsonObject &root = jsonBuffer.parseObject(sensordata);
|
||||
if (!root.success())
|
||||
|
|
|
@ -179,7 +179,7 @@ const char HUE_ERROR_JSON[] PROGMEM =
|
|||
|
||||
/********************************************************************************************/
|
||||
|
||||
String GetHueDeviceId(uint8_t id)
|
||||
String GetHueDeviceId(uint16_t id)
|
||||
{
|
||||
String deviceid = WiFi.macAddress();
|
||||
deviceid += F(":00:11-");
|
||||
|
@ -322,7 +322,6 @@ void HueLightStatus1(uint8_t device, String *response)
|
|||
const size_t buf_size = 256;
|
||||
char * buf = (char*) malloc(buf_size); // temp buffer for strings, avoid stack
|
||||
|
||||
//String resp;
|
||||
snprintf_P(buf, buf_size, PSTR("{\"on\":%s,"), (power & (1 << (device-1))) ? "true" : "false");
|
||||
// Brightness for all devices with PWM
|
||||
if ((1 == echo_gen) || (LST_SINGLE <= local_light_subtype)) { // force dimmer for 1st gen Echo
|
||||
|
@ -386,11 +385,11 @@ void HueLightStatus2(uint8_t device, String *response)
|
|||
// it is limited to 32 devices.
|
||||
// last 24 bits of Mac address + 4 bits of local light + high bit for relays 16-31, relay 32 is mapped to 0
|
||||
// Zigbee extension: bit 29 = 1, and last 16 bits = short address of Zigbee device
|
||||
// #ifndef USE_ZIGBEE
|
||||
#ifndef USE_ZIGBEE
|
||||
uint32_t EncodeLightId(uint8_t relay_id)
|
||||
// #else
|
||||
// uint32_t EncodeLightId(uint8_t relay_id, uint16_t z_shortaddr = 0)
|
||||
// #endif
|
||||
#else
|
||||
uint32_t EncodeLightId(uint8_t relay_id, uint16_t z_shortaddr = 0)
|
||||
#endif
|
||||
{
|
||||
uint8_t mac[6];
|
||||
WiFi.macAddress(mac);
|
||||
|
@ -403,12 +402,12 @@ uint32_t EncodeLightId(uint8_t relay_id)
|
|||
id |= (1 << 28);
|
||||
}
|
||||
id |= (relay_id & 0xF);
|
||||
// #ifdef USE_ZIGBEE
|
||||
// if ((z_shortaddr) && (!relay_id)) {
|
||||
// // fror Zigbee devices, we have relay_id == 0 and shortaddr != 0
|
||||
// id = (1 << 29) | z_shortaddr;
|
||||
// }
|
||||
// #endif
|
||||
#ifdef USE_ZIGBEE
|
||||
if ((z_shortaddr) && (!relay_id)) {
|
||||
// fror Zigbee devices, we have relay_id == 0 and shortaddr != 0
|
||||
id = (1 << 29) | z_shortaddr;
|
||||
}
|
||||
#endif
|
||||
|
||||
return id;
|
||||
}
|
||||
|
@ -419,11 +418,11 @@ uint32_t EncodeLightId(uint8_t relay_id)
|
|||
// Zigbee:
|
||||
// If the Id encodes a Zigbee device (meaning bit 29 is set)
|
||||
// it returns 0 and sets the 'shortaddr' to the device short address
|
||||
// #ifndef USE_ZIGBEE
|
||||
#ifndef USE_ZIGBEE
|
||||
uint32_t DecodeLightId(uint32_t hue_id)
|
||||
// #else
|
||||
// uint32_t DecodeLightId(uint32_t hue_id, uint16_t * shortaddr = nullptr)
|
||||
// #endif
|
||||
#else
|
||||
uint32_t DecodeLightId(uint32_t hue_id, uint16_t * shortaddr = nullptr)
|
||||
#endif
|
||||
{
|
||||
uint8_t relay_id = hue_id & 0xF;
|
||||
if (hue_id & (1 << 28)) { // check if bit 25 is set, if so we have
|
||||
|
@ -432,13 +431,13 @@ uint32_t DecodeLightId(uint32_t hue_id)
|
|||
if (0 == relay_id) { // special value 0 is actually relay #32
|
||||
relay_id = 32;
|
||||
}
|
||||
// #ifdef USE_ZIGBEE
|
||||
// if (hue_id & (1 << 29)) {
|
||||
// // this is actually a Zigbee ID
|
||||
// if (shortaddr) { *shortaddr = hue_id & 0xFFFF; }
|
||||
// relay_id = 0;
|
||||
// }
|
||||
// #endif // USE_ZIGBEE
|
||||
#ifdef USE_ZIGBEE
|
||||
if (hue_id & (1 << 29)) {
|
||||
// this is actually a Zigbee ID
|
||||
if (shortaddr) { *shortaddr = hue_id & 0xFFFF; }
|
||||
relay_id = 0;
|
||||
}
|
||||
#endif // USE_ZIGBEE
|
||||
return relay_id;
|
||||
}
|
||||
|
||||
|
@ -474,9 +473,9 @@ void HueGlobalConfig(String *path) {
|
|||
response = F("{\"lights\":{");
|
||||
bool appending = false; // do we need to add a comma to append
|
||||
CheckHue(&response, appending);
|
||||
// #ifdef USE_ZIGBEE
|
||||
// ZigbeeCheckHue(&response, appending);
|
||||
// #endif // USE_ZIGBEE
|
||||
#ifdef USE_ZIGBEE
|
||||
ZigbeeCheckHue(&response, appending);
|
||||
#endif // USE_ZIGBEE
|
||||
response += F("},\"groups\":{},\"schedules\":{},\"config\":");
|
||||
HueConfigResponse(&response);
|
||||
response += "}";
|
||||
|
@ -546,10 +545,8 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) {
|
|||
switch(on)
|
||||
{
|
||||
case false : ExecuteCommandPower(device, POWER_OFF, SRC_HUE);
|
||||
//response.replace("{re", "false");
|
||||
break;
|
||||
case true : ExecuteCommandPower(device, POWER_ON, SRC_HUE);
|
||||
//response.replace("{re", "true");
|
||||
break;
|
||||
}
|
||||
response += buf;
|
||||
|
@ -713,9 +710,9 @@ void HueLights(String *path)
|
|||
response = "{";
|
||||
bool appending = false;
|
||||
CheckHue(&response, appending);
|
||||
// #ifdef USE_ZIGBEE
|
||||
// ZigbeeCheckHue(&response, appending);
|
||||
// #endif // USE_ZIGBEE
|
||||
#ifdef USE_ZIGBEE
|
||||
ZigbeeCheckHue(&response, appending);
|
||||
#endif // USE_ZIGBEE
|
||||
#ifdef USE_SCRIPT_HUE
|
||||
Script_Check_Hue(&response);
|
||||
#endif
|
||||
|
@ -726,13 +723,13 @@ void HueLights(String *path)
|
|||
path->remove(path->indexOf("/state")); // Remove /state
|
||||
device_id = atoi(path->c_str());
|
||||
device = DecodeLightId(device_id);
|
||||
// #ifdef USE_ZIGBEE
|
||||
// uint16_t shortaddr;
|
||||
// device = DecodeLightId(device_id, &shortaddr);
|
||||
// if (shortaddr) {
|
||||
// return ZigbeeHandleHue(shortaddr, device_id, response);
|
||||
// }
|
||||
// #endif // USE_ZIGBEE
|
||||
#ifdef USE_ZIGBEE
|
||||
uint16_t shortaddr;
|
||||
device = DecodeLightId(device_id, &shortaddr);
|
||||
if (shortaddr) {
|
||||
return ZigbeeHandleHue(shortaddr, device_id, response);
|
||||
}
|
||||
#endif // USE_ZIGBEE
|
||||
|
||||
#ifdef USE_SCRIPT_HUE
|
||||
if (device > devices_present) {
|
||||
|
@ -749,6 +746,14 @@ void HueLights(String *path)
|
|||
path->remove(0,8); // Remove /lights/
|
||||
device_id = atoi(path->c_str());
|
||||
device = DecodeLightId(device_id);
|
||||
#ifdef USE_ZIGBEE
|
||||
uint16_t shortaddr;
|
||||
device = DecodeLightId(device_id, &shortaddr);
|
||||
if (shortaddr) {
|
||||
ZigbeeHueStatus(&response, shortaddr);
|
||||
goto exit;
|
||||
}
|
||||
#endif // USE_ZIGBEE
|
||||
|
||||
#ifdef USE_SCRIPT_HUE
|
||||
if (device > devices_present) {
|
||||
|
@ -791,9 +796,9 @@ void HueGroups(String *path)
|
|||
lights += "\"";
|
||||
}
|
||||
|
||||
// #ifdef USE_ZIGBEE
|
||||
// ZigbeeHueGroups(&response);
|
||||
// #endif // USE_ZIGBEE
|
||||
#ifdef USE_ZIGBEE
|
||||
ZigbeeHueGroups(&response);
|
||||
#endif // USE_ZIGBEE
|
||||
response.replace("{l1", lights);
|
||||
HueLightStatus1(1, &response);
|
||||
response += F("}");
|
||||
|
|
|
@ -171,12 +171,12 @@ enum Z_configuration {
|
|||
|
||||
//
|
||||
enum Z_Status {
|
||||
Z_Success = 0x00,
|
||||
Z_Failure = 0x01,
|
||||
Z_InvalidParameter = 0x02,
|
||||
Z_MemError = 0x03,
|
||||
Z_Created = 0x09,
|
||||
Z_BufferFull = 0x11
|
||||
Z_SUCCESS = 0x00,
|
||||
Z_FAILURE = 0x01,
|
||||
Z_INVALIDPARAMETER = 0x02,
|
||||
Z_MEMERROR = 0x03,
|
||||
Z_CREATED = 0x09,
|
||||
Z_BUFFERFULL = 0x11
|
||||
};
|
||||
|
||||
enum Z_App_Profiles {
|
||||
|
@ -385,6 +385,9 @@ enum ZCL_Global_Commands {
|
|||
|
||||
};
|
||||
|
||||
#define ZF(s) static const char ZS_ ## s[] PROGMEM = #s;
|
||||
#define Z(s) ZS_ ## s
|
||||
|
||||
const uint16_t Z_ProfileIds[] PROGMEM = { 0x0104, 0x0109, 0xA10E, 0xC05E };
|
||||
const char Z_ProfileNames[] PROGMEM = "ZigBee Home Automation|ZigBee Smart Energy|ZigBee Green Power|ZigBee Light Link";
|
||||
|
||||
|
@ -393,42 +396,78 @@ typedef struct Z_StatusLine {
|
|||
const char * status_msg;
|
||||
} Z_StatusLine;
|
||||
|
||||
ZF(SUCCESS)
|
||||
ZF(FAILURE)
|
||||
ZF(NOT_AUTHORIZED)
|
||||
ZF(RESERVED_FIELD_NOT_ZERO)
|
||||
ZF(MALFORMED_COMMAND)
|
||||
ZF(UNSUP_CLUSTER_COMMAND)
|
||||
ZF(UNSUP_GENERAL_COMMAND)
|
||||
ZF(UNSUP_MANUF_CLUSTER_COMMAND)
|
||||
ZF(UNSUP_MANUF_GENERAL_COMMAND)
|
||||
ZF(INVALID_FIELD)
|
||||
ZF(UNSUPPORTED_ATTRIBUTE)
|
||||
ZF(INVALID_VALUE)
|
||||
ZF(READ_ONLY)
|
||||
ZF(INSUFFICIENT_SPACE)
|
||||
ZF(DUPLICATE_EXISTS)
|
||||
ZF(NOT_FOUND)
|
||||
ZF(UNREPORTABLE_ATTRIBUTE)
|
||||
ZF(INVALID_DATA_TYPE)
|
||||
ZF(INVALID_SELECTOR)
|
||||
ZF(WRITE_ONLY)
|
||||
ZF(INCONSISTENT_STARTUP_STATE)
|
||||
ZF(DEFINED_OUT_OF_BAND)
|
||||
ZF(INCONSISTENT)
|
||||
ZF(ACTION_DENIED)
|
||||
ZF(TIMEOUT)
|
||||
ZF(ABORT)
|
||||
ZF(INVALID_IMAGE)
|
||||
ZF(WAIT_FOR_DATA)
|
||||
ZF(NO_IMAGE_AVAILABLE)
|
||||
ZF(REQUIRE_MORE_IMAGE)
|
||||
ZF(NOTIFICATION_PENDING)
|
||||
ZF(HARDWARE_FAILURE)
|
||||
ZF(SOFTWARE_FAILURE)
|
||||
ZF(CALIBRATION_ERROR)
|
||||
ZF(UNSUPPORTED_CLUSTER)
|
||||
|
||||
const Z_StatusLine Z_Status[] PROGMEM = {
|
||||
0x00, "SUCCESS",
|
||||
0x01, "FAILURE",
|
||||
0x7E, "NOT_AUTHORIZED",
|
||||
0x7F, "RESERVED_FIELD_NOT_ZERO",
|
||||
0x80, "MALFORMED_COMMAND",
|
||||
0x81, "UNSUP_CLUSTER_COMMAND",
|
||||
0x82, "UNSUP_GENERAL_COMMAND",
|
||||
0x83, "UNSUP_MANUF_CLUSTER_COMMAND",
|
||||
0x84, "UNSUP_MANUF_GENERAL_COMMAND",
|
||||
0x85, "INVALID_FIELD",
|
||||
0x86, "UNSUPPORTED_ATTRIBUTE",
|
||||
0x87, "INVALID_VALUE",
|
||||
0x88, "READ_ONLY",
|
||||
0x89, "INSUFFICIENT_SPACE",
|
||||
0x8A, "DUPLICATE_EXISTS",
|
||||
0x8B, "NOT_FOUND",
|
||||
0x8C, "UNREPORTABLE_ATTRIBUTE",
|
||||
0x8D, "INVALID_DATA_TYPE",
|
||||
0x8E, "INVALID_SELECTOR",
|
||||
0x8F, "WRITE_ONLY",
|
||||
0x90, "INCONSISTENT_STARTUP_STATE",
|
||||
0x91, "DEFINED_OUT_OF_BAND",
|
||||
0x92, "INCONSISTENT",
|
||||
0x93, "ACTION_DENIED",
|
||||
0x94, "TIMEOUT",
|
||||
0x95, "ABORT",
|
||||
0x96, "INVALID_IMAGE",
|
||||
0x97, "WAIT_FOR_DATA",
|
||||
0x98, "NO_IMAGE_AVAILABLE",
|
||||
0x99, "REQUIRE_MORE_IMAGE",
|
||||
0x9A, "NOTIFICATION_PENDING",
|
||||
0xC0, "HARDWARE_FAILURE",
|
||||
0xC1, "SOFTWARE_FAILURE",
|
||||
0xC2, "CALIBRATION_ERROR",
|
||||
0xC3, "UNSUPPORTED_CLUSTER",
|
||||
0x00, Z(SUCCESS),
|
||||
0x01, Z(FAILURE),
|
||||
0x7E, Z(NOT_AUTHORIZED),
|
||||
0x7F, Z(RESERVED_FIELD_NOT_ZERO),
|
||||
0x80, Z(MALFORMED_COMMAND),
|
||||
0x81, Z(UNSUP_CLUSTER_COMMAND),
|
||||
0x82, Z(UNSUP_GENERAL_COMMAND),
|
||||
0x83, Z(UNSUP_MANUF_CLUSTER_COMMAND),
|
||||
0x84, Z(UNSUP_MANUF_GENERAL_COMMAND),
|
||||
0x85, Z(INVALID_FIELD),
|
||||
0x86, Z(UNSUPPORTED_ATTRIBUTE),
|
||||
0x87, Z(INVALID_VALUE),
|
||||
0x88, Z(READ_ONLY),
|
||||
0x89, Z(INSUFFICIENT_SPACE),
|
||||
0x8A, Z(DUPLICATE_EXISTS),
|
||||
0x8B, Z(NOT_FOUND),
|
||||
0x8C, Z(UNREPORTABLE_ATTRIBUTE),
|
||||
0x8D, Z(INVALID_DATA_TYPE),
|
||||
0x8E, Z(INVALID_SELECTOR),
|
||||
0x8F, Z(WRITE_ONLY),
|
||||
0x90, Z(INCONSISTENT_STARTUP_STATE),
|
||||
0x91, Z(DEFINED_OUT_OF_BAND),
|
||||
0x92, Z(INCONSISTENT),
|
||||
0x93, Z(ACTION_DENIED),
|
||||
0x94, Z(TIMEOUT),
|
||||
0x95, Z(ABORT),
|
||||
0x96, Z(INVALID_IMAGE),
|
||||
0x97, Z(WAIT_FOR_DATA),
|
||||
0x98, Z(NO_IMAGE_AVAILABLE),
|
||||
0x99, Z(REQUIRE_MORE_IMAGE),
|
||||
0x9A, Z(NOTIFICATION_PENDING),
|
||||
0xC0, Z(HARDWARE_FAILURE),
|
||||
0xC1, Z(SOFTWARE_FAILURE),
|
||||
0xC2, Z(CALIBRATION_ERROR),
|
||||
0xC3, Z(UNSUPPORTED_CLUSTER),
|
||||
};
|
||||
|
||||
const __FlashStringHelper* getZigbeeStatusMessage(uint8_t status) {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
// contains some definitions for functions used before their declarations
|
||||
|
||||
void ZigbeeZCLSend(uint16_t dtsAddr, uint16_t clusterId, uint8_t endpoint, uint8_t cmdId, bool clusterSpecific, const uint8_t *msg, size_t len, bool needResponse, uint8_t transacId);
|
||||
void ZigbeeZCLSend_Raw(uint16_t dtsAddr, uint16_t groupaddr, uint16_t clusterId, uint8_t endpoint, uint8_t cmdId, bool clusterSpecific, const uint8_t *msg, size_t len, bool needResponse, uint8_t transacId);
|
||||
|
||||
|
||||
// Get an JSON attribute, with case insensitive key search
|
||||
|
@ -43,4 +43,15 @@ JsonVariant &getCaseInsensitive(const JsonObject &json, const char *needle) {
|
|||
return *(JsonVariant*)nullptr;
|
||||
}
|
||||
|
||||
uint32_t parseHex(const char **data, size_t max_len = 8) {
|
||||
uint32_t ret = 0;
|
||||
for (uint32_t i = 0; i < max_len; i++) {
|
||||
int8_t v = hexValue(**data);
|
||||
if (v < 0) { break; } // non hex digit, we stop parsing
|
||||
ret = (ret << 4) | v;
|
||||
*data += 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // USE_ZIGBEE
|
||||
|
|
|
@ -20,39 +20,62 @@
|
|||
#ifdef USE_ZIGBEE
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#ifndef ZIGBEE_SAVE_DELAY_SECONDS
|
||||
#define ZIGBEE_SAVE_DELAY_SECONDS 10; // wait for 10s before saving Zigbee info
|
||||
#define ZIGBEE_SAVE_DELAY_SECONDS 2; // wait for 2s before saving Zigbee info
|
||||
#endif
|
||||
const uint16_t kZigbeeSaveDelaySeconds = ZIGBEE_SAVE_DELAY_SECONDS; // wait for x seconds
|
||||
|
||||
typedef int32_t (*Z_DeviceTimer)(uint16_t shortaddr, uint16_t cluster, uint16_t endpoint, uint32_t value);
|
||||
typedef int32_t (*Z_DeviceTimer)(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value);
|
||||
|
||||
typedef struct Z_Device {
|
||||
uint16_t shortaddr; // unique key if not null, or unspecified if null
|
||||
uint64_t longaddr; // 0x00 means unspecified
|
||||
uint32_t firstSeen; // date when the device was first seen
|
||||
uint32_t lastSeen; // date when the device was last seen
|
||||
String manufacturerId;
|
||||
String modelId;
|
||||
String friendlyName;
|
||||
char * manufacturerId;
|
||||
char * modelId;
|
||||
char * friendlyName;
|
||||
std::vector<uint32_t> endpoints; // encoded as high 16 bits is endpoint, low 16 bits is ProfileId
|
||||
std::vector<uint32_t> clusters_in; // encoded as high 16 bits is endpoint, low 16 bits is cluster number
|
||||
std::vector<uint32_t> clusters_out; // encoded as high 16 bits is endpoint, low 16 bits is cluster number
|
||||
// below are per device timers, used for example to query the new state of the device
|
||||
uint32_t timer; // millis() when to fire the timer, 0 if no timer
|
||||
uint16_t cluster; // cluster to use for the timer
|
||||
uint16_t endpoint; // endpoint to use for timer
|
||||
uint32_t value; // any raw value to use for the timer
|
||||
Z_DeviceTimer func; // function to call when timer occurs
|
||||
// json buffer used for attribute reporting
|
||||
DynamicJsonBuffer *json_buffer;
|
||||
JsonObject *json;
|
||||
// sequence number for Zigbee frames
|
||||
uint8_t seqNumber;
|
||||
uint16_t shortaddr; // unique key if not null, or unspecified if null
|
||||
uint8_t seqNumber;
|
||||
// Light information for Hue integration integration, last known values
|
||||
int8_t bulbtype; // number of channel for the bulb: 0-5, or 0xFF if no Hue integration
|
||||
uint8_t power; // power state (boolean)
|
||||
uint8_t colormode; // 0x00: Hue/Sat, 0x01: XY, 0x02: CT
|
||||
uint8_t dimmer; // last Dimmer value: 0-254
|
||||
uint8_t sat; // last Sat: 0..254
|
||||
uint16_t ct; // last CT: 153-500
|
||||
uint16_t hue; // last Hue: 0..359
|
||||
uint16_t x, y; // last color [x,y]
|
||||
} Z_Device;
|
||||
|
||||
// Category for Deferred actions, this allows to selectively remove active deferred or update them
|
||||
typedef enum Z_Def_Category {
|
||||
Z_CAT_NONE = 0, // no category, it will happen anyways
|
||||
Z_CAT_READ_ATTR, // Attribute reporting, either READ_ATTRIBUTE or REPORT_ATTRIBUTE, we coalesce all attributes reported if we can
|
||||
Z_CAT_VIRTUAL_ATTR, // Creation of a virtual attribute, typically after a time-out. Ex: Aqara presence sensor
|
||||
Z_CAT_READ_0006, // Read 0x0006 cluster
|
||||
Z_CAT_READ_0008, // Read 0x0008 cluster
|
||||
Z_CAT_READ_0102, // Read 0x0300 cluster
|
||||
Z_CAT_READ_0300, // Read 0x0300 cluster
|
||||
} Z_Def_Category;
|
||||
|
||||
typedef struct Z_Deferred {
|
||||
// below are per device timers, used for example to query the new state of the device
|
||||
uint32_t timer; // millis() when to fire the timer, 0 if no timer
|
||||
uint16_t shortaddr; // identifier of the device
|
||||
uint16_t groupaddr; // group address (if needed)
|
||||
uint16_t cluster; // cluster to use for the timer
|
||||
uint8_t endpoint; // endpoint to use for timer
|
||||
uint8_t category; // which category of deferred is it
|
||||
uint32_t value; // any raw value to use for the timer
|
||||
Z_DeviceTimer func; // function to call when timer occurs
|
||||
} Z_Deferred;
|
||||
|
||||
// All devices are stored in a Vector
|
||||
// Invariants:
|
||||
// - shortaddr is unique if not null
|
||||
|
@ -93,21 +116,33 @@ public:
|
|||
void setManufId(uint16_t shortaddr, const char * str);
|
||||
void setModelId(uint16_t shortaddr, const char * str);
|
||||
void setFriendlyName(uint16_t shortaddr, const char * str);
|
||||
const String * getFriendlyName(uint16_t shortaddr) const;
|
||||
const String * getModelId(uint16_t shortaddr) const;
|
||||
|
||||
// device just seen on the network, update the lastSeen field
|
||||
void updateLastSeen(uint16_t shortaddr);
|
||||
const char * getFriendlyName(uint16_t shortaddr) const;
|
||||
const char * getModelId(uint16_t shortaddr) const;
|
||||
|
||||
// get next sequence number for (increment at each all)
|
||||
uint8_t getNextSeqNumber(uint16_t shortaddr);
|
||||
|
||||
// Dump json
|
||||
String dumpLightState(uint16_t shortaddr) const;
|
||||
String dump(uint32_t dump_mode, uint16_t status_shortaddr = 0) const;
|
||||
|
||||
// Hue support
|
||||
void setHueBulbtype(uint16_t shortaddr, int8_t bulbtype);
|
||||
int8_t getHueBulbtype(uint16_t shortaddr) const ;
|
||||
void updateHueState(uint16_t shortaddr,
|
||||
const uint8_t *power, const uint8_t *colormode,
|
||||
const uint8_t *dimmer, const uint8_t *sat,
|
||||
const uint16_t *ct, const uint16_t *hue,
|
||||
const uint16_t *x, const uint16_t *y);
|
||||
bool getHueState(uint16_t shortaddr,
|
||||
uint8_t *power, uint8_t *colormode,
|
||||
uint8_t *dimmer, uint8_t *sat,
|
||||
uint16_t *ct, uint16_t *hue,
|
||||
uint16_t *x, uint16_t *y) const ;
|
||||
|
||||
// Timers
|
||||
void resetTimer(uint32_t shortaddr);
|
||||
void setTimer(uint32_t shortaddr, uint32_t wait_ms, uint16_t cluster, uint16_t endpoint, uint32_t value, Z_DeviceTimer func);
|
||||
void resetTimersForDevice(uint16_t shortaddr, uint16_t groupaddr, uint8_t category);
|
||||
void setTimer(uint16_t shortaddr, uint16_t groupaddr, uint32_t wait_ms, uint16_t cluster, uint8_t endpoint, uint8_t category, uint32_t value, Z_DeviceTimer func);
|
||||
void runTimer(void);
|
||||
|
||||
// Append or clear attributes Json structure
|
||||
|
@ -123,7 +158,7 @@ public:
|
|||
return _devices.size();
|
||||
}
|
||||
const Z_Device &devicesAt(size_t i) const {
|
||||
return _devices.at(i);
|
||||
return *(_devices.at(i));
|
||||
}
|
||||
|
||||
// Remove device from list
|
||||
|
@ -132,14 +167,18 @@ public:
|
|||
// Mark data as 'dirty' and requiring to save in Flash
|
||||
void dirty(void);
|
||||
void clean(void); // avoid writing to flash the last changes
|
||||
void shrinkToFit(uint16_t shortaddr);
|
||||
|
||||
// Find device by name, can be short_addr, long_addr, number_in_array or name
|
||||
uint16_t parseDeviceParam(const char * param, bool short_must_be_known = false) const;
|
||||
|
||||
private:
|
||||
std::vector<Z_Device> _devices = {};
|
||||
uint32_t _saveTimer = 0;
|
||||
uint8_t _seqNumber = 0; // global seqNumber if device is unknown
|
||||
std::vector<Z_Device*> _devices = {};
|
||||
std::vector<Z_Deferred> _deferred = {}; // list of deferred calls
|
||||
// std::vector<Z_Device> _devices = std::vector<Z_Device>(4);
|
||||
// std::vector<Z_Deferred> _deferred = std::vector<Z_Deferred>(4); // list of deferred calls
|
||||
uint32_t _saveTimer = 0;
|
||||
uint8_t _seqNumber = 0; // global seqNumber if device is unknown
|
||||
|
||||
template < typename T>
|
||||
static bool findInVector(const std::vector<T> & vecOfElements, const T & element);
|
||||
|
@ -158,14 +197,9 @@ private:
|
|||
int32_t findLongAddr(uint64_t longaddr) const;
|
||||
int32_t findFriendlyName(const char * name) const;
|
||||
|
||||
void _updateLastSeen(Z_Device &device) {
|
||||
if (&device != nullptr) {
|
||||
device.lastSeen = Rtc.utc_time;
|
||||
}
|
||||
};
|
||||
|
||||
// Create a new entry in the devices list - must be called if it is sure it does not already exist
|
||||
Z_Device & createDeviceEntry(uint16_t shortaddr, uint64_t longaddr = 0);
|
||||
void freeDeviceEntry(Z_Device *device);
|
||||
};
|
||||
|
||||
Z_Devices zigbee_devices = Z_Devices();
|
||||
|
@ -223,23 +257,47 @@ int32_t Z_Devices::findClusterEndpoint(const std::vector<uint32_t> & vecOfEleme
|
|||
//
|
||||
Z_Device & Z_Devices::createDeviceEntry(uint16_t shortaddr, uint64_t longaddr) {
|
||||
if (!shortaddr && !longaddr) { return *(Z_Device*) nullptr; } // it is not legal to create an enrty with both short/long addr null
|
||||
Z_Device device = { shortaddr, longaddr,
|
||||
Rtc.utc_time, Rtc.utc_time,
|
||||
String(), // ManufId
|
||||
String(), // DeviceId
|
||||
String(), // FriendlyName
|
||||
std::vector<uint32_t>(),
|
||||
std::vector<uint32_t>(),
|
||||
std::vector<uint32_t>(),
|
||||
0,0,0,0,
|
||||
nullptr,
|
||||
//Z_Device* device_alloc = (Z_Device*) malloc(sizeof(Z_Device));
|
||||
Z_Device* device_alloc = new Z_Device{
|
||||
longaddr,
|
||||
nullptr, // ManufId
|
||||
nullptr, // DeviceId
|
||||
nullptr, // FriendlyName
|
||||
std::vector<uint32_t>(), // at least one endpoint
|
||||
std::vector<uint32_t>(), // try not to allocate if not needed
|
||||
std::vector<uint32_t>(), // try not to allocate if not needed
|
||||
nullptr, nullptr,
|
||||
shortaddr,
|
||||
0, // seqNumber
|
||||
};
|
||||
device.json_buffer = new DynamicJsonBuffer();
|
||||
_devices.push_back(device);
|
||||
// Hue support
|
||||
-1, // no Hue support
|
||||
0, // power
|
||||
0, // colormode
|
||||
0, // dimmer
|
||||
0, // sat
|
||||
200, // ct
|
||||
0, // hue
|
||||
0, 0, // x, y
|
||||
};
|
||||
|
||||
device_alloc->json_buffer = new DynamicJsonBuffer(16);
|
||||
_devices.push_back(device_alloc);
|
||||
dirty();
|
||||
return _devices.back();
|
||||
return *(_devices.back());
|
||||
}
|
||||
|
||||
void Z_Devices::freeDeviceEntry(Z_Device *device) {
|
||||
if (device->manufacturerId) { free(device->manufacturerId); }
|
||||
if (device->modelId) { free(device->modelId); }
|
||||
if (device->friendlyName) { free(device->friendlyName); }
|
||||
free(device);
|
||||
}
|
||||
|
||||
void Z_Devices::shrinkToFit(uint16_t shortaddr) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
device.endpoints.shrink_to_fit();
|
||||
device.clusters_in.shrink_to_fit();
|
||||
device.clusters_out.shrink_to_fit();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -255,7 +313,7 @@ int32_t Z_Devices::findShortAddr(uint16_t shortaddr) const {
|
|||
int32_t found = 0;
|
||||
if (shortaddr) {
|
||||
for (auto &elem : _devices) {
|
||||
if (elem.shortaddr == shortaddr) { return found; }
|
||||
if (elem->shortaddr == shortaddr) { return found; }
|
||||
found++;
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +332,7 @@ int32_t Z_Devices::findLongAddr(uint64_t longaddr) const {
|
|||
int32_t found = 0;
|
||||
if (longaddr) {
|
||||
for (auto &elem : _devices) {
|
||||
if (elem.longaddr == longaddr) { return found; }
|
||||
if (elem->longaddr == longaddr) { return found; }
|
||||
found++;
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +352,9 @@ int32_t Z_Devices::findFriendlyName(const char * name) const {
|
|||
int32_t found = 0;
|
||||
if (name_len) {
|
||||
for (auto &elem : _devices) {
|
||||
if (elem.friendlyName == name) { return found; }
|
||||
if (elem->friendlyName) {
|
||||
if (strcmp(elem->friendlyName, name) == 0) { return found; }
|
||||
}
|
||||
found++;
|
||||
}
|
||||
}
|
||||
|
@ -353,7 +413,7 @@ Z_Device & Z_Devices::getShortAddr(uint16_t shortaddr) {
|
|||
if (!shortaddr) { return *(Z_Device*) nullptr; } // this is not legal
|
||||
int32_t found = findShortAddr(shortaddr);
|
||||
if (found >= 0) {
|
||||
return _devices[found];
|
||||
return *(_devices[found]);
|
||||
}
|
||||
//Serial.printf("Device entry created for shortaddr = 0x%02X, found = %d\n", shortaddr, found);
|
||||
return createDeviceEntry(shortaddr, 0);
|
||||
|
@ -363,7 +423,7 @@ const Z_Device & Z_Devices::getShortAddrConst(uint16_t shortaddr) const {
|
|||
if (!shortaddr) { return *(Z_Device*) nullptr; } // this is not legal
|
||||
int32_t found = findShortAddr(shortaddr);
|
||||
if (found >= 0) {
|
||||
return _devices[found];
|
||||
return *(_devices[found]);
|
||||
}
|
||||
return *((Z_Device*)nullptr);
|
||||
}
|
||||
|
@ -373,7 +433,7 @@ Z_Device & Z_Devices::getLongAddr(uint64_t longaddr) {
|
|||
if (!longaddr) { return *(Z_Device*) nullptr; }
|
||||
int32_t found = findLongAddr(longaddr);
|
||||
if (found > 0) {
|
||||
return _devices[found];
|
||||
return *(_devices[found]);
|
||||
}
|
||||
return createDeviceEntry(0, longaddr);
|
||||
}
|
||||
|
@ -382,6 +442,7 @@ Z_Device & Z_Devices::getLongAddr(uint64_t longaddr) {
|
|||
bool Z_Devices::removeDevice(uint16_t shortaddr) {
|
||||
int32_t found = findShortAddr(shortaddr);
|
||||
if (found >= 0) {
|
||||
freeDeviceEntry(_devices.at(found));
|
||||
_devices.erase(_devices.begin() + found);
|
||||
dirty();
|
||||
return true;
|
||||
|
@ -400,24 +461,22 @@ void Z_Devices::updateDevice(uint16_t shortaddr, uint64_t longaddr) {
|
|||
|
||||
if ((s_found >= 0) && (l_found >= 0)) { // both shortaddr and longaddr are already registered
|
||||
if (s_found == l_found) {
|
||||
updateLastSeen(shortaddr); // short/long addr match, all good
|
||||
} else { // they don't match
|
||||
// the device with longaddr got a new shortaddr
|
||||
_devices[l_found].shortaddr = shortaddr; // update the shortaddr corresponding to the longaddr
|
||||
_devices[l_found]->shortaddr = shortaddr; // update the shortaddr corresponding to the longaddr
|
||||
// erase the previous shortaddr
|
||||
freeDeviceEntry(_devices.at(s_found));
|
||||
_devices.erase(_devices.begin() + s_found);
|
||||
updateLastSeen(shortaddr);
|
||||
dirty();
|
||||
}
|
||||
} else if (s_found >= 0) {
|
||||
// shortaddr already exists but longaddr not
|
||||
// add the longaddr to the entry
|
||||
_devices[s_found].longaddr = longaddr;
|
||||
updateLastSeen(shortaddr);
|
||||
_devices[s_found]->longaddr = longaddr;
|
||||
dirty();
|
||||
} else if (l_found >= 0) {
|
||||
// longaddr entry exists, update shortaddr
|
||||
_devices[l_found].shortaddr = shortaddr;
|
||||
_devices[l_found]->shortaddr = shortaddr;
|
||||
dirty();
|
||||
} else {
|
||||
// neither short/lonf addr are found.
|
||||
|
@ -432,10 +491,10 @@ void Z_Devices::updateDevice(uint16_t shortaddr, uint64_t longaddr) {
|
|||
//
|
||||
void Z_Devices::addEndoint(uint16_t shortaddr, uint8_t endpoint) {
|
||||
if (!shortaddr) { return; }
|
||||
if (0x00 == endpoint) { return; }
|
||||
uint32_t ep_profile = (endpoint << 16);
|
||||
Z_Device &device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
_updateLastSeen(device);
|
||||
if (findEndpointInVector(device.endpoints, endpoint) < 0) {
|
||||
device.endpoints.push_back(ep_profile);
|
||||
dirty();
|
||||
|
@ -444,10 +503,10 @@ void Z_Devices::addEndoint(uint16_t shortaddr, uint8_t endpoint) {
|
|||
|
||||
void Z_Devices::addEndointProfile(uint16_t shortaddr, uint8_t endpoint, uint16_t profileId) {
|
||||
if (!shortaddr) { return; }
|
||||
if (0x00 == endpoint) { return; }
|
||||
uint32_t ep_profile = (endpoint << 16) | profileId;
|
||||
Z_Device &device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
_updateLastSeen(device);
|
||||
int32_t found = findEndpointInVector(device.endpoints, endpoint);
|
||||
if (found < 0) {
|
||||
device.endpoints.push_back(ep_profile);
|
||||
|
@ -464,7 +523,6 @@ void Z_Devices::addCluster(uint16_t shortaddr, uint8_t endpoint, uint16_t cluste
|
|||
if (!shortaddr) { return; }
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
_updateLastSeen(device);
|
||||
uint32_t ep_cluster = (endpoint << 16) | cluster;
|
||||
if (!out) {
|
||||
if (!findInVector(device.clusters_in, ep_cluster)) {
|
||||
|
@ -494,64 +552,93 @@ uint8_t Z_Devices::findClusterEndpointIn(uint16_t shortaddr, uint16_t cluster){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Z_Devices::setManufId(uint16_t shortaddr, const char * str) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
_updateLastSeen(device);
|
||||
if (!device.manufacturerId.equals(str)) {
|
||||
dirty();
|
||||
size_t str_len = str ? strlen(str) : 0; // len, handle both null ptr and zero length string
|
||||
|
||||
if ((!device.manufacturerId) && (0 == str_len)) { return; } // if both empty, don't do anything
|
||||
if (device.manufacturerId) {
|
||||
// we already have a value
|
||||
if (strcmp(device.manufacturerId, str) != 0) {
|
||||
// new value
|
||||
free(device.manufacturerId); // free previous value
|
||||
device.manufacturerId = nullptr;
|
||||
} else {
|
||||
return; // same value, don't change anything
|
||||
}
|
||||
}
|
||||
device.manufacturerId = str;
|
||||
if (str_len) {
|
||||
device.manufacturerId = (char*) malloc(str_len + 1);
|
||||
strlcpy(device.manufacturerId, str, str_len + 1);
|
||||
}
|
||||
dirty();
|
||||
}
|
||||
|
||||
void Z_Devices::setModelId(uint16_t shortaddr, const char * str) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
_updateLastSeen(device);
|
||||
if (!device.modelId.equals(str)) {
|
||||
dirty();
|
||||
size_t str_len = str ? strlen(str) : 0; // len, handle both null ptr and zero length string
|
||||
|
||||
if ((!device.modelId) && (0 == str_len)) { return; } // if both empty, don't do anything
|
||||
if (device.modelId) {
|
||||
// we already have a value
|
||||
if (strcmp(device.modelId, str) != 0) {
|
||||
// new value
|
||||
free(device.modelId); // free previous value
|
||||
device.modelId = nullptr;
|
||||
} else {
|
||||
return; // same value, don't change anything
|
||||
}
|
||||
}
|
||||
device.modelId = str;
|
||||
if (str_len) {
|
||||
device.modelId = (char*) malloc(str_len + 1);
|
||||
strlcpy(device.modelId, str, str_len + 1);
|
||||
}
|
||||
dirty();
|
||||
}
|
||||
|
||||
void Z_Devices::setFriendlyName(uint16_t shortaddr, const char * str) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
_updateLastSeen(device);
|
||||
if (!device.friendlyName.equals(str)) {
|
||||
dirty();
|
||||
size_t str_len = str ? strlen(str) : 0; // len, handle both null ptr and zero length string
|
||||
|
||||
if ((!device.friendlyName) && (0 == str_len)) { return; } // if both empty, don't do anything
|
||||
if (device.friendlyName) {
|
||||
// we already have a value
|
||||
if (strcmp(device.friendlyName, str) != 0) {
|
||||
// new value
|
||||
free(device.friendlyName); // free previous value
|
||||
device.friendlyName = nullptr;
|
||||
} else {
|
||||
return; // same value, don't change anything
|
||||
}
|
||||
}
|
||||
device.friendlyName = str;
|
||||
if (str_len) {
|
||||
device.friendlyName = (char*) malloc(str_len + 1);
|
||||
strlcpy(device.friendlyName, str, str_len + 1);
|
||||
}
|
||||
dirty();
|
||||
}
|
||||
|
||||
const String * Z_Devices::getFriendlyName(uint16_t shortaddr) const {
|
||||
const char * Z_Devices::getFriendlyName(uint16_t shortaddr) const {
|
||||
int32_t found = findShortAddr(shortaddr);
|
||||
if (found >= 0) {
|
||||
const Z_Device & device = devicesAt(found);
|
||||
if (device.friendlyName.length() > 0) {
|
||||
return &device.friendlyName;
|
||||
}
|
||||
return device.friendlyName;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const String * Z_Devices::getModelId(uint16_t shortaddr) const {
|
||||
const char * Z_Devices::getModelId(uint16_t shortaddr) const {
|
||||
int32_t found = findShortAddr(shortaddr);
|
||||
if (found >= 0) {
|
||||
const Z_Device & device = devicesAt(found);
|
||||
if (device.modelId.length() > 0) {
|
||||
return &device.modelId;
|
||||
}
|
||||
return device.modelId;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// device just seen on the network, update the lastSeen field
|
||||
void Z_Devices::updateLastSeen(uint16_t shortaddr) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
_updateLastSeen(device);
|
||||
}
|
||||
|
||||
// get the next sequance number for the device, or use the global seq number if device is unknown
|
||||
uint8_t Z_Devices::getNextSeqNumber(uint16_t shortaddr) {
|
||||
int32_t short_found = findShortAddr(shortaddr);
|
||||
|
@ -565,48 +652,120 @@ uint8_t Z_Devices::getNextSeqNumber(uint16_t shortaddr) {
|
|||
}
|
||||
}
|
||||
|
||||
// Per device timers
|
||||
//
|
||||
// Reset the timer for a specific device
|
||||
void Z_Devices::resetTimer(uint32_t shortaddr) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
device.timer = 0;
|
||||
device.func = nullptr;
|
||||
|
||||
// Hue support
|
||||
void Z_Devices::setHueBulbtype(uint16_t shortaddr, int8_t bulbtype) {
|
||||
Z_Device &device = getShortAddr(shortaddr);
|
||||
if (bulbtype != device.bulbtype) {
|
||||
device.bulbtype = bulbtype;
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
int8_t Z_Devices::getHueBulbtype(uint16_t shortaddr) const {
|
||||
int32_t found = findShortAddr(shortaddr);
|
||||
if (found >= 0) {
|
||||
return _devices[found]->bulbtype;
|
||||
} else {
|
||||
return -1; // Hue not activated
|
||||
}
|
||||
}
|
||||
|
||||
// Hue support
|
||||
void Z_Devices::updateHueState(uint16_t shortaddr,
|
||||
const uint8_t *power, const uint8_t *colormode,
|
||||
const uint8_t *dimmer, const uint8_t *sat,
|
||||
const uint16_t *ct, const uint16_t *hue,
|
||||
const uint16_t *x, const uint16_t *y) {
|
||||
Z_Device &device = getShortAddr(shortaddr);
|
||||
if (power) { device.power = *power; }
|
||||
if (colormode){ device.colormode = *colormode; }
|
||||
if (dimmer) { device.dimmer = *dimmer; }
|
||||
if (sat) { device.sat = *sat; }
|
||||
if (ct) { device.ct = *ct; }
|
||||
if (hue) { device.hue = *hue; }
|
||||
if (x) { device.x = *x; }
|
||||
if (y) { device.y = *y; }
|
||||
}
|
||||
|
||||
// return true if ok
|
||||
bool Z_Devices::getHueState(uint16_t shortaddr,
|
||||
uint8_t *power, uint8_t *colormode,
|
||||
uint8_t *dimmer, uint8_t *sat,
|
||||
uint16_t *ct, uint16_t *hue,
|
||||
uint16_t *x, uint16_t *y) const {
|
||||
int32_t found = findShortAddr(shortaddr);
|
||||
if (found >= 0) {
|
||||
const Z_Device &device = *(_devices[found]);
|
||||
if (power) { *power = device.power; }
|
||||
if (colormode){ *colormode = device.colormode; }
|
||||
if (dimmer) { *dimmer = device.dimmer; }
|
||||
if (sat) { *sat = device.sat; }
|
||||
if (ct) { *ct = device.ct; }
|
||||
if (hue) { *hue = device.hue; }
|
||||
if (x) { *x = device.x; }
|
||||
if (y) { *y = device.y; }
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Deferred actions
|
||||
// Parse for a specific category, of all deferred for a device if category == 0xFF
|
||||
void Z_Devices::resetTimersForDevice(uint16_t shortaddr, uint16_t groupaddr, uint8_t category) {
|
||||
// iterate the list of deferred, and remove any linked to the shortaddr
|
||||
for (auto it = _deferred.begin(); it != _deferred.end(); it++) {
|
||||
// Notice that the iterator is decremented after it is passed
|
||||
// to erase() but before erase() is executed
|
||||
// see https://www.techiedelight.com/remove-elements-vector-inside-loop-cpp/
|
||||
if ((it->shortaddr == shortaddr) && (it->groupaddr == groupaddr)) {
|
||||
if ((0xFF == category) || (it->category == category)) {
|
||||
_deferred.erase(it--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set timer for a specific device
|
||||
void Z_Devices::setTimer(uint32_t shortaddr, uint32_t wait_ms, uint16_t cluster, uint16_t endpoint, uint32_t value, Z_DeviceTimer func) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
void Z_Devices::setTimer(uint16_t shortaddr, uint16_t groupaddr, uint32_t wait_ms, uint16_t cluster, uint8_t endpoint, uint8_t category, uint32_t value, Z_DeviceTimer func) {
|
||||
// First we remove any existing timer for same device in same category, except for category=0x00 (they need to happen anyway)
|
||||
if (category) { // if category == 0, we leave all previous
|
||||
resetTimersForDevice(shortaddr, groupaddr, category); // remove any cluster
|
||||
}
|
||||
|
||||
device.cluster = cluster;
|
||||
device.endpoint = endpoint;
|
||||
device.value = value;
|
||||
device.func = func;
|
||||
device.timer = wait_ms + millis();
|
||||
// Now create the new timer
|
||||
Z_Deferred deferred = { wait_ms + millis(), // timer
|
||||
shortaddr,
|
||||
groupaddr,
|
||||
cluster,
|
||||
endpoint,
|
||||
category,
|
||||
value,
|
||||
func };
|
||||
_deferred.push_back(deferred);
|
||||
}
|
||||
|
||||
// Run timer at each tick
|
||||
void Z_Devices::runTimer(void) {
|
||||
for (std::vector<Z_Device>::iterator it = _devices.begin(); it != _devices.end(); ++it) {
|
||||
Z_Device &device = *it;
|
||||
uint16_t shortaddr = device.shortaddr;
|
||||
// visit all timers
|
||||
for (auto it = _deferred.begin(); it != _deferred.end(); it++) {
|
||||
Z_Deferred &defer = *it;
|
||||
|
||||
uint32_t timer = device.timer;
|
||||
if ((timer) && TimeReached(timer)) {
|
||||
device.timer = 0; // cancel the timer before calling, so the callback can set another timer
|
||||
// trigger the timer
|
||||
(*device.func)(device.shortaddr, device.cluster, device.endpoint, device.value);
|
||||
uint32_t timer = defer.timer;
|
||||
if (TimeReached(timer)) {
|
||||
(*defer.func)(defer.shortaddr, defer.groupaddr, defer.cluster, defer.endpoint, defer.value);
|
||||
_deferred.erase(it--); // remove from list
|
||||
}
|
||||
}
|
||||
// save timer
|
||||
|
||||
// check if we need to save to Flash
|
||||
if ((_saveTimer) && TimeReached(_saveTimer)) {
|
||||
saveZigbeeDevices();
|
||||
_saveTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the JSON buffer for coalesced and deferred attributes
|
||||
void Z_Devices::jsonClear(uint16_t shortaddr) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return; } // don't crash if not found
|
||||
|
@ -615,23 +774,26 @@ void Z_Devices::jsonClear(uint16_t shortaddr) {
|
|||
device.json_buffer->clear();
|
||||
}
|
||||
|
||||
// Copy JSON from one object to another, this helps preserving the order of attributes
|
||||
void CopyJsonVariant(JsonObject &to, const String &key, const JsonVariant &val) {
|
||||
// first remove the potentially existing key in the target JSON, so new adds will be at the end of the list
|
||||
to.remove(key); // force remove to have metadata like LinkQuality at the end
|
||||
|
||||
if (val.is<char*>()) {
|
||||
String sval = val.as<String>(); // force a copy of the String value
|
||||
String sval = val.as<String>(); // force a copy of the String value, avoiding crash
|
||||
to.set(key, sval);
|
||||
} else if (val.is<JsonArray>()) {
|
||||
JsonArray &nested_arr = to.createNestedArray(key);
|
||||
CopyJsonArray(nested_arr, val.as<JsonArray>());
|
||||
CopyJsonArray(nested_arr, val.as<JsonArray>()); // deep copy
|
||||
} else if (val.is<JsonObject>()) {
|
||||
JsonObject &nested_obj = to.createNestedObject(key);
|
||||
CopyJsonObject(nested_obj, val.as<JsonObject>());
|
||||
CopyJsonObject(nested_obj, val.as<JsonObject>()); // deep copy
|
||||
} else {
|
||||
to.set(key, val);
|
||||
to.set(key, val); // general case for non array, object or string
|
||||
}
|
||||
}
|
||||
|
||||
// Shallow copy of array, we skip any sub-array or sub-object. It may be added in the future
|
||||
void CopyJsonArray(JsonArray &to, const JsonArray &arr) {
|
||||
for (auto v : arr) {
|
||||
if (v.is<char*>()) {
|
||||
|
@ -645,6 +807,7 @@ void CopyJsonArray(JsonArray &to, const JsonArray &arr) {
|
|||
}
|
||||
}
|
||||
|
||||
// Deep copy of object
|
||||
void CopyJsonObject(JsonObject &to, const JsonObject &from) {
|
||||
for (auto kv : from) {
|
||||
String key_string = kv.key;
|
||||
|
@ -655,6 +818,8 @@ void CopyJsonObject(JsonObject &to, const JsonObject &from) {
|
|||
}
|
||||
|
||||
// does the new payload conflicts with the existing payload, i.e. values would be overwritten
|
||||
// true - one attribute (except LinkQuality) woudl be lost, there is conflict
|
||||
// false - new attributes can be safely added
|
||||
bool Z_Devices::jsonIsConflict(uint16_t shortaddr, const JsonObject &values) {
|
||||
Z_Device & device = getShortAddr(shortaddr);
|
||||
if (&device == nullptr) { return false; } // don't crash if not found
|
||||
|
@ -665,14 +830,14 @@ bool Z_Devices::jsonIsConflict(uint16_t shortaddr, const JsonObject &values) {
|
|||
}
|
||||
|
||||
// compare groups
|
||||
uint16_t group1 = 0;
|
||||
uint16_t group2 = 0;
|
||||
if (device.json->containsKey(D_CMND_ZIGBEE_GROUP)) {
|
||||
group1 = device.json->get<unsigned int>(D_CMND_ZIGBEE_GROUP);
|
||||
}
|
||||
if (values.containsKey(D_CMND_ZIGBEE_GROUP)) {
|
||||
group2 = values.get<unsigned int>(D_CMND_ZIGBEE_GROUP);
|
||||
}
|
||||
// Special case for group addresses. Group attribute is only present if the target
|
||||
// address is a group address, so just comparing attributes will not work.
|
||||
// Eg: if the first packet has no group attribute, and the second does, conflict would not be detected
|
||||
// Here we explicitly compute the group address of both messages, and compare them. No group means group=0x0000
|
||||
// (we use the property of an missing attribute returning 0)
|
||||
// (note: we use .get() here which is case-sensitive. We know however that the attribute was set with the exact syntax D_CMND_ZIGBEE_GROUP, so we don't need a case-insensitive get())
|
||||
uint16_t group1 = device.json->get<unsigned int>(D_CMND_ZIGBEE_GROUP);
|
||||
uint16_t group2 = values.get<unsigned int>(D_CMND_ZIGBEE_GROUP);
|
||||
if (group1 != group2) {
|
||||
return true; // if group addresses differ, then conflict
|
||||
}
|
||||
|
@ -712,9 +877,9 @@ void Z_Devices::jsonAppend(uint16_t shortaddr, const JsonObject &values) {
|
|||
snprintf_P(sa, sizeof(sa), PSTR("0x%04X"), shortaddr);
|
||||
device.json->set(F(D_JSON_ZIGBEE_DEVICE), sa);
|
||||
// Prepend Friendly Name if it has one
|
||||
const String * fname = zigbee_devices.getFriendlyName(shortaddr);
|
||||
const char * fname = zigbee_devices.getFriendlyName(shortaddr);
|
||||
if (fname) {
|
||||
device.json->set(F(D_JSON_ZIGBEE_NAME), (char*)fname->c_str()); // (char*) forces ArduinoJson to make a copy of the cstring
|
||||
device.json->set(F(D_JSON_ZIGBEE_NAME), (char*) fname); // (char*) forces ArduinoJson to make a copy of the cstring
|
||||
}
|
||||
|
||||
// copy all values from 'values' to 'json'
|
||||
|
@ -733,18 +898,9 @@ void Z_Devices::jsonPublishFlush(uint16_t shortaddr) {
|
|||
JsonObject * json = device.json;
|
||||
if (json == nullptr) { return; } // abort if nothing in buffer
|
||||
|
||||
const String * fname = zigbee_devices.getFriendlyName(shortaddr);
|
||||
const char * fname = zigbee_devices.getFriendlyName(shortaddr);
|
||||
bool use_fname = (Settings.flag4.zigbee_use_names) && (fname); // should we replace shortaddr with friendlyname?
|
||||
|
||||
// if (use_fname) {
|
||||
// // we need to add the Device short_addr inside the JSON
|
||||
// char sa[8];
|
||||
// snprintf_P(sa, sizeof(sa), PSTR("0x%04X"), shortaddr);
|
||||
// json->set(F(D_JSON_ZIGBEE_DEVICE), sa);
|
||||
// } else if (fname) {
|
||||
// json->set(F(D_JSON_NAME), (char*) fname);
|
||||
// }
|
||||
|
||||
// Remove redundant "Name" or "Device"
|
||||
if (use_fname) {
|
||||
json->remove(F(D_JSON_ZIGBEE_NAME));
|
||||
|
@ -757,7 +913,7 @@ void Z_Devices::jsonPublishFlush(uint16_t shortaddr) {
|
|||
zigbee_devices.jsonClear(shortaddr);
|
||||
|
||||
if (use_fname) {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"%s\":%s}}"), fname->c_str(), msg.c_str());
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"%s\":%s}}"), fname, msg.c_str());
|
||||
} else {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"0x%04X\":%s}}"), shortaddr, msg.c_str());
|
||||
}
|
||||
|
@ -824,6 +980,58 @@ uint16_t Z_Devices::parseDeviceParam(const char * param, bool short_must_be_know
|
|||
return shortaddr;
|
||||
}
|
||||
|
||||
// Display the tracked status for a light
|
||||
String Z_Devices::dumpLightState(uint16_t shortaddr) const {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
char hex[8];
|
||||
|
||||
int32_t found = findShortAddr(shortaddr);
|
||||
if (found >= 0) {
|
||||
const Z_Device & device = devicesAt(found);
|
||||
const char * fname = getFriendlyName(shortaddr);
|
||||
|
||||
bool use_fname = (Settings.flag4.zigbee_use_names) && (fname); // should we replace shortaddr with friendlyname?
|
||||
|
||||
snprintf_P(hex, sizeof(hex), PSTR("0x%04X"), shortaddr);
|
||||
|
||||
JsonObject& dev = use_fname ? json.createNestedObject((char*) fname) // casting (char*) forces a copy
|
||||
: json.createNestedObject(hex);
|
||||
if (use_fname) {
|
||||
dev[F(D_JSON_ZIGBEE_DEVICE)] = hex;
|
||||
} else if (fname) {
|
||||
dev[F(D_JSON_ZIGBEE_NAME)] = (char*) fname;
|
||||
}
|
||||
|
||||
// expose the last known status of the bulb, for Hue integration
|
||||
dev[F(D_JSON_ZIGBEE_LIGHT)] = device.bulbtype; // sign extend, 0xFF changed as -1
|
||||
if (0 <= device.bulbtype) {
|
||||
// bulbtype is defined
|
||||
dev[F("Power")] = device.power;
|
||||
if (1 <= device.bulbtype) {
|
||||
dev[F("Dimmer")] = device.dimmer;
|
||||
}
|
||||
if (2 <= device.bulbtype) {
|
||||
dev[F("Colormode")] = device.colormode;
|
||||
}
|
||||
if ((2 == device.bulbtype) || (5 == device.bulbtype)) {
|
||||
dev[F("CT")] = device.ct;
|
||||
}
|
||||
if (3 <= device.bulbtype) {
|
||||
dev[F("Sat")] = device.sat;
|
||||
dev[F("Hue")] = device.hue;
|
||||
dev[F("X")] = device.x;
|
||||
dev[F("Y")] = device.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String payload = "";
|
||||
payload.reserve(200);
|
||||
json.printTo(payload);
|
||||
return payload;
|
||||
}
|
||||
|
||||
// Dump the internal memory of Zigbee devices
|
||||
// Mode = 1: simple dump of devices addresses
|
||||
// Mode = 2: simple dump of devices addresses and names
|
||||
|
@ -833,8 +1041,8 @@ String Z_Devices::dump(uint32_t dump_mode, uint16_t status_shortaddr) const {
|
|||
JsonArray& json = jsonBuffer.createArray();
|
||||
JsonArray& devices = json;
|
||||
|
||||
for (std::vector<Z_Device>::const_iterator it = _devices.begin(); it != _devices.end(); ++it) {
|
||||
const Z_Device& device = *it;
|
||||
for (std::vector<Z_Device*>::const_iterator it = _devices.begin(); it != _devices.end(); ++it) {
|
||||
const Z_Device &device = **it;
|
||||
uint16_t shortaddr = device.shortaddr;
|
||||
char hex[22];
|
||||
|
||||
|
@ -846,8 +1054,8 @@ String Z_Devices::dump(uint32_t dump_mode, uint16_t status_shortaddr) const {
|
|||
snprintf_P(hex, sizeof(hex), PSTR("0x%04X"), shortaddr);
|
||||
dev[F(D_JSON_ZIGBEE_DEVICE)] = hex;
|
||||
|
||||
if (device.friendlyName.length() > 0) {
|
||||
dev[F(D_JSON_ZIGBEE_NAME)] = device.friendlyName;
|
||||
if (device.friendlyName > 0) {
|
||||
dev[F(D_JSON_ZIGBEE_NAME)] = (char*) device.friendlyName;
|
||||
}
|
||||
|
||||
if (2 <= dump_mode) {
|
||||
|
@ -855,10 +1063,10 @@ String Z_Devices::dump(uint32_t dump_mode, uint16_t status_shortaddr) const {
|
|||
hex[1] = 'x';
|
||||
Uint64toHex(device.longaddr, &hex[2], 64);
|
||||
dev[F("IEEEAddr")] = hex;
|
||||
if (device.modelId.length() > 0) {
|
||||
if (device.modelId) {
|
||||
dev[F(D_JSON_MODEL D_JSON_ID)] = device.modelId;
|
||||
}
|
||||
if (device.manufacturerId.length() > 0) {
|
||||
if (device.manufacturerId) {
|
||||
dev[F("Manufacturer")] = device.manufacturerId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,301 @@
|
|||
/*
|
||||
xdrv_23_zigbee.ino - zigbee support for Tasmota
|
||||
|
||||
Copyright (C) 2020 Theo Arends and Stephan Hadinger
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifdef USE_ZIGBEE
|
||||
#if defined(USE_WEBSERVER) && defined(USE_EMULATION) && defined(USE_EMULATION_HUE) && defined(USE_LIGHT)
|
||||
|
||||
// Add global functions for Hue Emulation
|
||||
|
||||
// idx: index in the list of zigbee_devices
|
||||
void HueLightStatus1Zigbee(uint16_t shortaddr, uint8_t local_light_subtype, String *response) {
|
||||
uint8_t power, colormode, bri, sat;
|
||||
uint16_t ct, hue;
|
||||
uint16_t x, y;
|
||||
String light_status = "";
|
||||
uint32_t echo_gen = findEchoGeneration(); // 1 for 1st gen =+ Echo Dot 2nd gen, 2 for 2nd gen and above
|
||||
|
||||
zigbee_devices.getHueState(shortaddr, &power, &colormode, &bri, &sat, &ct, &hue, &x, &y);
|
||||
|
||||
if (bri > 254) bri = 254; // Philips Hue bri is between 1 and 254
|
||||
if (bri < 1) bri = 1;
|
||||
if (sat > 254) sat = 254; // Philips Hue only accepts 254 as max hue
|
||||
uint8_t hue8 = changeUIntScale(hue, 0, 360, 0, 254); // default hue is 0..254, we don't use extended hue
|
||||
|
||||
const size_t buf_size = 256;
|
||||
char * buf = (char*) malloc(buf_size); // temp buffer for strings, avoid stack
|
||||
|
||||
snprintf_P(buf, buf_size, PSTR("{\"on\":%s,"), (power & 1) ? "true" : "false");
|
||||
// Brightness for all devices with PWM
|
||||
if ((1 == echo_gen) || (LST_SINGLE <= local_light_subtype)) { // force dimmer for 1st gen Echo
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"bri\":%d,"), buf, bri);
|
||||
}
|
||||
if (LST_COLDWARM <= local_light_subtype) {
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"colormode\":\"%s\","), buf, (0 == colormode) ? "hs" : (1 == colormode) ? "xy" : "ct");
|
||||
}
|
||||
if (LST_RGB <= local_light_subtype) { // colors
|
||||
if (prev_x_str[0] && prev_y_str[0]) {
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"xy\":[%s,%s],"), buf, prev_x_str, prev_y_str);
|
||||
} else {
|
||||
float x_f = x / 65536.0f;
|
||||
float y_f = y / 65536.0f;
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"xy\":[%s,%s],"), buf, String(x, 5).c_str(), String(y, 5).c_str());
|
||||
}
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"hue\":%d,\"sat\":%d,"), buf, hue, sat);
|
||||
}
|
||||
if (LST_COLDWARM == local_light_subtype || LST_RGBW <= local_light_subtype) { // white temp
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"ct\":%d,"), buf, ct > 0 ? ct : 284);
|
||||
}
|
||||
snprintf_P(buf, buf_size, HUE_LIGHTS_STATUS_JSON1_SUFFIX, buf);
|
||||
|
||||
*response += buf;
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void HueLightStatus2Zigbee(uint16_t shortaddr, String *response)
|
||||
{
|
||||
const size_t buf_size = 192;
|
||||
char * buf = (char*) malloc(buf_size);
|
||||
|
||||
const char * friendlyName = zigbee_devices.getFriendlyName(shortaddr);
|
||||
char shortaddrname[8];
|
||||
snprintf_P(shortaddrname, sizeof(shortaddrname), PSTR("0x%04X"), shortaddr);
|
||||
|
||||
snprintf_P(buf, buf_size, HUE_LIGHTS_STATUS_JSON2,
|
||||
(friendlyName) ? friendlyName : shortaddrname,
|
||||
GetHueDeviceId(shortaddr).c_str());
|
||||
*response += buf;
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void ZigbeeHueStatus(String * response, uint16_t shortaddr) {
|
||||
*response += F("{\"state\":");
|
||||
HueLightStatus1Zigbee(shortaddr, zigbee_devices.getHueBulbtype(shortaddr), response);
|
||||
HueLightStatus2Zigbee(shortaddr, response);
|
||||
}
|
||||
|
||||
void ZigbeeCheckHue(String * response, bool &appending) {
|
||||
uint32_t zigbee_num = zigbee_devices.devicesSize();
|
||||
for (uint32_t i = 0; i < zigbee_num; i++) {
|
||||
int8_t bulbtype = zigbee_devices.devicesAt(i).bulbtype;
|
||||
|
||||
if (bulbtype >= 0) {
|
||||
uint16_t shortaddr = zigbee_devices.devicesAt(i).shortaddr;
|
||||
// this bulb is advertized
|
||||
if (appending) { *response += ","; }
|
||||
*response += "\"";
|
||||
*response += EncodeLightId(0, shortaddr);
|
||||
*response += F("\":{\"state\":");
|
||||
HueLightStatus1Zigbee(shortaddr, bulbtype, response); // TODO
|
||||
HueLightStatus2Zigbee(shortaddr, response);
|
||||
appending = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZigbeeHueGroups(String * lights) {
|
||||
uint32_t zigbee_num = zigbee_devices.devicesSize();
|
||||
for (uint32_t i = 0; i < zigbee_num; i++) {
|
||||
int8_t bulbtype = zigbee_devices.devicesAt(i).bulbtype;
|
||||
|
||||
if (bulbtype >= 0) {
|
||||
*lights += ",\"";
|
||||
*lights += EncodeLightId(i);
|
||||
*lights += "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send commands
|
||||
// Power On/Off
|
||||
void ZigbeeHuePower(uint16_t shortaddr, uint8_t power) {
|
||||
zigbeeZCLSendStr(shortaddr, 0, 0, true, 0x0006, power, "");
|
||||
zigbee_devices.updateHueState(shortaddr, &power, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
// Dimmer
|
||||
void ZigbeeHueDimmer(uint16_t shortaddr, uint8_t dimmer) {
|
||||
char param[8];
|
||||
snprintf_P(param, sizeof(param), PSTR("%02X0A00"), dimmer);
|
||||
zigbeeZCLSendStr(shortaddr, 0, 0, true, 0x0008, 0x04, param);
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, nullptr, &dimmer, nullptr, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
// CT
|
||||
void ZigbeeHueCT(uint16_t shortaddr, uint16_t ct) {
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeHueCT 0x%04X - %d"), shortaddr, ct);
|
||||
char param[12];
|
||||
snprintf_P(param, sizeof(param), PSTR("%02X%02X0A00"), ct & 0xFF, ct >> 8);
|
||||
uint8_t colormode = 2; // "ct"
|
||||
zigbeeZCLSendStr(shortaddr, 0, 0, true, 0x0300, 0x0A, param);
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, &colormode, nullptr, nullptr, &ct, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
// XY
|
||||
void ZigbeeHueXY(uint16_t shortaddr, uint16_t x, uint16_t y) {
|
||||
char param[16];
|
||||
snprintf_P(param, sizeof(param), PSTR("%02X%02X%02X%02X0A00"), x & 0xFF, x >> 8, y & 0xFF, y >> 8);
|
||||
uint8_t colormode = 1; // "xy"
|
||||
zigbeeZCLSendStr(shortaddr, 0, 0, true, 0x0300, 0x07, param);
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, &colormode, nullptr, nullptr, nullptr, nullptr, &x, &y);
|
||||
}
|
||||
|
||||
// HueSat
|
||||
void ZigbeeHueHS(uint16_t shortaddr, uint16_t hue, uint8_t sat) {
|
||||
char param[16];
|
||||
uint8_t hue8 = changeUIntScale(hue, 0, 360, 0, 254);
|
||||
snprintf_P(param, sizeof(param), PSTR("%02X%02X0A00"), hue8, sat);
|
||||
uint8_t colormode = 0; // "hs"
|
||||
zigbeeZCLSendStr(shortaddr, 0, 0, true, 0x0300, 0x06, param);
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, &colormode, nullptr, &sat, nullptr, &hue, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void ZigbeeHandleHue(uint16_t shortaddr, uint32_t device_id, String &response) {
|
||||
uint8_t power, colormode, bri, sat;
|
||||
uint16_t ct, hue;
|
||||
float x, y;
|
||||
int code = 200;
|
||||
|
||||
bool resp = false; // is the response non null (add comma between parameters)
|
||||
bool on = false;
|
||||
|
||||
uint8_t bulbtype = zigbee_devices.getHueBulbtype(shortaddr);
|
||||
|
||||
const size_t buf_size = 100;
|
||||
char * buf = (char*) malloc(buf_size);
|
||||
|
||||
if (WebServer->args()) {
|
||||
response = "[";
|
||||
|
||||
StaticJsonBuffer<300> jsonBuffer;
|
||||
JsonObject &hue_json = jsonBuffer.parseObject(WebServer->arg((WebServer->args())-1));
|
||||
if (hue_json.containsKey("on")) {
|
||||
on = hue_json["on"];
|
||||
snprintf_P(buf, buf_size,
|
||||
PSTR("{\"success\":{\"/lights/%d/state/on\":%s}}"),
|
||||
device_id, on ? "true" : "false");
|
||||
|
||||
switch(on)
|
||||
{
|
||||
case false : ZigbeeHuePower(shortaddr, 0x00);
|
||||
break;
|
||||
case true : ZigbeeHuePower(shortaddr, 0x01);
|
||||
break;
|
||||
}
|
||||
response += buf;
|
||||
resp = true;
|
||||
}
|
||||
|
||||
if (hue_json.containsKey("bri")) { // Brightness is a scale from 1 (the minimum the light is capable of) to 254 (the maximum). Note: a brightness of 1 is not off.
|
||||
bri = hue_json["bri"];
|
||||
prev_bri = bri; // store command value
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
PSTR("{\"success\":{\"/lights/%d/state/%s\":%d}}"),
|
||||
device_id, "bri", bri);
|
||||
response += buf;
|
||||
if (LST_SINGLE <= bulbtype) {
|
||||
// extend bri value if set to max
|
||||
if (254 <= bri) { bri = 255; }
|
||||
ZigbeeHueDimmer(shortaddr, bri);
|
||||
}
|
||||
resp = true;
|
||||
}
|
||||
// handle xy before Hue/Sat
|
||||
// If the request contains both XY and HS, we wan't to give priority to HS
|
||||
if (hue_json.containsKey("xy")) {
|
||||
float x = hue_json["xy"][0];
|
||||
float y = hue_json["xy"][1];
|
||||
const String &x_str = hue_json["xy"][0];
|
||||
const String &y_str = hue_json["xy"][1];
|
||||
x_str.toCharArray(prev_x_str, sizeof(prev_x_str));
|
||||
y_str.toCharArray(prev_y_str, sizeof(prev_y_str));
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
PSTR("{\"success\":{\"/lights/%d/state/xy\":[%s,%s]}}"),
|
||||
device_id, prev_x_str, prev_y_str);
|
||||
response += buf;
|
||||
resp = true;
|
||||
uint16_t xi = x * 65536.0f;
|
||||
uint16_t yi = y * 65536.0f;
|
||||
ZigbeeHueXY(shortaddr, xi, yi);
|
||||
}
|
||||
bool huesat_changed = false;
|
||||
if (hue_json.containsKey("hue")) { // The hue value is a wrapping value between 0 and 65535. Both 0 and 65535 are red, 25500 is green and 46920 is blue.
|
||||
hue = hue_json["hue"];
|
||||
prev_hue = hue;
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
PSTR("{\"success\":{\"/lights/%d/state/%s\":%d}}"),
|
||||
device_id, "hue", hue);
|
||||
response += buf;
|
||||
if (LST_RGB <= bulbtype) {
|
||||
// change range from 0..65535 to 0..359
|
||||
hue = changeUIntScale(hue, 0, 65535, 0, 359);
|
||||
huesat_changed = true;
|
||||
}
|
||||
resp = true;
|
||||
}
|
||||
if (hue_json.containsKey("sat")) { // Saturation of the light. 254 is the most saturated (colored) and 0 is the least saturated (white).
|
||||
sat = hue_json["sat"];
|
||||
prev_sat = sat; // store command value
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
PSTR("{\"success\":{\"/lights/%d/state/%s\":%d}}"),
|
||||
device_id, "sat", sat);
|
||||
response += buf;
|
||||
if (LST_RGB <= bulbtype) {
|
||||
// extend sat value if set to max
|
||||
if (254 <= sat) { sat = 255; }
|
||||
huesat_changed = true;
|
||||
}
|
||||
if (huesat_changed) {
|
||||
ZigbeeHueHS(shortaddr, hue, sat);
|
||||
}
|
||||
resp = true;
|
||||
}
|
||||
if (hue_json.containsKey("ct")) { // Color temperature 153 (Cold) to 500 (Warm)
|
||||
ct = hue_json["ct"];
|
||||
prev_ct = ct; // store commande value
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
PSTR("{\"success\":{\"/lights/%d/state/%s\":%d}}"),
|
||||
device_id, "ct", ct);
|
||||
response += buf;
|
||||
if ((LST_COLDWARM == bulbtype) || (LST_RGBW <= bulbtype)) {
|
||||
ZigbeeHueCT(shortaddr, ct);
|
||||
}
|
||||
resp = true;
|
||||
}
|
||||
|
||||
response += "]";
|
||||
if (2 == response.length()) {
|
||||
response = FPSTR(HUE_ERROR_JSON);
|
||||
}
|
||||
}
|
||||
else {
|
||||
response = FPSTR(HUE_ERROR_JSON);
|
||||
}
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str());
|
||||
WSSend(code, CT_JSON, response);
|
||||
|
||||
free(buf);
|
||||
}
|
||||
|
||||
#endif // USE_WEBSERVER && USE_EMULATION && USE_EMULATION_HUE
|
||||
#endif // USE_ZIGBEE
|
|
@ -45,6 +45,8 @@
|
|||
// str - Manuf (null terminated C string, 32 chars max)
|
||||
// str - FriendlyName (null terminated C string, 32 chars max)
|
||||
// reserved for extensions
|
||||
// -- V2 --
|
||||
// int8_t - bulbtype
|
||||
|
||||
// Memory footprint
|
||||
const static uint16_t z_spi_start_sector = 0xFF; // Force last bank of first MB
|
||||
|
@ -141,23 +143,32 @@ class SBuffer hibernateDevice(const struct Z_Device &device) {
|
|||
}
|
||||
|
||||
// ModelID
|
||||
size_t model_len = device.modelId.length();
|
||||
if (model_len > 32) { model_len = 32; } // max 32 chars
|
||||
buf.addBuffer(device.modelId.c_str(), model_len);
|
||||
if (device.modelId) {
|
||||
size_t model_len = strlen(device.modelId);
|
||||
if (model_len > 32) { model_len = 32; } // max 32 chars
|
||||
buf.addBuffer(device.modelId, model_len);
|
||||
}
|
||||
buf.add8(0x00); // end of string marker
|
||||
|
||||
// ManufID
|
||||
size_t manuf_len = device.manufacturerId.length();
|
||||
if (manuf_len > 32) {manuf_len = 32; } // max 32 chars
|
||||
buf.addBuffer(device.manufacturerId.c_str(), manuf_len);
|
||||
if (device.manufacturerId) {
|
||||
size_t manuf_len = strlen(device.manufacturerId);
|
||||
if (manuf_len > 32) { manuf_len = 32; } // max 32 chars
|
||||
buf.addBuffer(device.manufacturerId, manuf_len);
|
||||
}
|
||||
buf.add8(0x00); // end of string marker
|
||||
|
||||
// FriendlyName
|
||||
size_t frname_len = device.friendlyName.length();
|
||||
if (frname_len > 32) {frname_len = 32; } // max 32 chars
|
||||
buf.addBuffer(device.friendlyName.c_str(), frname_len);
|
||||
if (device.friendlyName) {
|
||||
size_t frname_len = strlen(device.friendlyName);
|
||||
if (frname_len > 32) {frname_len = 32; } // max 32 chars
|
||||
buf.addBuffer(device.friendlyName, frname_len);
|
||||
}
|
||||
buf.add8(0x00); // end of string marker
|
||||
|
||||
// Hue Bulbtype
|
||||
buf.add8(device.bulbtype);
|
||||
|
||||
// update overall length
|
||||
buf.set8(0, buf.len());
|
||||
|
||||
|
@ -193,18 +204,28 @@ class SBuffer hibernateDevices(void) {
|
|||
return buf;
|
||||
}
|
||||
|
||||
void hidrateDevices(const SBuffer &buf) {
|
||||
void hydrateDevices(const SBuffer &buf) {
|
||||
uint32_t buf_len = buf.len();
|
||||
if (buf_len <= 10) { return; }
|
||||
|
||||
uint32_t k = 0;
|
||||
uint32_t num_devices = buf.get8(k++);
|
||||
|
||||
//size_t before = 0;
|
||||
for (uint32_t i = 0; (i < num_devices) && (k < buf_len); i++) {
|
||||
uint32_t dev_record_len = buf.get8(k);
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Device %d Before Memory = %d // DIFF %d // record_len %d"), i, ESP.getFreeHeap(), before - ESP.getFreeHeap(), dev_record_len);
|
||||
// before = ESP.getFreeHeap();
|
||||
|
||||
SBuffer buf_d = buf.subBuffer(k, dev_record_len);
|
||||
|
||||
// char *hex_char = (char*) malloc((dev_record_len * 2) + 2);
|
||||
// if (hex_char) {
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "/// SUB %s"),
|
||||
// ToHex_P(buf_d.getBuffer(), dev_record_len, hex_char, (dev_record_len * 2) + 2));
|
||||
// free(hex_char);
|
||||
// }
|
||||
|
||||
uint32_t d = 1; // index in device buffer
|
||||
uint16_t shortaddr = buf_d.get16(d); d += 2;
|
||||
uint64_t longaddr = buf_d.get64(d); d += 8;
|
||||
|
@ -229,7 +250,9 @@ void hidrateDevices(const SBuffer &buf) {
|
|||
zigbee_devices.addCluster(shortaddr, ep, fromClusterCode(ep_cluster), true);
|
||||
}
|
||||
}
|
||||
|
||||
zigbee_devices.shrinkToFit(shortaddr);
|
||||
//AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Device 0x%04X Memory3.shrink = %d"), shortaddr, ESP.getFreeHeap());
|
||||
|
||||
// parse 3 strings
|
||||
char empty[] = "";
|
||||
|
||||
|
@ -251,14 +274,22 @@ void hidrateDevices(const SBuffer &buf) {
|
|||
zigbee_devices.setFriendlyName(shortaddr, ptr);
|
||||
d += s_len + 1;
|
||||
|
||||
// Hue bulbtype - if present
|
||||
if (d < dev_record_len) {
|
||||
zigbee_devices.setHueBulbtype(shortaddr, buf_d.get8(d));
|
||||
d++;
|
||||
}
|
||||
|
||||
// next iteration
|
||||
k += dev_record_len;
|
||||
//AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Device %d After Memory = %d"), i, ESP.getFreeHeap());
|
||||
}
|
||||
}
|
||||
|
||||
void loadZigbeeDevices(void) {
|
||||
z_flashdata_t flashdata;
|
||||
memcpy_P(&flashdata, z_dev_start, sizeof(z_flashdata_t));
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Memory %d"), ESP.getFreeHeap());
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Zigbee signature in Flash: %08X - %d"), flashdata.name, flashdata.len);
|
||||
|
||||
// Check the signature
|
||||
|
@ -268,11 +299,12 @@ void loadZigbeeDevices(void) {
|
|||
SBuffer buf(buf_len);
|
||||
buf.addBuffer(z_dev_start + sizeof(z_flashdata_t), buf_len);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee devices data in Flash (%d bytes)"), buf_len);
|
||||
hidrateDevices(buf);
|
||||
hydrateDevices(buf);
|
||||
zigbee_devices.clean(); // don't write back to Flash what we just loaded
|
||||
} else {
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No zigbee devices data in Flash"));
|
||||
}
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Memory %d"), ESP.getFreeHeap());
|
||||
}
|
||||
|
||||
void saveZigbeeDevices(void) {
|
||||
|
|
|
@ -39,13 +39,13 @@ class ZCLFrame {
|
|||
public:
|
||||
|
||||
ZCLFrame(uint8_t frame_control, uint16_t manuf_code, uint8_t transact_seq, uint8_t cmd_id,
|
||||
const char *buf, size_t buf_len, uint16_t clusterid, uint16_t groupid,
|
||||
const char *buf, size_t buf_len, uint16_t clusterid, uint16_t groupaddr,
|
||||
uint16_t srcaddr, uint8_t srcendpoint, uint8_t dstendpoint, uint8_t wasbroadcast,
|
||||
uint8_t linkquality, uint8_t securityuse, uint8_t seqnumber,
|
||||
uint32_t timestamp):
|
||||
_cmd_id(cmd_id), _manuf_code(manuf_code), _transact_seq(transact_seq),
|
||||
_payload(buf_len ? buf_len : 250), // allocate the data frame from source or preallocate big enough
|
||||
_cluster_id(clusterid), _group_id(groupid),
|
||||
_cluster_id(clusterid), _groupaddr(groupaddr),
|
||||
_srcaddr(srcaddr), _srcendpoint(srcendpoint), _dstendpoint(dstendpoint), _wasbroadcast(wasbroadcast),
|
||||
_linkquality(linkquality), _securityuse(securityuse), _seqnumber(seqnumber),
|
||||
_timestamp(timestamp)
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
"\"timestamp\":%d,"
|
||||
"\"fc\":\"0x%02X\",\"manuf\":\"0x%04X\",\"transact\":%d,"
|
||||
"\"cmdid\":\"0x%02X\",\"payload\":\"%s\"}}"),
|
||||
_group_id, _cluster_id, _srcaddr,
|
||||
_groupaddr, _cluster_id, _srcaddr,
|
||||
_srcendpoint, _dstendpoint, _wasbroadcast,
|
||||
_linkquality, _securityuse, _seqnumber,
|
||||
_timestamp,
|
||||
|
@ -117,7 +117,7 @@ public:
|
|||
void postProcessAttributes(uint16_t shortaddr, JsonObject& json);
|
||||
|
||||
inline void setGroupId(uint16_t groupid) {
|
||||
_group_id = groupid;
|
||||
_groupaddr = groupid;
|
||||
}
|
||||
|
||||
inline void setClusterId(uint16_t clusterid) {
|
||||
|
@ -150,7 +150,7 @@ private:
|
|||
uint8_t _transact_seq = 0; // transaction sequence number
|
||||
uint8_t _cmd_id = 0;
|
||||
uint16_t _cluster_id = 0;
|
||||
uint16_t _group_id = 0;
|
||||
uint16_t _groupaddr = 0;
|
||||
SBuffer _payload;
|
||||
// information from decoded ZCL frame
|
||||
uint16_t _srcaddr;
|
||||
|
@ -210,6 +210,7 @@ uint32_t parseSingleAttribute(JsonObject& json, char *attrid_str, class SBuffer
|
|||
}
|
||||
break;
|
||||
case 0x20: // uint8
|
||||
case 0x30: // enum8
|
||||
{
|
||||
uint8_t uint8_val = buf.get8(i);
|
||||
i += 1;
|
||||
|
@ -219,6 +220,7 @@ uint32_t parseSingleAttribute(JsonObject& json, char *attrid_str, class SBuffer
|
|||
}
|
||||
break;
|
||||
case 0x21: // uint16
|
||||
case 0x31: // enum16
|
||||
{
|
||||
uint16_t uint16_val = buf.get16(i);
|
||||
i += 2;
|
||||
|
@ -358,11 +360,6 @@ uint32_t parseSingleAttribute(JsonObject& json, char *attrid_str, class SBuffer
|
|||
json[attrid_str] = uint32_val;
|
||||
}
|
||||
break;
|
||||
// enum
|
||||
case 0x30: // enum8
|
||||
case 0x31: // enum16
|
||||
i += attrtype - 0x2F;
|
||||
break;
|
||||
|
||||
// TODO
|
||||
case 0x39: // float
|
||||
|
@ -499,9 +496,9 @@ void ZCLFrame::parseResponse(void) {
|
|||
snprintf_P(s, sizeof(s), PSTR("0x%04X"), _srcaddr);
|
||||
json[F(D_JSON_ZIGBEE_DEVICE)] = s;
|
||||
// "Name"
|
||||
const String * friendlyName = zigbee_devices.getFriendlyName(_srcaddr);
|
||||
const char * friendlyName = zigbee_devices.getFriendlyName(_srcaddr);
|
||||
if (friendlyName) {
|
||||
json[F(D_JSON_ZIGBEE_NAME)] = *friendlyName;
|
||||
json[F(D_JSON_ZIGBEE_NAME)] = (char*) friendlyName;
|
||||
}
|
||||
// "Command"
|
||||
snprintf_P(s, sizeof(s), PSTR("%04X!%02X"), _cluster_id, cmd);
|
||||
|
@ -516,8 +513,8 @@ void ZCLFrame::parseResponse(void) {
|
|||
// Add Endpoint
|
||||
json[F(D_CMND_ZIGBEE_ENDPOINT)] = _srcendpoint;
|
||||
// Add Group if non-zero
|
||||
if (_group_id) {
|
||||
json[F(D_CMND_ZIGBEE_GROUP)] = _group_id;
|
||||
if (_groupaddr) {
|
||||
json[F(D_CMND_ZIGBEE_GROUP)] = _groupaddr;
|
||||
}
|
||||
// Add linkquality
|
||||
json[F(D_CMND_ZIGBEE_LINKQUALITY)] = _linkquality;
|
||||
|
@ -534,6 +531,7 @@ void ZCLFrame::parseResponse(void) {
|
|||
// Parse non-normalized attributes
|
||||
void ZCLFrame::parseClusterSpecificCommand(JsonObject& json, uint8_t offset) {
|
||||
convertClusterSpecific(json, _cluster_id, _cmd_id, _frame_control.b.direction, _payload);
|
||||
sendHueUpdate(_srcaddr, _groupaddr, _cluster_id, _cmd_id, _frame_control.b.direction);
|
||||
}
|
||||
|
||||
// return value:
|
||||
|
@ -547,331 +545,419 @@ typedef struct Z_AttributeConverter {
|
|||
Z_AttrConverter func;
|
||||
} Z_AttributeConverter;
|
||||
|
||||
ZF(ZCLVersion) ZF(AppVersion) ZF(StackVersion) ZF(HWVersion) ZF(Manufacturer) ZF(ModelId)
|
||||
ZF(DateCode) ZF(PowerSource) ZF(SWBuildID) ZF(Power) ZF(SwitchType) ZF(Dimmer)
|
||||
ZF(MainsVoltage) ZF(MainsFrequency) ZF(BatteryVoltage) ZF(BatteryPercentage)
|
||||
ZF(CurrentTemperature) ZF(MinTempExperienced) ZF(MaxTempExperienced) ZF(OverTempTotalDwell)
|
||||
ZF(AlarmCount) ZF(Time) ZF(TimeStatus) ZF(TimeZone) ZF(DstStart) ZF(DstEnd)
|
||||
ZF(DstShift) ZF(StandardTime) ZF(LocalTime) ZF(LastSetTime) ZF(ValidUntilTime)
|
||||
|
||||
ZF(LocationType) ZF(LocationMethod) ZF(LocationAge) ZF(QualityMeasure) ZF(NumberOfDevices)
|
||||
|
||||
ZF(AnalogInActiveText) ZF(AnalogInDescription) ZF(AnalogInInactiveText) ZF(AnalogInMaxValue)
|
||||
ZF(AnalogInMinValue) ZF(AnalogInOutOfService) ZF(AqaraRotate) ZF(AnalogInPriorityArray)
|
||||
ZF(AnalogInReliability) ZF(AnalogInRelinquishDefault) ZF(AnalogInResolution) ZF(AnalogInStatusFlags)
|
||||
ZF(AnalogInEngineeringUnits) ZF(AnalogInApplicationType) ZF(Aqara_FF05)
|
||||
|
||||
ZF(AnalogOutDescription) ZF(AnalogOutMaxValue) ZF(AnalogOutMinValue) ZF(AnalogOutOutOfService)
|
||||
ZF(AnalogOutValue) ZF(AnalogOutPriorityArray) ZF(AnalogOutReliability) ZF(AnalogOutRelinquishDefault)
|
||||
ZF(AnalogOutResolution) ZF(AnalogOutStatusFlags) ZF(AnalogOutEngineeringUnits) ZF(AnalogOutApplicationType)
|
||||
|
||||
ZF(AnalogDescription) ZF(AnalogOutOfService) ZF(AnalogValue) ZF(AnalogPriorityArray) ZF(AnalogReliability)
|
||||
ZF(AnalogRelinquishDefault) ZF(AnalogStatusFlags) ZF(AnalogEngineeringUnits) ZF(AnalogApplicationType)
|
||||
|
||||
ZF(BinaryInActiveText) ZF(BinaryInDescription) ZF(BinaryInInactiveText) ZF(BinaryInOutOfService)
|
||||
ZF(BinaryInPolarity) ZF(BinaryInValue) ZF(BinaryInPriorityArray) ZF(BinaryInReliability)
|
||||
ZF(BinaryInStatusFlags) ZF(BinaryInApplicationType)
|
||||
|
||||
ZF(BinaryOutActiveText) ZF(BinaryOutDescription) ZF(BinaryOutInactiveText) ZF(BinaryOutMinimumOffTime)
|
||||
ZF(BinaryOutMinimumOnTime) ZF(BinaryOutOutOfService) ZF(BinaryOutPolarity) ZF(BinaryOutValue)
|
||||
ZF(BinaryOutPriorityArray) ZF(BinaryOutReliability) ZF(BinaryOutRelinquishDefault) ZF(BinaryOutStatusFlags)
|
||||
ZF(BinaryOutApplicationType)
|
||||
|
||||
ZF(BinaryActiveText) ZF(BinaryDescription) ZF(BinaryInactiveText) ZF(BinaryMinimumOffTime)
|
||||
ZF(BinaryMinimumOnTime) ZF(BinaryOutOfService) ZF(BinaryValue) ZF(BinaryPriorityArray) ZF(BinaryReliability)
|
||||
ZF(BinaryRelinquishDefault) ZF(BinaryStatusFlags) ZF(BinaryApplicationType)
|
||||
|
||||
ZF(MultiInStateText) ZF(MultiInDescription) ZF(MultiInNumberOfStates) ZF(MultiInOutOfService)
|
||||
ZF(MultiInValue) ZF(MultiInReliability) ZF(MultiInStatusFlags) ZF(MultiInApplicationType)
|
||||
|
||||
ZF(MultiOutStateText) ZF(MultiOutDescription) ZF(MultiOutNumberOfStates) ZF(MultiOutOutOfService)
|
||||
ZF(MultiOutValue) ZF(MultiOutPriorityArray) ZF(MultiOutReliability) ZF(MultiOutRelinquishDefault)
|
||||
ZF(MultiOutStatusFlags) ZF(MultiOutApplicationType)
|
||||
|
||||
ZF(MultiStateText) ZF(MultiDescription) ZF(MultiNumberOfStates) ZF(MultiOutOfService) ZF(MultiValue)
|
||||
ZF(MultiReliability) ZF(MultiRelinquishDefault) ZF(MultiStatusFlags) ZF(MultiApplicationType)
|
||||
|
||||
ZF(TotalProfileNum) ZF(MultipleScheduling) ZF(EnergyFormatting) ZF(EnergyRemote) ZF(ScheduleMode)
|
||||
|
||||
ZF(CheckinInterval) ZF(LongPollInterval) ZF(ShortPollInterval) ZF(FastPollTimeout) ZF(CheckinIntervalMin)
|
||||
ZF(LongPollIntervalMin) ZF(FastPollTimeoutMax)
|
||||
|
||||
ZF(PhysicalClosedLimit) ZF(MotorStepSize) ZF(Status) ZF(ClosedLimit) ZF(Mode)
|
||||
|
||||
ZF(LockState) ZF(LockType) ZF(ActuatorEnabled) ZF(DoorState) ZF(DoorOpenEvents)
|
||||
ZF(DoorClosedEvents) ZF(OpenPeriod)
|
||||
|
||||
ZF(AqaraVibrationMode) ZF(AqaraVibrationsOrAngle) ZF(AqaraVibration505) ZF(AqaraAccelerometer)
|
||||
|
||||
ZF(WindowCoveringType) ZF(PhysicalClosedLimitLift) ZF(PhysicalClosedLimitTilt) ZF(CurrentPositionLift)
|
||||
ZF(CurrentPositionTilt) ZF(NumberofActuationsLift) ZF(NumberofActuationsTilt) ZF(ConfigStatus)
|
||||
ZF(CurrentPositionLiftPercentage) ZF(CurrentPositionTiltPercentage) ZF(InstalledOpenLimitLift)
|
||||
ZF(InstalledClosedLimitLift) ZF(InstalledOpenLimitTilt) ZF(InstalledClosedLimitTilt) ZF(VelocityLift)
|
||||
ZF(AccelerationTimeLift) ZF(DecelerationTimeLift) ZF(IntermediateSetpointsLift)
|
||||
ZF(IntermediateSetpointsTilt)
|
||||
|
||||
ZF(Hue) ZF(Sat) ZF(RemainingTime) ZF(X) ZF(Y) ZF(DriftCompensation) ZF(CompensationText) ZF(CT)
|
||||
ZF(ColorMode) ZF(NumberOfPrimaries) ZF(Primary1X) ZF(Primary1Y) ZF(Primary1Intensity) ZF(Primary2X)
|
||||
ZF(Primary2Y) ZF(Primary2Intensity) ZF(Primary3X) ZF(Primary3Y) ZF(Primary3Intensity) ZF(WhitePointX)
|
||||
ZF(WhitePointY) ZF(ColorPointRX) ZF(ColorPointRY) ZF(ColorPointRIntensity) ZF(ColorPointGX) ZF(ColorPointGY)
|
||||
ZF(ColorPointGIntensity) ZF(ColorPointBX) ZF(ColorPointBY) ZF(ColorPointBIntensity)
|
||||
|
||||
ZF(Illuminance) ZF(IlluminanceMinMeasuredValue) ZF(IlluminanceMaxMeasuredValue) ZF(IlluminanceTolerance)
|
||||
ZF(IlluminanceLightSensorType) ZF(IlluminanceLevelStatus)
|
||||
|
||||
ZF(Temperature) ZF(TemperatureMinMeasuredValue) ZF(TemperatureMaxMeasuredValue) ZF(TemperatureTolerance)
|
||||
|
||||
ZF(PressureUnit) ZF(Pressure) ZF(PressureMinMeasuredValue) ZF(PressureMaxMeasuredValue) ZF(PressureTolerance)
|
||||
ZF(PressureScaledValue) ZF(PressureMinScaledValue) ZF(PressureMaxScaledValue) ZF(PressureScaledTolerance)
|
||||
ZF(PressureScale)
|
||||
|
||||
ZF(FlowRate) ZF(FlowMinMeasuredValue) ZF(FlowMaxMeasuredValue) ZF(FlowTolerance)
|
||||
|
||||
ZF(Humidity) ZF(HumidityMinMeasuredValue) ZF(HumidityMaxMeasuredValue) ZF(HumidityTolerance)
|
||||
|
||||
ZF(Occupancy) ZF(OccupancySensorType)
|
||||
|
||||
ZF(CompanyName) ZF(MeterTypeID) ZF(DataQualityID) ZF(CustomerName) ZF(Model) ZF(PartNumber)
|
||||
ZF(SoftwareRevision) ZF(POD) ZF(AvailablePower) ZF(PowerThreshold)
|
||||
|
||||
ZF(NumberOfResets) ZF(PersistentMemoryWrites) ZF(LastMessageLQI) ZF(LastMessageRSSI)
|
||||
// list of post-processing directives
|
||||
const Z_AttributeConverter Z_PostProcess[] PROGMEM = {
|
||||
{ 0x0000, 0x0000, "ZCLVersion", &Z_Copy },
|
||||
{ 0x0000, 0x0001, "AppVersion", &Z_Copy },
|
||||
{ 0x0000, 0x0002, "StackVersion", &Z_Copy },
|
||||
{ 0x0000, 0x0003, "HWVersion", &Z_Copy },
|
||||
{ 0x0000, 0x0004, "Manufacturer", &Z_ManufKeep }, // record Manufacturer
|
||||
{ 0x0000, 0x0005, D_JSON_MODEL D_JSON_ID, &Z_ModelKeep }, // record Model
|
||||
{ 0x0000, 0x0006, "DateCode", &Z_Copy },
|
||||
{ 0x0000, 0x0007, "PowerSource", &Z_Copy },
|
||||
{ 0x0000, 0x4000, "SWBuildID", &Z_Copy },
|
||||
{ 0x0000, 0x0000, Z(ZCLVersion), &Z_Copy },
|
||||
{ 0x0000, 0x0001, Z(AppVersion), &Z_Copy },
|
||||
{ 0x0000, 0x0002, Z(StackVersion), &Z_Copy },
|
||||
{ 0x0000, 0x0003, Z(HWVersion), &Z_Copy },
|
||||
{ 0x0000, 0x0004, Z(Manufacturer), &Z_ManufKeep }, // record Manufacturer
|
||||
{ 0x0000, 0x0005, Z(ModelId), &Z_ModelKeep }, // record Model
|
||||
{ 0x0000, 0x0006, Z(DateCode), &Z_Copy },
|
||||
{ 0x0000, 0x0007, Z(PowerSource), &Z_Copy },
|
||||
{ 0x0000, 0x4000, Z(SWBuildID), &Z_Copy },
|
||||
{ 0x0000, 0xFFFF, nullptr, &Z_Remove }, // Remove all other values
|
||||
// Cmd 0x0A - Cluster 0x0000, attribute 0xFF01 - proprietary
|
||||
{ 0x0000, 0xFF01, nullptr, &Z_AqaraSensor }, // Occupancy (map8)
|
||||
|
||||
// Power Configuration cluster
|
||||
{ 0x0001, 0x0000, "MainsVoltage", &Z_Copy },
|
||||
{ 0x0001, 0x0001, "MainsFrequency", &Z_Copy },
|
||||
{ 0x0001, 0x0020, "BatteryVoltage", &Z_FloatDiv10 },
|
||||
{ 0x0001, 0x0021, "BatteryPercentageRemaining",&Z_Copy },
|
||||
{ 0x0001, 0x0000, Z(MainsVoltage), &Z_Copy },
|
||||
{ 0x0001, 0x0001, Z(MainsFrequency), &Z_Copy },
|
||||
{ 0x0001, 0x0020, Z(BatteryVoltage), &Z_FloatDiv10 },
|
||||
{ 0x0001, 0x0021, Z(BatteryPercentage), &Z_Copy },
|
||||
|
||||
// Device Temperature Configuration cluster
|
||||
{ 0x0002, 0x0000, "CurrentTemperature", &Z_Copy },
|
||||
{ 0x0002, 0x0001, "MinTempExperienced", &Z_Copy },
|
||||
{ 0x0002, 0x0002, "MaxTempExperienced", &Z_Copy },
|
||||
{ 0x0002, 0x0003, "OverTempTotalDwell", &Z_Copy },
|
||||
{ 0x0002, 0x0000, Z(CurrentTemperature), &Z_Copy },
|
||||
{ 0x0002, 0x0001, Z(MinTempExperienced), &Z_Copy },
|
||||
{ 0x0002, 0x0002, Z(MaxTempExperienced), &Z_Copy },
|
||||
{ 0x0002, 0x0003, Z(OverTempTotalDwell), &Z_Copy },
|
||||
|
||||
// On/off cluster
|
||||
{ 0x0006, 0x0000, "Power", &Z_Copy },
|
||||
{ 0x0006, 0x8000, "Power", &Z_Copy }, // See 7280
|
||||
{ 0x0006, 0x0000, Z(Power), &Z_Copy },
|
||||
{ 0x0006, 0x8000, Z(Power), &Z_Copy }, // See 7280
|
||||
|
||||
// On/Off Switch Configuration cluster
|
||||
{ 0x0007, 0x0000, "SwitchType", &Z_Copy },
|
||||
{ 0x0007, 0x0000, Z(SwitchType), &Z_Copy },
|
||||
|
||||
// Level Control cluster
|
||||
{ 0x0008, 0x0000, "Dimmer", &Z_Copy },
|
||||
// { 0x0008, 0x0001, "RemainingTime", &Z_Copy },
|
||||
// { 0x0008, 0x0010, "OnOffTransitionTime", &Z_Copy },
|
||||
// { 0x0008, 0x0011, "OnLevel", &Z_Copy },
|
||||
// { 0x0008, 0x0012, "OnTransitionTime", &Z_Copy },
|
||||
// { 0x0008, 0x0013, "OffTransitionTime", &Z_Copy },
|
||||
// { 0x0008, 0x0014, "DefaultMoveRate", &Z_Copy },
|
||||
{ 0x0008, 0x0000, Z(Dimmer), &Z_Copy },
|
||||
// { 0x0008, 0x0001, Z(RemainingTime", &Z_Copy },
|
||||
// { 0x0008, 0x0010, Z(OnOffTransitionTime", &Z_Copy },
|
||||
// { 0x0008, 0x0011, Z(OnLevel", &Z_Copy },
|
||||
// { 0x0008, 0x0012, Z(OnTransitionTime", &Z_Copy },
|
||||
// { 0x0008, 0x0013, Z(OffTransitionTime", &Z_Copy },
|
||||
// { 0x0008, 0x0014, Z(DefaultMoveRate", &Z_Copy },
|
||||
|
||||
// Alarms cluster
|
||||
{ 0x0009, 0x0000, "AlarmCount", &Z_Copy },
|
||||
{ 0x0009, 0x0000, Z(AlarmCount), &Z_Copy },
|
||||
// Time cluster
|
||||
{ 0x000A, 0x0000, "Time", &Z_Copy },
|
||||
{ 0x000A, 0x0001, "TimeStatus", &Z_Copy },
|
||||
{ 0x000A, 0x0002, "TimeZone", &Z_Copy },
|
||||
{ 0x000A, 0x0003, "DstStart", &Z_Copy },
|
||||
{ 0x000A, 0x0004, "DstStart", &Z_Copy },
|
||||
{ 0x000A, 0x0005, "DstShift", &Z_Copy },
|
||||
{ 0x000A, 0x0006, "StandardTime", &Z_Copy },
|
||||
{ 0x000A, 0x0007, "LocalTime", &Z_Copy },
|
||||
{ 0x000A, 0x0008, "LastSetTime", &Z_Copy },
|
||||
{ 0x000A, 0x0009, "ValidUntilTime", &Z_Copy },
|
||||
{ 0x000A, 0x0000, Z(Time), &Z_Copy },
|
||||
{ 0x000A, 0x0001, Z(TimeStatus), &Z_Copy },
|
||||
{ 0x000A, 0x0002, Z(TimeZone), &Z_Copy },
|
||||
{ 0x000A, 0x0003, Z(DstStart), &Z_Copy },
|
||||
{ 0x000A, 0x0004, Z(DstEnd), &Z_Copy },
|
||||
{ 0x000A, 0x0005, Z(DstShift), &Z_Copy },
|
||||
{ 0x000A, 0x0006, Z(StandardTime), &Z_Copy },
|
||||
{ 0x000A, 0x0007, Z(LocalTime), &Z_Copy },
|
||||
{ 0x000A, 0x0008, Z(LastSetTime), &Z_Copy },
|
||||
{ 0x000A, 0x0009, Z(ValidUntilTime), &Z_Copy },
|
||||
// RSSI Location cluster
|
||||
{ 0x000B, 0x0000, "LocationType", &Z_Copy },
|
||||
{ 0x000B, 0x0000, "LocationMethod", &Z_Copy },
|
||||
{ 0x000B, 0x0000, "LocationAge", &Z_Copy },
|
||||
{ 0x000B, 0x0000, "QualityMeasure", &Z_Copy },
|
||||
{ 0x000B, 0x0000, "NumberOfDevices", &Z_Copy },
|
||||
{ 0x000B, 0x0000, Z(LocationType), &Z_Copy },
|
||||
{ 0x000B, 0x0000, Z(LocationMethod), &Z_Copy },
|
||||
{ 0x000B, 0x0000, Z(LocationAge), &Z_Copy },
|
||||
{ 0x000B, 0x0000, Z(QualityMeasure), &Z_Copy },
|
||||
{ 0x000B, 0x0000, Z(NumberOfDevices), &Z_Copy },
|
||||
// Analog Input cluster
|
||||
{ 0x000C, 0x0004, "AnalogInActiveText", &Z_Copy },
|
||||
{ 0x000C, 0x001C, "AnalogInDescription", &Z_Copy },
|
||||
{ 0x000C, 0x002E, "AnalogInInactiveText", &Z_Copy },
|
||||
{ 0x000C, 0x0041, "AnalogInMaxValue", &Z_Copy },
|
||||
{ 0x000C, 0x0045, "AnalogInMinValue", &Z_Copy },
|
||||
{ 0x000C, 0x0051, "AnalogInOutOfService", &Z_Copy },
|
||||
{ 0x000C, 0x0055, "AqaraRotate", &Z_Copy },
|
||||
{ 0x000C, 0x0057, "AnalogInPriorityArray",&Z_Copy },
|
||||
{ 0x000C, 0x0067, "AnalogInReliability", &Z_Copy },
|
||||
{ 0x000C, 0x0068, "AnalogInRelinquishDefault",&Z_Copy },
|
||||
{ 0x000C, 0x006A, "AnalogInResolution", &Z_Copy },
|
||||
{ 0x000C, 0x006F, "AnalogInStatusFlags", &Z_Copy },
|
||||
{ 0x000C, 0x0075, "AnalogInEngineeringUnits",&Z_Copy },
|
||||
{ 0x000C, 0x0100, "AnalogInApplicationType",&Z_Copy },
|
||||
{ 0x000C, 0xFF05, "Aqara_FF05", &Z_Copy },
|
||||
{ 0x000C, 0x0004, Z(AnalogInActiveText), &Z_Copy },
|
||||
{ 0x000C, 0x001C, Z(AnalogInDescription), &Z_Copy },
|
||||
{ 0x000C, 0x002E, Z(AnalogInInactiveText), &Z_Copy },
|
||||
{ 0x000C, 0x0041, Z(AnalogInMaxValue), &Z_Copy },
|
||||
{ 0x000C, 0x0045, Z(AnalogInMinValue), &Z_Copy },
|
||||
{ 0x000C, 0x0051, Z(AnalogInOutOfService), &Z_Copy },
|
||||
{ 0x000C, 0x0055, Z(AqaraRotate), &Z_Copy },
|
||||
{ 0x000C, 0x0057, Z(AnalogInPriorityArray),&Z_Copy },
|
||||
{ 0x000C, 0x0067, Z(AnalogInReliability), &Z_Copy },
|
||||
{ 0x000C, 0x0068, Z(AnalogInRelinquishDefault),&Z_Copy },
|
||||
{ 0x000C, 0x006A, Z(AnalogInResolution), &Z_Copy },
|
||||
{ 0x000C, 0x006F, Z(AnalogInStatusFlags), &Z_Copy },
|
||||
{ 0x000C, 0x0075, Z(AnalogInEngineeringUnits),&Z_Copy },
|
||||
{ 0x000C, 0x0100, Z(AnalogInApplicationType),&Z_Copy },
|
||||
{ 0x000C, 0xFF05, Z(Aqara_FF05), &Z_Copy },
|
||||
// Analog Output cluster
|
||||
{ 0x000D, 0x001C, "AnalogOutDescription", &Z_Copy },
|
||||
{ 0x000D, 0x0041, "AnalogOutMaxValue", &Z_Copy },
|
||||
{ 0x000D, 0x0045, "AnalogOutMinValue", &Z_Copy },
|
||||
{ 0x000D, 0x0051, "AnalogOutOutOfService",&Z_Copy },
|
||||
{ 0x000D, 0x0055, "AnalogOutValue", &Z_Copy },
|
||||
{ 0x000D, 0x0057, "AnalogOutPriorityArray",&Z_Copy },
|
||||
{ 0x000D, 0x0067, "AnalogOutReliability", &Z_Copy },
|
||||
{ 0x000D, 0x0068, "AnalogOutRelinquishDefault",&Z_Copy },
|
||||
{ 0x000D, 0x006A, "AnalogOutResolution", &Z_Copy },
|
||||
{ 0x000D, 0x006F, "AnalogOutStatusFlags", &Z_Copy },
|
||||
{ 0x000D, 0x0075, "AnalogOutEngineeringUnits",&Z_Copy },
|
||||
{ 0x000D, 0x0100, "AnalogOutApplicationType",&Z_Copy },
|
||||
{ 0x000D, 0x001C, Z(AnalogOutDescription), &Z_Copy },
|
||||
{ 0x000D, 0x0041, Z(AnalogOutMaxValue), &Z_Copy },
|
||||
{ 0x000D, 0x0045, Z(AnalogOutMinValue), &Z_Copy },
|
||||
{ 0x000D, 0x0051, Z(AnalogOutOutOfService),&Z_Copy },
|
||||
{ 0x000D, 0x0055, Z(AnalogOutValue), &Z_Copy },
|
||||
{ 0x000D, 0x0057, Z(AnalogOutPriorityArray),&Z_Copy },
|
||||
{ 0x000D, 0x0067, Z(AnalogOutReliability), &Z_Copy },
|
||||
{ 0x000D, 0x0068, Z(AnalogOutRelinquishDefault),&Z_Copy },
|
||||
{ 0x000D, 0x006A, Z(AnalogOutResolution), &Z_Copy },
|
||||
{ 0x000D, 0x006F, Z(AnalogOutStatusFlags), &Z_Copy },
|
||||
{ 0x000D, 0x0075, Z(AnalogOutEngineeringUnits),&Z_Copy },
|
||||
{ 0x000D, 0x0100, Z(AnalogOutApplicationType),&Z_Copy },
|
||||
// Analog Value cluster
|
||||
{ 0x000E, 0x001C, "AnalogDescription", &Z_Copy },
|
||||
{ 0x000E, 0x0051, "AnalogOutOfService", &Z_Copy },
|
||||
{ 0x000E, 0x0055, "AnalogValue", &Z_Copy },
|
||||
{ 0x000E, 0x0057, "AnalogPriorityArray", &Z_Copy },
|
||||
{ 0x000E, 0x0067, "AnalogReliability", &Z_Copy },
|
||||
{ 0x000E, 0x0068, "AnalogRelinquishDefault",&Z_Copy },
|
||||
{ 0x000E, 0x006F, "AnalogStatusFlags", &Z_Copy },
|
||||
{ 0x000E, 0x0075, "AnalogEngineeringUnits",&Z_Copy },
|
||||
{ 0x000E, 0x0100, "AnalogApplicationType",&Z_Copy },
|
||||
{ 0x000E, 0x001C, Z(AnalogDescription), &Z_Copy },
|
||||
{ 0x000E, 0x0051, Z(AnalogOutOfService), &Z_Copy },
|
||||
{ 0x000E, 0x0055, Z(AnalogValue), &Z_Copy },
|
||||
{ 0x000E, 0x0057, Z(AnalogPriorityArray), &Z_Copy },
|
||||
{ 0x000E, 0x0067, Z(AnalogReliability), &Z_Copy },
|
||||
{ 0x000E, 0x0068, Z(AnalogRelinquishDefault),&Z_Copy },
|
||||
{ 0x000E, 0x006F, Z(AnalogStatusFlags), &Z_Copy },
|
||||
{ 0x000E, 0x0075, Z(AnalogEngineeringUnits),&Z_Copy },
|
||||
{ 0x000E, 0x0100, Z(AnalogApplicationType),&Z_Copy },
|
||||
// Binary Input cluster
|
||||
{ 0x000F, 0x0004, "BinaryInActiveText", &Z_Copy },
|
||||
{ 0x000F, 0x001C, "BinaryInDescription", &Z_Copy },
|
||||
{ 0x000F, 0x002E, "BinaryInInactiveText",&Z_Copy },
|
||||
{ 0x000F, 0x0051, "BinaryInOutOfService",&Z_Copy },
|
||||
{ 0x000F, 0x0054, "BinaryInPolarity", &Z_Copy },
|
||||
{ 0x000F, 0x0055, "BinaryInValue", &Z_Copy },
|
||||
{ 0x000F, 0x0057, "BinaryInPriorityArray",&Z_Copy },
|
||||
{ 0x000F, 0x0067, "BinaryInReliability", &Z_Copy },
|
||||
{ 0x000F, 0x006F, "BinaryInStatusFlags", &Z_Copy },
|
||||
{ 0x000F, 0x0100, "BinaryInApplicationType",&Z_Copy },
|
||||
{ 0x000F, 0x0004, Z(BinaryInActiveText), &Z_Copy },
|
||||
{ 0x000F, 0x001C, Z(BinaryInDescription), &Z_Copy },
|
||||
{ 0x000F, 0x002E, Z(BinaryInInactiveText),&Z_Copy },
|
||||
{ 0x000F, 0x0051, Z(BinaryInOutOfService),&Z_Copy },
|
||||
{ 0x000F, 0x0054, Z(BinaryInPolarity), &Z_Copy },
|
||||
{ 0x000F, 0x0055, Z(BinaryInValue), &Z_Copy },
|
||||
{ 0x000F, 0x0057, Z(BinaryInPriorityArray),&Z_Copy },
|
||||
{ 0x000F, 0x0067, Z(BinaryInReliability), &Z_Copy },
|
||||
{ 0x000F, 0x006F, Z(BinaryInStatusFlags), &Z_Copy },
|
||||
{ 0x000F, 0x0100, Z(BinaryInApplicationType),&Z_Copy },
|
||||
// Binary Output cluster
|
||||
{ 0x0010, 0x0004, "BinaryOutActiveText", &Z_Copy },
|
||||
{ 0x0010, 0x001C, "BinaryOutDescription", &Z_Copy },
|
||||
{ 0x0010, 0x002E, "BinaryOutInactiveText",&Z_Copy },
|
||||
{ 0x0010, 0x0042, "BinaryOutMinimumOffTime",&Z_Copy },
|
||||
{ 0x0010, 0x0043, "BinaryOutMinimumOnTime",&Z_Copy },
|
||||
{ 0x0010, 0x0051, "BinaryOutOutOfService",&Z_Copy },
|
||||
{ 0x0010, 0x0054, "BinaryOutPolarity", &Z_Copy },
|
||||
{ 0x0010, 0x0055, "BinaryOutValue", &Z_Copy },
|
||||
{ 0x0010, 0x0057, "BinaryOutPriorityArray",&Z_Copy },
|
||||
{ 0x0010, 0x0067, "BinaryOutReliability", &Z_Copy },
|
||||
{ 0x0010, 0x0068, "BinaryOutRelinquishDefault",&Z_Copy },
|
||||
{ 0x0010, 0x006F, "BinaryOutStatusFlags", &Z_Copy },
|
||||
{ 0x0010, 0x0100, "BinaryOutApplicationType",&Z_Copy },
|
||||
{ 0x0010, 0x0004, Z(BinaryOutActiveText), &Z_Copy },
|
||||
{ 0x0010, 0x001C, Z(BinaryOutDescription), &Z_Copy },
|
||||
{ 0x0010, 0x002E, Z(BinaryOutInactiveText),&Z_Copy },
|
||||
{ 0x0010, 0x0042, Z(BinaryOutMinimumOffTime),&Z_Copy },
|
||||
{ 0x0010, 0x0043, Z(BinaryOutMinimumOnTime),&Z_Copy },
|
||||
{ 0x0010, 0x0051, Z(BinaryOutOutOfService),&Z_Copy },
|
||||
{ 0x0010, 0x0054, Z(BinaryOutPolarity), &Z_Copy },
|
||||
{ 0x0010, 0x0055, Z(BinaryOutValue), &Z_Copy },
|
||||
{ 0x0010, 0x0057, Z(BinaryOutPriorityArray),&Z_Copy },
|
||||
{ 0x0010, 0x0067, Z(BinaryOutReliability), &Z_Copy },
|
||||
{ 0x0010, 0x0068, Z(BinaryOutRelinquishDefault),&Z_Copy },
|
||||
{ 0x0010, 0x006F, Z(BinaryOutStatusFlags), &Z_Copy },
|
||||
{ 0x0010, 0x0100, Z(BinaryOutApplicationType),&Z_Copy },
|
||||
// Binary Value cluster
|
||||
{ 0x0011, 0x0004, "BinaryActiveText", &Z_Copy },
|
||||
{ 0x0011, 0x001C, "BinaryDescription", &Z_Copy },
|
||||
{ 0x0011, 0x002E, "BinaryInactiveText", &Z_Copy },
|
||||
{ 0x0011, 0x0042, "BinaryMinimumOffTime", &Z_Copy },
|
||||
{ 0x0011, 0x0043, "BinaryMinimumOnTime", &Z_Copy },
|
||||
{ 0x0011, 0x0051, "BinaryOutOfService", &Z_Copy },
|
||||
{ 0x0011, 0x0055, "BinaryValue", &Z_Copy },
|
||||
{ 0x0011, 0x0057, "BinaryPriorityArray", &Z_Copy },
|
||||
{ 0x0011, 0x0067, "BinaryReliability", &Z_Copy },
|
||||
{ 0x0011, 0x0068, "BinaryRelinquishDefault",&Z_Copy },
|
||||
{ 0x0011, 0x006F, "BinaryStatusFlags", &Z_Copy },
|
||||
{ 0x0011, 0x0100, "BinaryApplicationType",&Z_Copy },
|
||||
{ 0x0011, 0x0004, Z(BinaryActiveText), &Z_Copy },
|
||||
{ 0x0011, 0x001C, Z(BinaryDescription), &Z_Copy },
|
||||
{ 0x0011, 0x002E, Z(BinaryInactiveText), &Z_Copy },
|
||||
{ 0x0011, 0x0042, Z(BinaryMinimumOffTime), &Z_Copy },
|
||||
{ 0x0011, 0x0043, Z(BinaryMinimumOnTime), &Z_Copy },
|
||||
{ 0x0011, 0x0051, Z(BinaryOutOfService), &Z_Copy },
|
||||
{ 0x0011, 0x0055, Z(BinaryValue), &Z_Copy },
|
||||
{ 0x0011, 0x0057, Z(BinaryPriorityArray), &Z_Copy },
|
||||
{ 0x0011, 0x0067, Z(BinaryReliability), &Z_Copy },
|
||||
{ 0x0011, 0x0068, Z(BinaryRelinquishDefault),&Z_Copy },
|
||||
{ 0x0011, 0x006F, Z(BinaryStatusFlags), &Z_Copy },
|
||||
{ 0x0011, 0x0100, Z(BinaryApplicationType),&Z_Copy },
|
||||
// Multistate Input cluster
|
||||
{ 0x0012, 0x000E, "MultiInStateText", &Z_Copy },
|
||||
{ 0x0012, 0x001C, "MultiInDescription", &Z_Copy },
|
||||
{ 0x0012, 0x004A, "MultiInNumberOfStates",&Z_Copy },
|
||||
{ 0x0012, 0x0051, "MultiInOutOfService", &Z_Copy },
|
||||
{ 0x0012, 0x0055, "MultiInValue", &Z_AqaraCube },
|
||||
{ 0x0012, 0x0067, "MultiInReliability", &Z_Copy },
|
||||
{ 0x0012, 0x006F, "MultiInStatusFlags", &Z_Copy },
|
||||
{ 0x0012, 0x0100, "MultiInApplicationType",&Z_Copy },
|
||||
{ 0x0012, 0x000E, Z(MultiInStateText), &Z_Copy },
|
||||
{ 0x0012, 0x001C, Z(MultiInDescription), &Z_Copy },
|
||||
{ 0x0012, 0x004A, Z(MultiInNumberOfStates),&Z_Copy },
|
||||
{ 0x0012, 0x0051, Z(MultiInOutOfService), &Z_Copy },
|
||||
{ 0x0012, 0x0055, Z(MultiInValue), &Z_AqaraCube },
|
||||
{ 0x0012, 0x0067, Z(MultiInReliability), &Z_Copy },
|
||||
{ 0x0012, 0x006F, Z(MultiInStatusFlags), &Z_Copy },
|
||||
{ 0x0012, 0x0100, Z(MultiInApplicationType),&Z_Copy },
|
||||
// Multistate output
|
||||
{ 0x0013, 0x000E, "MultiOutStateText", &Z_Copy },
|
||||
{ 0x0013, 0x001C, "MultiOutDescription", &Z_Copy },
|
||||
{ 0x0013, 0x004A, "MultiOutNumberOfStates",&Z_Copy },
|
||||
{ 0x0013, 0x0051, "MultiOutOutOfService", &Z_Copy },
|
||||
{ 0x0013, 0x0055, "MultiOutValue", &Z_Copy },
|
||||
{ 0x0013, 0x0057, "MultiOutPriorityArray",&Z_Copy },
|
||||
{ 0x0013, 0x0067, "MultiOutReliability", &Z_Copy },
|
||||
{ 0x0013, 0x0068, "MultiOutRelinquishDefault",&Z_Copy },
|
||||
{ 0x0013, 0x006F, "MultiOutStatusFlags", &Z_Copy },
|
||||
{ 0x0013, 0x0100, "MultiOutApplicationType",&Z_Copy },
|
||||
{ 0x0013, 0x000E, Z(MultiOutStateText), &Z_Copy },
|
||||
{ 0x0013, 0x001C, Z(MultiOutDescription), &Z_Copy },
|
||||
{ 0x0013, 0x004A, Z(MultiOutNumberOfStates),&Z_Copy },
|
||||
{ 0x0013, 0x0051, Z(MultiOutOutOfService), &Z_Copy },
|
||||
{ 0x0013, 0x0055, Z(MultiOutValue), &Z_Copy },
|
||||
{ 0x0013, 0x0057, Z(MultiOutPriorityArray),&Z_Copy },
|
||||
{ 0x0013, 0x0067, Z(MultiOutReliability), &Z_Copy },
|
||||
{ 0x0013, 0x0068, Z(MultiOutRelinquishDefault),&Z_Copy },
|
||||
{ 0x0013, 0x006F, Z(MultiOutStatusFlags), &Z_Copy },
|
||||
{ 0x0013, 0x0100, Z(MultiOutApplicationType),&Z_Copy },
|
||||
// Multistate Value cluster
|
||||
{ 0x0014, 0x000E, "MultiStateText", &Z_Copy },
|
||||
{ 0x0014, 0x001C, "MultiDescription", &Z_Copy },
|
||||
{ 0x0014, 0x004A, "MultiNumberOfStates", &Z_Copy },
|
||||
{ 0x0014, 0x0051, "MultiOutOfService", &Z_Copy },
|
||||
{ 0x0014, 0x0055, "MultiValue", &Z_Copy },
|
||||
{ 0x0014, 0x0067, "MultiReliability", &Z_Copy },
|
||||
{ 0x0014, 0x0068, "MultiRelinquishDefault",&Z_Copy },
|
||||
{ 0x0014, 0x006F, "MultiStatusFlags", &Z_Copy },
|
||||
{ 0x0014, 0x0100, "MultiApplicationType", &Z_Copy },
|
||||
{ 0x0014, 0x000E, Z(MultiStateText), &Z_Copy },
|
||||
{ 0x0014, 0x001C, Z(MultiDescription), &Z_Copy },
|
||||
{ 0x0014, 0x004A, Z(MultiNumberOfStates), &Z_Copy },
|
||||
{ 0x0014, 0x0051, Z(MultiOutOfService), &Z_Copy },
|
||||
{ 0x0014, 0x0055, Z(MultiValue), &Z_Copy },
|
||||
{ 0x0014, 0x0067, Z(MultiReliability), &Z_Copy },
|
||||
{ 0x0014, 0x0068, Z(MultiRelinquishDefault),&Z_Copy },
|
||||
{ 0x0014, 0x006F, Z(MultiStatusFlags), &Z_Copy },
|
||||
{ 0x0014, 0x0100, Z(MultiApplicationType), &Z_Copy },
|
||||
// Power Profile cluster
|
||||
{ 0x001A, 0x0000, "TotalProfileNum", &Z_Copy },
|
||||
{ 0x001A, 0x0001, "MultipleScheduling", &Z_Copy },
|
||||
{ 0x001A, 0x0002, "EnergyFormatting", &Z_Copy },
|
||||
{ 0x001A, 0x0003, "EnergyRemote", &Z_Copy },
|
||||
{ 0x001A, 0x0004, "ScheduleMode", &Z_Copy },
|
||||
{ 0x001A, 0x0000, Z(TotalProfileNum), &Z_Copy },
|
||||
{ 0x001A, 0x0001, Z(MultipleScheduling), &Z_Copy },
|
||||
{ 0x001A, 0x0002, Z(EnergyFormatting), &Z_Copy },
|
||||
{ 0x001A, 0x0003, Z(EnergyRemote), &Z_Copy },
|
||||
{ 0x001A, 0x0004, Z(ScheduleMode), &Z_Copy },
|
||||
// Poll Control cluster
|
||||
{ 0x0020, 0x0000, "CheckinInterval", &Z_Copy },
|
||||
{ 0x0020, 0x0001, "LongPollInterval", &Z_Copy },
|
||||
{ 0x0020, 0x0002, "ShortPollInterval", &Z_Copy },
|
||||
{ 0x0020, 0x0003, "FastPollTimeout", &Z_Copy },
|
||||
{ 0x0020, 0x0004, "CheckinIntervalMin", &Z_Copy },
|
||||
{ 0x0020, 0x0005, "LongPollIntervalMin", &Z_Copy },
|
||||
{ 0x0020, 0x0006, "FastPollTimeoutMax", &Z_Copy },
|
||||
{ 0x0020, 0x0000, Z(CheckinInterval), &Z_Copy },
|
||||
{ 0x0020, 0x0001, Z(LongPollInterval), &Z_Copy },
|
||||
{ 0x0020, 0x0002, Z(ShortPollInterval), &Z_Copy },
|
||||
{ 0x0020, 0x0003, Z(FastPollTimeout), &Z_Copy },
|
||||
{ 0x0020, 0x0004, Z(CheckinIntervalMin), &Z_Copy },
|
||||
{ 0x0020, 0x0005, Z(LongPollIntervalMin), &Z_Copy },
|
||||
{ 0x0020, 0x0006, Z(FastPollTimeoutMax), &Z_Copy },
|
||||
// Shade Configuration cluster
|
||||
{ 0x0100, 0x0000, "PhysicalClosedLimit", &Z_Copy },
|
||||
{ 0x0100, 0x0001, "MotorStepSize", &Z_Copy },
|
||||
{ 0x0100, 0x0002, "Status", &Z_Copy },
|
||||
{ 0x0100, 0x0010, "ClosedLimit", &Z_Copy },
|
||||
{ 0x0100, 0x0011, "Mode", &Z_Copy },
|
||||
{ 0x0100, 0x0000, Z(PhysicalClosedLimit), &Z_Copy },
|
||||
{ 0x0100, 0x0001, Z(MotorStepSize), &Z_Copy },
|
||||
{ 0x0100, 0x0002, Z(Status), &Z_Copy },
|
||||
{ 0x0100, 0x0010, Z(ClosedLimit), &Z_Copy },
|
||||
{ 0x0100, 0x0011, Z(Mode), &Z_Copy },
|
||||
// Door Lock cluster
|
||||
{ 0x0101, 0x0000, "LockState", &Z_Copy },
|
||||
{ 0x0101, 0x0001, "LockType", &Z_Copy },
|
||||
{ 0x0101, 0x0002, "ActuatorEnabled", &Z_Copy },
|
||||
{ 0x0101, 0x0003, "DoorState", &Z_Copy },
|
||||
{ 0x0101, 0x0004, "DoorOpenEvents", &Z_Copy },
|
||||
{ 0x0101, 0x0005, "DoorClosedEvents", &Z_Copy },
|
||||
{ 0x0101, 0x0006, "OpenPeriod", &Z_Copy },
|
||||
{ 0x0101, 0x0000, Z(LockState), &Z_Copy },
|
||||
{ 0x0101, 0x0001, Z(LockType), &Z_Copy },
|
||||
{ 0x0101, 0x0002, Z(ActuatorEnabled), &Z_Copy },
|
||||
{ 0x0101, 0x0003, Z(DoorState), &Z_Copy },
|
||||
{ 0x0101, 0x0004, Z(DoorOpenEvents), &Z_Copy },
|
||||
{ 0x0101, 0x0005, Z(DoorClosedEvents), &Z_Copy },
|
||||
{ 0x0101, 0x0006, Z(OpenPeriod), &Z_Copy },
|
||||
// Aqara Lumi Vibration Sensor
|
||||
{ 0x0101, 0x0055, "AqaraVibrationMode", &Z_AqaraVibration },
|
||||
{ 0x0101, 0x0503, "AqaraVibrationsOrAngle", &Z_Copy },
|
||||
{ 0x0101, 0x0505, "AqaraVibration505", &Z_Copy },
|
||||
{ 0x0101, 0x0508, "AqaraAccelerometer", &Z_AqaraVibration },
|
||||
{ 0x0101, 0x0055, Z(AqaraVibrationMode), &Z_AqaraVibration },
|
||||
{ 0x0101, 0x0503, Z(AqaraVibrationsOrAngle), &Z_Copy },
|
||||
{ 0x0101, 0x0505, Z(AqaraVibration505), &Z_Copy },
|
||||
{ 0x0101, 0x0508, Z(AqaraAccelerometer), &Z_AqaraVibration },
|
||||
// Window Covering cluster
|
||||
{ 0x0102, 0x0000, "WindowCoveringType", &Z_Copy },
|
||||
{ 0x0102, 0x0001, "PhysicalClosedLimitLift",&Z_Copy },
|
||||
{ 0x0102, 0x0002, "PhysicalClosedLimitTilt",&Z_Copy },
|
||||
{ 0x0102, 0x0003, "CurrentPositionLift", &Z_Copy },
|
||||
{ 0x0102, 0x0004, "CurrentPositionTilt", &Z_Copy },
|
||||
{ 0x0102, 0x0005, "NumberofActuationsLift",&Z_Copy },
|
||||
{ 0x0102, 0x0006, "NumberofActuationsTilt",&Z_Copy },
|
||||
{ 0x0102, 0x0007, "ConfigStatus", &Z_Copy },
|
||||
{ 0x0102, 0x0008, "CurrentPositionLiftPercentage",&Z_Copy },
|
||||
{ 0x0102, 0x0009, "CurrentPositionTiltPercentage",&Z_Copy },
|
||||
{ 0x0102, 0x0010, "InstalledOpenLimitLift",&Z_Copy },
|
||||
{ 0x0102, 0x0011, "InstalledClosedLimitLift",&Z_Copy },
|
||||
{ 0x0102, 0x0012, "InstalledOpenLimitTilt",&Z_Copy },
|
||||
{ 0x0102, 0x0013, "InstalledClosedLimitTilt",&Z_Copy },
|
||||
{ 0x0102, 0x0014, "VelocityLift", &Z_Copy },
|
||||
{ 0x0102, 0x0015, "AccelerationTimeLift",&Z_Copy },
|
||||
{ 0x0102, 0x0016, "DecelerationTimeLift", &Z_Copy },
|
||||
{ 0x0102, 0x0017, "Mode", &Z_Copy },
|
||||
{ 0x0102, 0x0018, "IntermediateSetpointsLift",&Z_Copy },
|
||||
{ 0x0102, 0x0019, "IntermediateSetpointsTilt",&Z_Copy },
|
||||
{ 0x0102, 0x0000, Z(WindowCoveringType), &Z_Copy },
|
||||
{ 0x0102, 0x0001, Z(PhysicalClosedLimitLift),&Z_Copy },
|
||||
{ 0x0102, 0x0002, Z(PhysicalClosedLimitTilt),&Z_Copy },
|
||||
{ 0x0102, 0x0003, Z(CurrentPositionLift), &Z_Copy },
|
||||
{ 0x0102, 0x0004, Z(CurrentPositionTilt), &Z_Copy },
|
||||
{ 0x0102, 0x0005, Z(NumberofActuationsLift),&Z_Copy },
|
||||
{ 0x0102, 0x0006, Z(NumberofActuationsTilt),&Z_Copy },
|
||||
{ 0x0102, 0x0007, Z(ConfigStatus), &Z_Copy },
|
||||
{ 0x0102, 0x0008, Z(CurrentPositionLiftPercentage),&Z_Copy },
|
||||
{ 0x0102, 0x0009, Z(CurrentPositionTiltPercentage),&Z_Copy },
|
||||
{ 0x0102, 0x0010, Z(InstalledOpenLimitLift),&Z_Copy },
|
||||
{ 0x0102, 0x0011, Z(InstalledClosedLimitLift),&Z_Copy },
|
||||
{ 0x0102, 0x0012, Z(InstalledOpenLimitTilt),&Z_Copy },
|
||||
{ 0x0102, 0x0013, Z(InstalledClosedLimitTilt),&Z_Copy },
|
||||
{ 0x0102, 0x0014, Z(VelocityLift), &Z_Copy },
|
||||
{ 0x0102, 0x0015, Z(AccelerationTimeLift),&Z_Copy },
|
||||
{ 0x0102, 0x0016, Z(DecelerationTimeLift), &Z_Copy },
|
||||
{ 0x0102, 0x0017, Z(Mode), &Z_Copy },
|
||||
{ 0x0102, 0x0018, Z(IntermediateSetpointsLift),&Z_Copy },
|
||||
{ 0x0102, 0x0019, Z(IntermediateSetpointsTilt),&Z_Copy },
|
||||
|
||||
// Color Control cluster
|
||||
{ 0x0300, 0x0000, "Hue", &Z_Copy },
|
||||
{ 0x0300, 0x0001, "Sat", &Z_Copy },
|
||||
{ 0x0300, 0x0002, "RemainingTime", &Z_Copy },
|
||||
{ 0x0300, 0x0003, "X", &Z_Copy },
|
||||
{ 0x0300, 0x0004, "Y", &Z_Copy },
|
||||
{ 0x0300, 0x0005, "DriftCompensation", &Z_Copy },
|
||||
{ 0x0300, 0x0006, "CompensationText", &Z_Copy },
|
||||
{ 0x0300, 0x0007, "CT", &Z_Copy },
|
||||
{ 0x0300, 0x0008, "ColorMode", &Z_Copy },
|
||||
{ 0x0300, 0x0010, "NumberOfPrimaries", &Z_Copy },
|
||||
{ 0x0300, 0x0011, "Primary1X", &Z_Copy },
|
||||
{ 0x0300, 0x0012, "Primary1Y", &Z_Copy },
|
||||
{ 0x0300, 0x0013, "Primary1Intensity", &Z_Copy },
|
||||
{ 0x0300, 0x0015, "Primary2X", &Z_Copy },
|
||||
{ 0x0300, 0x0016, "Primary2Y", &Z_Copy },
|
||||
{ 0x0300, 0x0017, "Primary2Intensity", &Z_Copy },
|
||||
{ 0x0300, 0x0019, "Primary3X", &Z_Copy },
|
||||
{ 0x0300, 0x001A, "Primary3Y", &Z_Copy },
|
||||
{ 0x0300, 0x001B, "Primary3Intensity", &Z_Copy },
|
||||
{ 0x0300, 0x0030, "WhitePointX", &Z_Copy },
|
||||
{ 0x0300, 0x0031, "WhitePointY", &Z_Copy },
|
||||
{ 0x0300, 0x0032, "ColorPointRX", &Z_Copy },
|
||||
{ 0x0300, 0x0033, "ColorPointRY", &Z_Copy },
|
||||
{ 0x0300, 0x0034, "ColorPointRIntensity", &Z_Copy },
|
||||
{ 0x0300, 0x0036, "ColorPointGX", &Z_Copy },
|
||||
{ 0x0300, 0x0037, "ColorPointGY", &Z_Copy },
|
||||
{ 0x0300, 0x0038, "ColorPointGIntensity", &Z_Copy },
|
||||
{ 0x0300, 0x003A, "ColorPointBX", &Z_Copy },
|
||||
{ 0x0300, 0x003B, "ColorPointBY", &Z_Copy },
|
||||
{ 0x0300, 0x003C, "ColorPointBIntensity", &Z_Copy },
|
||||
{ 0x0300, 0x0000, Z(Hue), &Z_Copy },
|
||||
{ 0x0300, 0x0001, Z(Sat), &Z_Copy },
|
||||
{ 0x0300, 0x0002, Z(RemainingTime), &Z_Copy },
|
||||
{ 0x0300, 0x0003, Z(X), &Z_Copy },
|
||||
{ 0x0300, 0x0004, Z(Y), &Z_Copy },
|
||||
{ 0x0300, 0x0005, Z(DriftCompensation), &Z_Copy },
|
||||
{ 0x0300, 0x0006, Z(CompensationText), &Z_Copy },
|
||||
{ 0x0300, 0x0007, Z(CT), &Z_Copy },
|
||||
{ 0x0300, 0x0008, Z(ColorMode), &Z_Copy },
|
||||
{ 0x0300, 0x0010, Z(NumberOfPrimaries), &Z_Copy },
|
||||
{ 0x0300, 0x0011, Z(Primary1X), &Z_Copy },
|
||||
{ 0x0300, 0x0012, Z(Primary1Y), &Z_Copy },
|
||||
{ 0x0300, 0x0013, Z(Primary1Intensity), &Z_Copy },
|
||||
{ 0x0300, 0x0015, Z(Primary2X), &Z_Copy },
|
||||
{ 0x0300, 0x0016, Z(Primary2Y), &Z_Copy },
|
||||
{ 0x0300, 0x0017, Z(Primary2Intensity), &Z_Copy },
|
||||
{ 0x0300, 0x0019, Z(Primary3X), &Z_Copy },
|
||||
{ 0x0300, 0x001A, Z(Primary3Y), &Z_Copy },
|
||||
{ 0x0300, 0x001B, Z(Primary3Intensity), &Z_Copy },
|
||||
{ 0x0300, 0x0030, Z(WhitePointX), &Z_Copy },
|
||||
{ 0x0300, 0x0031, Z(WhitePointY), &Z_Copy },
|
||||
{ 0x0300, 0x0032, Z(ColorPointRX), &Z_Copy },
|
||||
{ 0x0300, 0x0033, Z(ColorPointRY), &Z_Copy },
|
||||
{ 0x0300, 0x0034, Z(ColorPointRIntensity), &Z_Copy },
|
||||
{ 0x0300, 0x0036, Z(ColorPointGX), &Z_Copy },
|
||||
{ 0x0300, 0x0037, Z(ColorPointGY), &Z_Copy },
|
||||
{ 0x0300, 0x0038, Z(ColorPointGIntensity), &Z_Copy },
|
||||
{ 0x0300, 0x003A, Z(ColorPointBX), &Z_Copy },
|
||||
{ 0x0300, 0x003B, Z(ColorPointBY), &Z_Copy },
|
||||
{ 0x0300, 0x003C, Z(ColorPointBIntensity), &Z_Copy },
|
||||
|
||||
// Illuminance Measurement cluster
|
||||
{ 0x0400, 0x0000, D_JSON_ILLUMINANCE, &Z_Copy }, // Illuminance (in Lux)
|
||||
{ 0x0400, 0x0001, "IlluminanceMinMeasuredValue", &Z_Copy }, //
|
||||
{ 0x0400, 0x0002, "IlluminanceMaxMeasuredValue", &Z_Copy }, //
|
||||
{ 0x0400, 0x0003, "IlluminanceTolerance", &Z_Copy }, //
|
||||
{ 0x0400, 0x0004, "IlluminanceLightSensorType", &Z_Copy }, //
|
||||
{ 0x0400, 0x0000, Z(Illuminance), &Z_Copy }, // Illuminance (in Lux)
|
||||
{ 0x0400, 0x0001, Z(IlluminanceMinMeasuredValue), &Z_Copy }, //
|
||||
{ 0x0400, 0x0002, Z(IlluminanceMaxMeasuredValue), &Z_Copy }, //
|
||||
{ 0x0400, 0x0003, Z(IlluminanceTolerance), &Z_Copy }, //
|
||||
{ 0x0400, 0x0004, Z(IlluminanceLightSensorType), &Z_Copy }, //
|
||||
{ 0x0400, 0xFFFF, nullptr, &Z_Remove }, // Remove all other values
|
||||
|
||||
// Illuminance Level Sensing cluster
|
||||
{ 0x0401, 0x0000, "IlluminanceLevelStatus", &Z_Copy }, // Illuminance (in Lux)
|
||||
{ 0x0401, 0x0001, "IlluminanceLightSensorType", &Z_Copy }, // LightSensorType
|
||||
{ 0x0401, 0x0000, Z(IlluminanceLevelStatus), &Z_Copy }, // Illuminance (in Lux)
|
||||
{ 0x0401, 0x0001, Z(IlluminanceLightSensorType), &Z_Copy }, // LightSensorType
|
||||
{ 0x0401, 0xFFFF, nullptr, &Z_Remove }, // Remove all other values
|
||||
|
||||
// Temperature Measurement cluster
|
||||
{ 0x0402, 0x0000, D_JSON_TEMPERATURE, &Z_FloatDiv100 }, // Temperature
|
||||
{ 0x0402, 0x0001, "TemperatureMinMeasuredValue", &Z_FloatDiv100 }, //
|
||||
{ 0x0402, 0x0002, "TemperatureMaxMeasuredValue", &Z_FloatDiv100 }, //
|
||||
{ 0x0402, 0x0003, "TemperatureTolerance", &Z_FloatDiv100 }, //
|
||||
{ 0x0402, 0x0000, Z(Temperature), &Z_FloatDiv100 }, // Temperature
|
||||
{ 0x0402, 0x0001, Z(TemperatureMinMeasuredValue), &Z_FloatDiv100 }, //
|
||||
{ 0x0402, 0x0002, Z(TemperatureMaxMeasuredValue), &Z_FloatDiv100 }, //
|
||||
{ 0x0402, 0x0003, Z(TemperatureTolerance), &Z_FloatDiv100 }, //
|
||||
{ 0x0402, 0xFFFF, nullptr, &Z_Remove }, // Remove all other values
|
||||
|
||||
// Pressure Measurement cluster
|
||||
{ 0x0403, 0x0000, D_JSON_PRESSURE_UNIT, &Z_AddPressureUnit }, // Pressure Unit
|
||||
{ 0x0403, 0x0000, D_JSON_PRESSURE, &Z_Copy }, // Pressure
|
||||
{ 0x0403, 0x0001, "PressureMinMeasuredValue", &Z_Copy }, //
|
||||
{ 0x0403, 0x0002, "PressureMaxMeasuredValue", &Z_Copy }, //
|
||||
{ 0x0403, 0x0003, "PressureTolerance", &Z_Copy }, //
|
||||
{ 0x0403, 0x0010, "PressureScaledValue", &Z_Copy }, //
|
||||
{ 0x0403, 0x0011, "PressureMinScaledValue", &Z_Copy }, //
|
||||
{ 0x0403, 0x0012, "PressureMaxScaledValue", &Z_Copy }, //
|
||||
{ 0x0403, 0x0013, "PressureScaledTolerance", &Z_Copy }, //
|
||||
{ 0x0403, 0x0014, "PressureScale", &Z_Copy }, //
|
||||
{ 0x0403, 0x0000, Z(PressureUnit), &Z_AddPressureUnit }, // Pressure Unit
|
||||
{ 0x0403, 0x0000, Z(Pressure), &Z_Copy }, // Pressure
|
||||
{ 0x0403, 0x0001, Z(PressureMinMeasuredValue), &Z_Copy }, //
|
||||
{ 0x0403, 0x0002, Z(PressureMaxMeasuredValue), &Z_Copy }, //
|
||||
{ 0x0403, 0x0003, Z(PressureTolerance), &Z_Copy }, //
|
||||
{ 0x0403, 0x0010, Z(PressureScaledValue), &Z_Copy }, //
|
||||
{ 0x0403, 0x0011, Z(PressureMinScaledValue), &Z_Copy }, //
|
||||
{ 0x0403, 0x0012, Z(PressureMaxScaledValue), &Z_Copy }, //
|
||||
{ 0x0403, 0x0013, Z(PressureScaledTolerance), &Z_Copy }, //
|
||||
{ 0x0403, 0x0014, Z(PressureScale), &Z_Copy }, //
|
||||
{ 0x0403, 0xFFFF, nullptr, &Z_Remove }, // Remove all other Pressure values
|
||||
|
||||
// Flow Measurement cluster
|
||||
{ 0x0404, 0x0000, D_JSON_FLOWRATE, &Z_FloatDiv10 }, // Flow (in m3/h)
|
||||
{ 0x0404, 0x0001, "FlowMinMeasuredValue", &Z_Copy }, //
|
||||
{ 0x0404, 0x0002, "FlowMaxMeasuredValue", &Z_Copy }, //
|
||||
{ 0x0404, 0x0003, "FlowTolerance", &Z_Copy }, //
|
||||
{ 0x0404, 0x0000, Z(FlowRate), &Z_FloatDiv10 }, // Flow (in m3/h)
|
||||
{ 0x0404, 0x0001, Z(FlowMinMeasuredValue), &Z_Copy }, //
|
||||
{ 0x0404, 0x0002, Z(FlowMaxMeasuredValue), &Z_Copy }, //
|
||||
{ 0x0404, 0x0003, Z(FlowTolerance), &Z_Copy }, //
|
||||
{ 0x0404, 0xFFFF, nullptr, &Z_Remove }, // Remove all other values
|
||||
|
||||
// Relative Humidity Measurement cluster
|
||||
{ 0x0405, 0x0000, D_JSON_HUMIDITY, &Z_FloatDiv100 }, // Humidity
|
||||
{ 0x0405, 0x0001, "HumidityMinMeasuredValue", &Z_Copy }, //
|
||||
{ 0x0405, 0x0002, "HumidityMaxMeasuredValue", &Z_Copy }, //
|
||||
{ 0x0405, 0x0003, "HumidityTolerance", &Z_Copy }, //
|
||||
{ 0x0405, 0x0000, Z(Humidity), &Z_FloatDiv100 }, // Humidity
|
||||
{ 0x0405, 0x0001, Z(HumidityMinMeasuredValue), &Z_Copy }, //
|
||||
{ 0x0405, 0x0002, Z(HumidityMaxMeasuredValue), &Z_Copy }, //
|
||||
{ 0x0405, 0x0003, Z(HumidityTolerance), &Z_Copy }, //
|
||||
{ 0x0405, 0xFFFF, nullptr, &Z_Remove }, // Remove all other values
|
||||
|
||||
// Occupancy Sensing cluster
|
||||
{ 0x0406, 0x0000, OCCUPANCY, &Z_Copy }, // Occupancy (map8)
|
||||
{ 0x0406, 0x0001, "OccupancySensorType", &Z_Copy }, // OccupancySensorType
|
||||
{ 0x0406, 0x0000, Z(Occupancy), &Z_Copy }, // Occupancy (map8)
|
||||
{ 0x0406, 0x0001, Z(OccupancySensorType), &Z_Copy }, // OccupancySensorType
|
||||
{ 0x0406, 0xFFFF, nullptr, &Z_Remove }, // Remove all other values
|
||||
|
||||
// Meter Identification cluster
|
||||
{ 0x0B01, 0x0000, "CompanyName", &Z_Copy },
|
||||
{ 0x0B01, 0x0001, "MeterTypeID", &Z_Copy },
|
||||
{ 0x0B01, 0x0004, "DataQualityID", &Z_Copy },
|
||||
{ 0x0B01, 0x0005, "CustomerName", &Z_Copy },
|
||||
{ 0x0B01, 0x0006, "Model", &Z_Copy },
|
||||
{ 0x0B01, 0x0007, "PartNumber", &Z_Copy },
|
||||
{ 0x0B01, 0x000A, "SoftwareRevision", &Z_Copy },
|
||||
{ 0x0B01, 0x000C, "POD", &Z_Copy },
|
||||
{ 0x0B01, 0x000D, "AvailablePower", &Z_Copy },
|
||||
{ 0x0B01, 0x000E, "PowerThreshold", &Z_Copy },
|
||||
{ 0x0B01, 0x0000, Z(CompanyName), &Z_Copy },
|
||||
{ 0x0B01, 0x0001, Z(MeterTypeID), &Z_Copy },
|
||||
{ 0x0B01, 0x0004, Z(DataQualityID), &Z_Copy },
|
||||
{ 0x0B01, 0x0005, Z(CustomerName), &Z_Copy },
|
||||
{ 0x0B01, 0x0006, Z(Model), &Z_Copy },
|
||||
{ 0x0B01, 0x0007, Z(PartNumber), &Z_Copy },
|
||||
{ 0x0B01, 0x000A, Z(SoftwareRevision), &Z_Copy },
|
||||
{ 0x0B01, 0x000C, Z(POD), &Z_Copy },
|
||||
{ 0x0B01, 0x000D, Z(AvailablePower), &Z_Copy },
|
||||
{ 0x0B01, 0x000E, Z(PowerThreshold), &Z_Copy },
|
||||
|
||||
// Diagnostics cluster
|
||||
{ 0x0B05, 0x0000, "NumberOfResets", &Z_Copy },
|
||||
{ 0x0B05, 0x0001, "PersistentMemoryWrites",&Z_Copy },
|
||||
{ 0x0B05, 0x011C, "LastMessageLQI", &Z_Copy },
|
||||
{ 0x0B05, 0x011D, "LastMessageRSSI", &Z_Copy },
|
||||
{ 0x0B05, 0x0000, Z(NumberOfResets), &Z_Copy },
|
||||
{ 0x0B05, 0x0001, Z(PersistentMemoryWrites),&Z_Copy },
|
||||
{ 0x0B05, 0x011C, Z(LastMessageLQI), &Z_Copy },
|
||||
{ 0x0B05, 0x011D, Z(LastMessageRSSI), &Z_Copy },
|
||||
|
||||
};
|
||||
|
||||
|
@ -924,7 +1010,7 @@ int32_t Z_FloatDiv2(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObject& j
|
|||
}
|
||||
|
||||
// Publish a message for `"Occupancy":0` when the timer expired
|
||||
int32_t Z_OccupancyCallback(uint16_t shortaddr, uint16_t cluster, uint16_t endpoint, uint32_t value) {
|
||||
int32_t Z_OccupancyCallback(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
json[F(OCCUPANCY)] = 0;
|
||||
|
@ -1050,7 +1136,8 @@ int32_t Z_AqaraSensor(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObject&
|
|||
char tmp[] = "tmp"; // for obscure reasons, it must be converted from const char* to char*, otherwise ArduinoJson gets confused
|
||||
|
||||
JsonVariant sub_value;
|
||||
const String * modelId = zigbee_devices.getModelId(shortaddr); // null if unknown
|
||||
const char * modelId_c = zigbee_devices.getModelId(shortaddr); // null if unknown
|
||||
String modelId((char*) modelId_c);
|
||||
|
||||
while (len - i >= 2) {
|
||||
uint8_t attrid = buf2.get8(i++);
|
||||
|
@ -1064,8 +1151,8 @@ int32_t Z_AqaraSensor(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObject&
|
|||
json[F("Battery")] = toPercentageCR2032(val);
|
||||
} else if ((nullptr != modelId) && (0 == zcl->getManufCode())) {
|
||||
translated = true;
|
||||
if (modelId->startsWith(F("lumi.sensor_ht")) ||
|
||||
modelId->startsWith(F("lumi.weather"))) { // Temp sensor
|
||||
if (modelId.startsWith(F("lumi.sensor_ht")) ||
|
||||
modelId.startsWith(F("lumi.weather"))) { // Temp sensor
|
||||
// Filter according to prefix of model name
|
||||
// onla Aqara Temp/Humidity has manuf_code of zero. If non-zero we skip the parameters
|
||||
if (0x64 == attrid) {
|
||||
|
@ -1076,11 +1163,11 @@ int32_t Z_AqaraSensor(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObject&
|
|||
json[F(D_JSON_PRESSURE)] = val / 100.0f;
|
||||
json[F(D_JSON_PRESSURE_UNIT)] = F(D_UNIT_PRESSURE); // hPa
|
||||
}
|
||||
} else if (modelId->startsWith(F("lumi.sensor_smoke"))) { // gas leak
|
||||
} else if (modelId.startsWith(F("lumi.sensor_smoke"))) { // gas leak
|
||||
if (0x64 == attrid) {
|
||||
json[F("SmokeDensity")] = val;
|
||||
}
|
||||
} else if (modelId->startsWith(F("lumi.sensor_natgas"))) { // gas leak
|
||||
} else if (modelId.startsWith(F("lumi.sensor_natgas"))) { // gas leak
|
||||
if (0x64 == attrid) {
|
||||
json[F("GasDensity")] = val;
|
||||
}
|
||||
|
@ -1121,6 +1208,42 @@ void ZCLFrame::postProcessAttributes(uint16_t shortaddr, JsonObject& json) {
|
|||
suffix = strtoul(delimiter2+1, nullptr, 10);
|
||||
}
|
||||
|
||||
// see if we need to update the Hue bulb status
|
||||
if ((cluster == 0x0006) && ((attribute == 0x0000) || (attribute == 0x8000))) {
|
||||
uint8_t power = value;
|
||||
zigbee_devices.updateHueState(shortaddr, &power, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
} else if ((cluster == 0x0008) && (attribute == 0x0000)) {
|
||||
uint8_t dimmer = value;
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, nullptr, &dimmer, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
} else if ((cluster == 0x0300) && (attribute == 0x0000)) {
|
||||
uint16_t hue8 = value;
|
||||
uint16_t hue = changeUIntScale(hue8, 0, 254, 0, 360); // change range from 0..254 to 0..360
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, &hue, nullptr, nullptr);
|
||||
} else if ((cluster == 0x0300) && (attribute == 0x0001)) {
|
||||
uint8_t sat = value;
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, nullptr, nullptr, &sat,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
} else if ((cluster == 0x0300) && (attribute == 0x0003)) {
|
||||
uint16_t x = value;
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, &x, nullptr);
|
||||
} else if ((cluster == 0x0300) && (attribute == 0x0004)) {
|
||||
uint16_t y = value;
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, &y);
|
||||
} else if ((cluster == 0x0300) && (attribute == 0x0007)) {
|
||||
uint16_t ct = value;
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, nullptr, nullptr, nullptr,
|
||||
&ct, nullptr, nullptr, nullptr);
|
||||
} else if ((cluster == 0x0300) && (attribute == 0x0008)) {
|
||||
uint8_t colormode = value;
|
||||
zigbee_devices.updateHueState(shortaddr, nullptr, &colormode, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
// Iterate on filter
|
||||
for (uint32_t i = 0; i < sizeof(Z_PostProcess) / sizeof(Z_PostProcess[0]); i++) {
|
||||
const Z_AttributeConverter *converter = &Z_PostProcess[i];
|
||||
|
@ -1129,7 +1252,7 @@ void ZCLFrame::postProcessAttributes(uint16_t shortaddr, JsonObject& json) {
|
|||
|
||||
if ((conv_cluster == cluster) &&
|
||||
((conv_attribute == attribute) || (conv_attribute == 0xFFFF)) ) {
|
||||
String new_name_str = converter->name;
|
||||
String new_name_str = (const __FlashStringHelper*) converter->name;
|
||||
if (suffix > 1) { new_name_str += suffix; } // append suffix number
|
||||
int32_t drop = (*converter->func)(this, shortaddr, json, key, value, new_name_str, conv_cluster, conv_attribute);
|
||||
if (drop) {
|
||||
|
|
|
@ -36,6 +36,23 @@ typedef struct Z_XYZ_Var { // Holds values for vairables X, Y and Z
|
|||
uint8_t z_type = 0;
|
||||
} Z_XYZ_Var;
|
||||
|
||||
ZF(AddGroup) ZF(ViewGroup) ZF(GetGroup) ZF(GetAllGroups) ZF(RemoveGroup) ZF(RemoveAllGroups)
|
||||
ZF(AddScene) ZF(ViewScene) ZF(RemoveScene) ZF(RemoveAllScenes) ZF(RecallScene) ZF(StoreScene) ZF(GetSceneMembership)
|
||||
//ZF(Power) ZF(Dimmer)
|
||||
ZF(DimmerUp) ZF(DimmerDown) ZF(DimmerStop)
|
||||
ZF(ResetAlarm) ZF(ResetAllAlarms)
|
||||
//ZF(Hue) ZF(Sat) ZF(CT)
|
||||
ZF(HueSat) ZF(Color)
|
||||
ZF(ShutterOpen) ZF(ShutterClose) ZF(ShutterStop) ZF(ShutterLift) ZF(ShutterTilt) ZF(Shutter)
|
||||
//ZF(Occupancy)
|
||||
ZF(DimmerMove) ZF(DimmerStep)
|
||||
ZF(HueMove) ZF(HueStep) ZF(SatMove) ZF(SatStep) ZF(ColorMove) ZF(ColorStep)
|
||||
ZF(ArrowClick) ZF(ArrowHold) ZF(ArrowRelease) ZF(ZoneStatusChange)
|
||||
|
||||
ZF(xxxx00) ZF(xxxx) ZF(01xxxx) ZF(00) ZF(01) ZF() ZF(xxxxyy) ZF(001902) ZF(011902) ZF(xxyyyy) ZF(xx)
|
||||
ZF(xx000A00) ZF(xx0A00) ZF(xxyy0A00) ZF(xxxxyyyy0A00) ZF(xxxx0A00) ZF(xx0A)
|
||||
ZF(xx190A00) ZF(xx19) ZF(xx190A) ZF(xxxxyyyy) ZF(xxxxyyzz) ZF(xxyyzzzz) ZF(xxyyyyzz)
|
||||
|
||||
// Cluster specific commands
|
||||
// Note: the table is both for sending commands, but also displaying received commands
|
||||
// - tasmota_cmd: the human-readable name of the command as entered or displayed, use '|' to split into multiple commands when displayed
|
||||
|
@ -45,58 +62,72 @@ typedef struct Z_XYZ_Var { // Holds values for vairables X, Y and Z
|
|||
// - param: the paylod template, x/y/z are substituted with arguments, little endian. For command display, payload must match until x/y/z character or until the end of the paylod. '??' means ignore.
|
||||
const Z_CommandConverter Z_Commands[] PROGMEM = {
|
||||
// Group adress commands
|
||||
{ "AddGroup", 0x0004, 0x00, 0x01, "xxxx00" }, // Add group id, group name is not supported
|
||||
{ "ViewGroup", 0x0004, 0x01, 0x01, "xxxx" }, // Ask for the group name
|
||||
{ "GetGroup", 0x0004, 0x02, 0x01, "01xxxx" }, // Get one group membership
|
||||
{ "GetAllGroups", 0x0004, 0x02, 0x01, "00" }, // Get all groups membership
|
||||
{ "RemoveGroup", 0x0004, 0x03, 0x01, "xxxx" }, // Remove one group
|
||||
{ "RemoveAllGroups",0x0004, 0x04, 0x01, "" }, // Remove all groups
|
||||
{ Z(AddGroup), 0x0004, 0x00, 0x01, Z(xxxx00) }, // Add group id, group name is not supported
|
||||
{ Z(ViewGroup), 0x0004, 0x01, 0x01, Z(xxxx) }, // Ask for the group name
|
||||
{ Z(GetGroup), 0x0004, 0x02, 0x01, Z(01xxxx) }, // Get one group membership
|
||||
{ Z(GetAllGroups), 0x0004, 0x02, 0x01, Z(00) }, // Get all groups membership
|
||||
{ Z(RemoveGroup), 0x0004, 0x03, 0x01, Z(xxxx) }, // Remove one group
|
||||
{ Z(RemoveAllGroups),0x0004, 0x04, 0x01, Z() }, // Remove all groups
|
||||
// Scenes
|
||||
//{ "AddScene", 0x0005, 0x00, 0x01, "xxxxyy0100" },
|
||||
{ Z(ViewScene), 0x0005, 0x01, 0x01, Z(xxxxyy) },
|
||||
{ Z(RemoveScene), 0x0005, 0x02, 0x01, Z(xxxxyy) },
|
||||
{ Z(RemoveAllScenes),0x0005, 0x03, 0x01, Z(xxxx) },
|
||||
{ Z(RecallScene), 0x0005, 0x05, 0x01, Z(xxxxyy) },
|
||||
{ Z(GetSceneMembership),0x0005, 0x06, 0x01, Z(xxxx) },
|
||||
// Light & Shutter commands
|
||||
{ "Power", 0x0006, 0xFF, 0x01, "" }, // 0=Off, 1=On, 2=Toggle
|
||||
{ "Dimmer", 0x0008, 0x04, 0x01, "xx0A00" }, // Move to Level with On/Off, xx=0..254 (255 is invalid)
|
||||
{ "Dimmer+", 0x0008, 0x06, 0x01, "001902" }, // Step up by 10%, 0.2 secs
|
||||
{ "Dimmer-", 0x0008, 0x06, 0x01, "011902" }, // Step down by 10%, 0.2 secs
|
||||
{ "DimmerStop", 0x0008, 0x03, 0x01, "" }, // Stop any Dimmer animation
|
||||
{ "ResetAlarm", 0x0009, 0x00, 0x01, "xxyyyy" }, // Reset alarm (alarm code + cluster identifier)
|
||||
{ "ResetAllAlarms", 0x0009, 0x01, 0x01, "" }, // Reset all alarms
|
||||
{ "Hue", 0x0300, 0x00, 0x01, "xx000A00" }, // Move to Hue, shortest time, 1s
|
||||
{ "Sat", 0x0300, 0x03, 0x01, "xx0A00" }, // Move to Sat
|
||||
{ "HueSat", 0x0300, 0x06, 0x01, "xxyy0A00" }, // Hue, Sat
|
||||
{ "Color", 0x0300, 0x07, 0x01, "xxxxyyyy0A00" }, // x, y (uint16)
|
||||
{ "CT", 0x0300, 0x0A, 0x01, "xxxx0A00" }, // Color Temperature Mireds (uint16)
|
||||
{ "ShutterOpen", 0x0102, 0x00, 0x01, "" },
|
||||
{ "ShutterClose", 0x0102, 0x01, 0x01, "" },
|
||||
{ "ShutterStop", 0x0102, 0x02, 0x01, "" },
|
||||
{ "ShutterLift", 0x0102, 0x05, 0x01, "xx" }, // Lift percentage, 0%=open, 100%=closed
|
||||
{ "ShutterTilt", 0x0102, 0x08, 0x01, "xx" }, // Tilt percentage
|
||||
{ "Shutter", 0x0102, 0xFF, 0x01, "" },
|
||||
{ Z(Power), 0x0006, 0xFF, 0x01, Z() }, // 0=Off, 1=On, 2=Toggle
|
||||
{ Z(Dimmer), 0x0008, 0x04, 0x01, Z(xx0A00) }, // Move to Level with On/Off, xx=0..254 (255 is invalid)
|
||||
{ Z(DimmerUp), 0x0008, 0x06, 0x01, Z(001902) }, // Step up by 10%, 0.2 secs
|
||||
{ Z(DimmerDown), 0x0008, 0x06, 0x01, Z(011902) }, // Step down by 10%, 0.2 secs
|
||||
{ Z(DimmerStop), 0x0008, 0x03, 0x01, Z() }, // Stop any Dimmer animation
|
||||
{ Z(ResetAlarm), 0x0009, 0x00, 0x01, Z(xxyyyy) }, // Reset alarm (alarm code + cluster identifier)
|
||||
{ Z(ResetAllAlarms), 0x0009, 0x01, 0x01, Z() }, // Reset all alarms
|
||||
{ Z(Hue), 0x0300, 0x00, 0x01, Z(xx000A00) }, // Move to Hue, shortest time, 1s
|
||||
{ Z(Sat), 0x0300, 0x03, 0x01, Z(xx0A00) }, // Move to Sat
|
||||
{ Z(HueSat), 0x0300, 0x06, 0x01, Z(xxyy0A00) }, // Hue, Sat
|
||||
{ Z(Color), 0x0300, 0x07, 0x01, Z(xxxxyyyy0A00) }, // x, y (uint16)
|
||||
{ Z(CT), 0x0300, 0x0A, 0x01, Z(xxxx0A00) }, // Color Temperature Mireds (uint16)
|
||||
{ Z(ShutterOpen), 0x0102, 0x00, 0x01, Z() },
|
||||
{ Z(ShutterClose), 0x0102, 0x01, 0x01, Z() },
|
||||
{ Z(ShutterStop), 0x0102, 0x02, 0x01, Z() },
|
||||
{ Z(ShutterLift), 0x0102, 0x05, 0x01, Z(xx) }, // Lift percentage, 0%=open, 100%=closed
|
||||
{ Z(ShutterTilt), 0x0102, 0x08, 0x01, Z(xx) }, // Tilt percentage
|
||||
{ Z(Shutter), 0x0102, 0xFF, 0x01, Z() },
|
||||
// Blitzwolf PIR
|
||||
{ "Occupancy", 0xEF00, 0x01, 0x82, ""}, // Specific decoder for Blitzwolf PIR, empty name means special treatment
|
||||
{ Z(Occupancy), 0xEF00, 0x01, 0x82, Z()}, // Specific decoder for Blitzwolf PIR, empty name means special treatment
|
||||
// Decoders only - normally not used to send, and names may be masked by previous definitions
|
||||
{ "Dimmer", 0x0008, 0x00, 0x01, "xx" },
|
||||
{ "DimmerMove", 0x0008, 0x01, 0x01, "xx0A" },
|
||||
{ "DimmerStep", 0x0008, 0x02, 0x01, "xx190A00" },
|
||||
{ "DimmerMove", 0x0008, 0x05, 0x01, "xx0A" },
|
||||
{ "Dimmer+", 0x0008, 0x06, 0x01, "00" },
|
||||
{ "Dimmer-", 0x0008, 0x06, 0x01, "01" },
|
||||
{ "DimmerStop", 0x0008, 0x07, 0x01, "" },
|
||||
{ "HueMove", 0x0300, 0x01, 0x01, "xx19" },
|
||||
{ "HueStep", 0x0300, 0x02, 0x01, "xx190A00" },
|
||||
{ "SatMove", 0x0300, 0x04, 0x01, "xx19" },
|
||||
{ "SatStep", 0x0300, 0x05, 0x01, "xx190A" },
|
||||
{ "ColorMove", 0x0300, 0x08, 0x01, "xxxxyyyy" },
|
||||
{ "ColorStep", 0x0300, 0x09, 0x01, "xxxxyyyy0A00" },
|
||||
{ Z(Dimmer), 0x0008, 0x00, 0x01, Z(xx) },
|
||||
{ Z(DimmerMove), 0x0008, 0x01, 0x01, Z(xx0A) },
|
||||
{ Z(DimmerStep), 0x0008, 0x02, 0x01, Z(xx190A00) },
|
||||
{ Z(DimmerMove), 0x0008, 0x05, 0x01, Z(xx0A) },
|
||||
{ Z(DimmerUp), 0x0008, 0x06, 0x01, Z(00) },
|
||||
{ Z(DimmerDown), 0x0008, 0x06, 0x01, Z(01) },
|
||||
{ Z(DimmerStop), 0x0008, 0x07, 0x01, Z() },
|
||||
{ Z(HueMove), 0x0300, 0x01, 0x01, Z(xx19) },
|
||||
{ Z(HueStep), 0x0300, 0x02, 0x01, Z(xx190A00) },
|
||||
{ Z(SatMove), 0x0300, 0x04, 0x01, Z(xx19) },
|
||||
{ Z(SatStep), 0x0300, 0x05, 0x01, Z(xx190A) },
|
||||
{ Z(ColorMove), 0x0300, 0x08, 0x01, Z(xxxxyyyy) },
|
||||
{ Z(ColorStep), 0x0300, 0x09, 0x01, Z(xxxxyyyy0A00) },
|
||||
// Tradfri
|
||||
{ "ArrowClick", 0x0005, 0x07, 0x01, "xx" }, // xx == 0x01 = left, 0x00 = right
|
||||
{ "ArrowHold", 0x0005, 0x08, 0x01, "xx" }, // xx == 0x01 = left, 0x00 = right
|
||||
{ "ArrowRelease", 0x0005, 0x09, 0x01, "" },
|
||||
{ Z(ArrowClick), 0x0005, 0x07, 0x01, Z(xx) }, // xx == 0x01 = left, 0x00 = right
|
||||
{ Z(ArrowHold), 0x0005, 0x08, 0x01, Z(xx) }, // xx == 0x01 = left, 0x00 = right
|
||||
{ Z(ArrowRelease), 0x0005, 0x09, 0x01, Z() },
|
||||
// IAS - Intruder Alarm System + leak/fire detection
|
||||
{ "ZoneStatusChange",0x0500, 0x00, 0x82, "xxxxyyzz" }, // xxxx = zone status, yy = extended status, zz = zone id, Delay is ignored
|
||||
{ Z(ZoneStatusChange),0x0500, 0x00, 0x82, Z(xxxxyyzz) }, // xxxx = zone status, yy = extended status, zz = zone id, Delay is ignored
|
||||
// responses for Group cluster commands
|
||||
{ "AddGroup", 0x0004, 0x00, 0x82, "xxyyyy" }, // xx = status, yy = group id
|
||||
{ "ViewGroup", 0x0004, 0x01, 0x82, "xxyyyy" }, // xx = status, yy = group id, name ignored
|
||||
{ "GetGroup", 0x0004, 0x02, 0x82, "xxyyzzzz" }, // xx = capacity, yy = count, zzzz = first group id, following groups ignored
|
||||
{ "RemoveGroup", 0x0004, 0x03, 0x82, "xxyyyy" }, // xx = status, yy = group id
|
||||
{ Z(AddGroup), 0x0004, 0x00, 0x82, Z(xxyyyy) }, // xx = status, yy = group id
|
||||
{ Z(ViewGroup), 0x0004, 0x01, 0x82, Z(xxyyyy) }, // xx = status, yy = group id, name ignored
|
||||
{ Z(GetGroup), 0x0004, 0x02, 0x82, Z(xxyyzzzz) }, // xx = capacity, yy = count, zzzz = first group id, following groups ignored
|
||||
{ Z(RemoveGroup), 0x0004, 0x03, 0x82, Z(xxyyyy) }, // xx = status, yy = group id
|
||||
// responses for Scene cluster commands
|
||||
{ Z(AddScene), 0x0005, 0x00, 0x82, Z(xxyyyyzz) }, // xx = status, yyyy = group id, zz = scene id
|
||||
{ Z(ViewScene), 0x0005, 0x01, 0x82, Z(xxyyyyzz) }, // xx = status, yyyy = group id, zz = scene id
|
||||
{ Z(RemoveScene), 0x0005, 0x02, 0x82, Z(xxyyyyzz) }, // xx = status, yyyy = group id, zz = scene id
|
||||
{ Z(RemoveAllScenes),0x0005, 0x03, 0x82, Z(xxyyyy) }, // xx = status, yyyy = group id
|
||||
{ Z(StoreScene), 0x0005, 0x04, 0x82, Z(xxyyyyzz) }, // xx = status, yyyy = group id, zz = scene id
|
||||
{ Z(GetSceneMembership),0x0005, 0x06, 0x82, Z() }, // specific
|
||||
};
|
||||
|
||||
#define ZLE(x) ((x) & 0xFF), ((x) >> 8) // Little Endian
|
||||
|
@ -105,10 +136,10 @@ const Z_CommandConverter Z_Commands[] PROGMEM = {
|
|||
const uint8_t CLUSTER_0006[] = { ZLE(0x0000) }; // Power
|
||||
const uint8_t CLUSTER_0008[] = { ZLE(0x0000) }; // CurrentLevel
|
||||
const uint8_t CLUSTER_0009[] = { ZLE(0x0000) }; // AlarmCount
|
||||
const uint8_t CLUSTER_0300[] = { ZLE(0x0000), ZLE(0x0001), ZLE(0x0003), ZLE(0x0004), ZLE(0x0007) }; // Hue, Sat, X, Y, CT
|
||||
const uint8_t CLUSTER_0300[] = { ZLE(0x0000), ZLE(0x0001), ZLE(0x0003), ZLE(0x0004), ZLE(0x0007), ZLE(0x0008) }; // Hue, Sat, X, Y, CT, ColorMode
|
||||
|
||||
// This callback is registered after a cluster specific command and sends a read command for the same cluster
|
||||
int32_t Z_ReadAttrCallback(uint16_t shortaddr, uint16_t cluster, uint16_t endpoint, uint32_t value) {
|
||||
int32_t Z_ReadAttrCallback(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) {
|
||||
size_t attrs_len = 0;
|
||||
const uint8_t* attrs = nullptr;
|
||||
|
||||
|
@ -131,12 +162,12 @@ int32_t Z_ReadAttrCallback(uint16_t shortaddr, uint16_t cluster, uint16_t endpoi
|
|||
break;
|
||||
}
|
||||
if (attrs) {
|
||||
ZigbeeZCLSend(shortaddr, cluster, endpoint, ZCL_READ_ATTRIBUTES, false, attrs, attrs_len, true /* we do want a response */, zigbee_devices.getNextSeqNumber(shortaddr));
|
||||
ZigbeeZCLSend_Raw(shortaddr, groupaddr, cluster, endpoint, ZCL_READ_ATTRIBUTES, false, attrs, attrs_len, true /* we do want a response */, zigbee_devices.getNextSeqNumber(shortaddr));
|
||||
}
|
||||
}
|
||||
|
||||
// set a timer to read back the value in the future
|
||||
void zigbeeSetCommandTimer(uint16_t shortaddr, uint16_t cluster, uint16_t endpoint) {
|
||||
void zigbeeSetCommandTimer(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint) {
|
||||
uint32_t wait_ms = 0;
|
||||
|
||||
switch (cluster) {
|
||||
|
@ -153,7 +184,7 @@ void zigbeeSetCommandTimer(uint16_t shortaddr, uint16_t cluster, uint16_t endpoi
|
|||
break;
|
||||
}
|
||||
if (wait_ms) {
|
||||
zigbee_devices.setTimer(shortaddr, wait_ms, cluster, endpoint, 0 /* value */, &Z_ReadAttrCallback);
|
||||
zigbee_devices.setTimer(shortaddr, groupaddr, wait_ms, cluster, endpoint, Z_CAT_NONE, 0 /* value */, &Z_ReadAttrCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +260,42 @@ void parseXYZ(const char *model, const SBuffer &payload, struct Z_XYZ_Var *xyz)
|
|||
// - cluster number
|
||||
// - command number or 0xFF if command is part of the variable part
|
||||
// - the payload in the form of a HEX string with x/y/z variables
|
||||
void sendHueUpdate(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t cmd, bool direction) {
|
||||
if (direction) { return; } // no need to update if server->client
|
||||
|
||||
int32_t z_cat = -1;
|
||||
uint32_t wait_ms = 0;
|
||||
|
||||
switch (cluster) {
|
||||
case 0x0006:
|
||||
z_cat = Z_CAT_READ_0006;
|
||||
wait_ms = 200; // wait 0.2 s
|
||||
break;
|
||||
case 0x0008:
|
||||
z_cat = Z_CAT_READ_0008;
|
||||
wait_ms = 1050; // wait 1.0 s
|
||||
break;
|
||||
case 0x0102:
|
||||
z_cat = Z_CAT_READ_0102;
|
||||
wait_ms = 10000; // wait 10.0 s
|
||||
break;
|
||||
case 0x0300:
|
||||
z_cat = Z_CAT_READ_0300;
|
||||
wait_ms = 1050; // wait 1.0 s
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (z_cat >= 0) {
|
||||
uint8_t endpoint = 0;
|
||||
if (!groupaddr) {
|
||||
endpoint = zigbee_devices.findClusterEndpointIn(shortaddr, cluster);
|
||||
}
|
||||
if ((endpoint) || (groupaddr)) { // send only if we know the endpoint
|
||||
zigbee_devices.setTimer(shortaddr, groupaddr, wait_ms, cluster, endpoint, z_cat, 0 /* value */, &Z_ReadAttrCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse a cluster specific command, and try to convert into human readable
|
||||
|
@ -314,17 +380,17 @@ void convertClusterSpecific(JsonObject& json, uint16_t cluster, uint8_t cmd, boo
|
|||
if ((cluster == 0x0500) && (cmd == 0x00)) {
|
||||
// "ZoneStatusChange"
|
||||
json[command_name] = xyz.x;
|
||||
json[command_name2 + "Ext"] = xyz.y;
|
||||
json[command_name2 + "Zone"] = xyz.z;
|
||||
json[command_name2 + F("Ext")] = xyz.y;
|
||||
json[command_name2 + F("Zone")] = xyz.z;
|
||||
} else if ((cluster == 0x0004) && ((cmd == 0x00) || (cmd == 0x01) || (cmd == 0x03))) {
|
||||
// AddGroupResp or ViewGroupResp (group name ignored) or RemoveGroup
|
||||
json[command_name] = xyz.y;
|
||||
json[command_name2 + "Status"] = xyz.x;
|
||||
json[command_name2 + "StatusMsg"] = getZigbeeStatusMessage(xyz.x);
|
||||
json[command_name2 + F("Status")] = xyz.x;
|
||||
json[command_name2 + F("StatusMsg")] = getZigbeeStatusMessage(xyz.x);
|
||||
} else if ((cluster == 0x0004) && (cmd == 0x02)) {
|
||||
// GetGroupResp
|
||||
json[command_name2 + "Capacity"] = xyz.x;
|
||||
json[command_name2 + "Count"] = xyz.y;
|
||||
json[command_name2 + F("Capacity")] = xyz.x;
|
||||
json[command_name2 + F("Count")] = xyz.y;
|
||||
JsonArray &arr = json.createNestedArray(command_name);
|
||||
for (uint32_t i = 0; i < xyz.y; i++) {
|
||||
arr.add(payload.get16(2 + 2*i));
|
||||
|
|
|
@ -165,28 +165,28 @@ ZBM(ZBR_VERSION, Z_SRSP | Z_SYS, SYS_VERSION ) // 6102 Z_SYS:versio
|
|||
|
||||
// Check if ZNP_HAS_CONFIGURED is set
|
||||
ZBM(ZBS_ZNPHC, Z_SREQ | Z_SYS, SYS_OSAL_NV_READ, ZNP_HAS_CONFIGURED & 0xFF, ZNP_HAS_CONFIGURED >> 8, 0x00 /* offset */ ) // 2108000F00 - 6108000155
|
||||
ZBM(ZBR_ZNPHC, Z_SRSP | Z_SYS, SYS_OSAL_NV_READ, Z_Success, 0x01 /* len */, 0x55) // 6108000155
|
||||
// If not set, the response is 61-08-02-00 = Z_SRSP | Z_SYS, SYS_OSAL_NV_READ, Z_InvalidParameter, 0x00 /* len */
|
||||
ZBM(ZBR_ZNPHC, Z_SRSP | Z_SYS, SYS_OSAL_NV_READ, Z_SUCCESS, 0x01 /* len */, 0x55) // 6108000155
|
||||
// If not set, the response is 61-08-02-00 = Z_SRSP | Z_SYS, SYS_OSAL_NV_READ, Z_INVALIDPARAMETER, 0x00 /* len */
|
||||
|
||||
ZBM(ZBS_PAN, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_PANID ) // 260483
|
||||
ZBM(ZBR_PAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_Success, CONF_PANID, 0x02 /* len */,
|
||||
ZBM(ZBR_PAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PANID, 0x02 /* len */,
|
||||
Z_B0(USE_ZIGBEE_PANID), Z_B1(USE_ZIGBEE_PANID) ) // 6604008302xxxx
|
||||
|
||||
ZBM(ZBS_EXTPAN, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_EXTENDED_PAN_ID ) // 26042D
|
||||
ZBM(ZBR_EXTPAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_Success, CONF_EXTENDED_PAN_ID,
|
||||
ZBM(ZBR_EXTPAN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_EXTENDED_PAN_ID,
|
||||
0x08 /* len */,
|
||||
Z_B0(USE_ZIGBEE_EXTPANID), Z_B1(USE_ZIGBEE_EXTPANID), Z_B2(USE_ZIGBEE_EXTPANID), Z_B3(USE_ZIGBEE_EXTPANID),
|
||||
Z_B4(USE_ZIGBEE_EXTPANID), Z_B5(USE_ZIGBEE_EXTPANID), Z_B6(USE_ZIGBEE_EXTPANID), Z_B7(USE_ZIGBEE_EXTPANID),
|
||||
) // 6604002D08xxxxxxxxxxxxxxxx
|
||||
|
||||
ZBM(ZBS_CHANN, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_CHANLIST ) // 260484
|
||||
ZBM(ZBR_CHANN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_Success, CONF_CHANLIST,
|
||||
ZBM(ZBR_CHANN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_CHANLIST,
|
||||
0x04 /* len */,
|
||||
Z_B0(USE_ZIGBEE_CHANNEL_MASK), Z_B1(USE_ZIGBEE_CHANNEL_MASK), Z_B2(USE_ZIGBEE_CHANNEL_MASK), Z_B3(USE_ZIGBEE_CHANNEL_MASK),
|
||||
) // 6604008404xxxxxxxx
|
||||
|
||||
ZBM(ZBS_PFGK, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_PRECFGKEY ) // 260462
|
||||
ZBM(ZBR_PFGK, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_Success, CONF_PRECFGKEY,
|
||||
ZBM(ZBR_PFGK, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PRECFGKEY,
|
||||
0x10 /* len */,
|
||||
Z_B0(USE_ZIGBEE_PRECFGKEY_L), Z_B1(USE_ZIGBEE_PRECFGKEY_L), Z_B2(USE_ZIGBEE_PRECFGKEY_L), Z_B3(USE_ZIGBEE_PRECFGKEY_L),
|
||||
Z_B4(USE_ZIGBEE_PRECFGKEY_L), Z_B5(USE_ZIGBEE_PRECFGKEY_L), Z_B6(USE_ZIGBEE_PRECFGKEY_L), Z_B7(USE_ZIGBEE_PRECFGKEY_L),
|
||||
|
@ -196,13 +196,13 @@ ZBM(ZBR_PFGK, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_Success, CONF_PRECFGKE
|
|||
0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0D*/ ) // 660400621001030507090B0D0F00020406080A0C0D
|
||||
|
||||
ZBM(ZBS_PFGKEN, Z_SREQ | Z_SAPI, SAPI_READ_CONFIGURATION, CONF_PRECFGKEYS_ENABLE ) // 260463
|
||||
ZBM(ZBR_PFGKEN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_Success, CONF_PRECFGKEYS_ENABLE,
|
||||
ZBM(ZBR_PFGKEN, Z_SRSP | Z_SAPI, SAPI_READ_CONFIGURATION, Z_SUCCESS, CONF_PRECFGKEYS_ENABLE,
|
||||
0x01 /* len */, 0x00 ) // 660400630100
|
||||
|
||||
// commands to "format" the device
|
||||
// Write configuration - write success
|
||||
ZBM(ZBR_W_OK, Z_SRSP | Z_SAPI, SAPI_WRITE_CONFIGURATION, Z_Success ) // 660500 - Write Configuration
|
||||
ZBM(ZBR_WNV_OK, Z_SRSP | Z_SYS, SYS_OSAL_NV_WRITE, Z_Success ) // 610900 - NV Write
|
||||
ZBM(ZBR_W_OK, Z_SRSP | Z_SAPI, SAPI_WRITE_CONFIGURATION, Z_SUCCESS ) // 660500 - Write Configuration
|
||||
ZBM(ZBR_WNV_OK, Z_SRSP | Z_SYS, SYS_OSAL_NV_WRITE, Z_SUCCESS ) // 610900 - NV Write
|
||||
|
||||
// Factory reset
|
||||
ZBM(ZBS_FACTRES, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_STARTUP_OPTION, 0x01 /* len */, 0x02 ) // 2605030102
|
||||
|
@ -243,7 +243,7 @@ ZBM(ZBS_W_ZDODCB, Z_SREQ | Z_SAPI, SAPI_WRITE_CONFIGURATION, CONF_ZDO_DIRECT_CB,
|
|||
ZBM(ZBS_WNV_INITZNPHC, Z_SREQ | Z_SYS, SYS_OSAL_NV_ITEM_INIT, ZNP_HAS_CONFIGURED & 0xFF, ZNP_HAS_CONFIGURED >> 8,
|
||||
0x01, 0x00 /* InitLen 16 bits */, 0x01 /* len */, 0x00 ) // 2107000F01000100 - 610709
|
||||
// Init succeeded
|
||||
//ZBM(ZBR_WNV_INIT_OK, Z_SRSP | Z_SYS, SYS_OSAL_NV_ITEM_INIT, Z_Created ) // 610709 - NV Write
|
||||
//ZBM(ZBR_WNV_INIT_OK, Z_SRSP | Z_SYS, SYS_OSAL_NV_ITEM_INIT, Z_CREATED ) // 610709 - NV Write
|
||||
ZBM(ZBR_WNV_INIT_OK, Z_SRSP | Z_SYS, SYS_OSAL_NV_ITEM_INIT ) // 6107xx, Success if 610700 or 610709 - NV Write
|
||||
|
||||
// Write ZNP Has Configured
|
||||
|
@ -255,7 +255,7 @@ ZBM(ZBR_STARTUPFROMAPP, Z_SRSP | Z_ZDO, ZDO_STARTUP_FROM_APP ) // 6540 + 01 fo
|
|||
ZBM(AREQ_STARTUPFROMAPP, Z_AREQ | Z_ZDO, ZDO_STATE_CHANGE_IND, ZDO_DEV_ZB_COORD ) // 45C009 + 08 = starting, 09 = started
|
||||
// GetDeviceInfo
|
||||
ZBM(ZBS_GETDEVICEINFO, Z_SREQ | Z_UTIL, Z_UTIL_GET_DEVICE_INFO ) // 2700
|
||||
ZBM(ZBR_GETDEVICEINFO, Z_SRSP | Z_UTIL, Z_UTIL_GET_DEVICE_INFO, Z_Success ) // Ex= 6700.00.6263151D004B1200.0000.07.09.00
|
||||
ZBM(ZBR_GETDEVICEINFO, Z_SRSP | Z_UTIL, Z_UTIL_GET_DEVICE_INFO, Z_SUCCESS ) // Ex= 6700.00.6263151D004B1200.0000.07.09.00
|
||||
// IEEE Adr (8 bytes) = 6263151D004B1200
|
||||
// Short Addr (2 bytes) = 0000
|
||||
// Device Type (1 byte) = 07 (coord?)
|
||||
|
@ -267,7 +267,7 @@ ZBM(ZBR_GETDEVICEINFO, Z_SRSP | Z_UTIL, Z_UTIL_GET_DEVICE_INFO, Z_Success ) //
|
|||
|
||||
// Z_ZDO:nodeDescReq
|
||||
ZBM(ZBS_ZDO_NODEDESCREQ, Z_SREQ | Z_ZDO, ZDO_NODE_DESC_REQ, 0x00, 0x00 /* dst addr */, 0x00, 0x00 /* NWKAddrOfInterest */) // 250200000000
|
||||
ZBM(ZBR_ZDO_NODEDESCREQ, Z_SRSP | Z_ZDO, ZDO_NODE_DESC_REQ, Z_Success ) // 650200
|
||||
ZBM(ZBR_ZDO_NODEDESCREQ, Z_SRSP | Z_ZDO, ZDO_NODE_DESC_REQ, Z_SUCCESS ) // 650200
|
||||
// Async resp ex: 4582.0000.00.0000.00.40.8F.0000.50.A000.0100.A000.00
|
||||
ZBM(AREQ_ZDO_NODEDESCRSP, Z_AREQ | Z_ZDO, ZDO_NODE_DESC_RSP) // 4582
|
||||
// SrcAddr (2 bytes) 0000
|
||||
|
@ -285,32 +285,25 @@ ZBM(AREQ_ZDO_NODEDESCRSP, Z_AREQ | Z_ZDO, ZDO_NODE_DESC_RSP) // 4582
|
|||
|
||||
// Z_ZDO:activeEpReq
|
||||
ZBM(ZBS_ZDO_ACTIVEEPREQ, Z_SREQ | Z_ZDO, ZDO_ACTIVE_EP_REQ, 0x00, 0x00, 0x00, 0x00) // 250500000000
|
||||
ZBM(ZBR_ZDO_ACTIVEEPREQ, Z_SRSP | Z_ZDO, ZDO_ACTIVE_EP_REQ, Z_Success) // 65050000
|
||||
ZBM(ZBR_ZDO_ACTIVEEPRSP_NONE, Z_AREQ | Z_ZDO, ZDO_ACTIVE_EP_RSP, 0x00, 0x00 /* srcAddr */, Z_Success,
|
||||
ZBM(ZBR_ZDO_ACTIVEEPREQ, Z_SRSP | Z_ZDO, ZDO_ACTIVE_EP_REQ, Z_SUCCESS) // 65050000
|
||||
ZBM(ZBR_ZDO_ACTIVEEPRSP_NONE, Z_AREQ | Z_ZDO, ZDO_ACTIVE_EP_RSP, 0x00, 0x00 /* srcAddr */, Z_SUCCESS,
|
||||
0x00, 0x00 /* nwkaddr */, 0x00 /* activeepcount */) // 45050000 - no Ep running
|
||||
ZBM(ZBR_ZDO_ACTIVEEPRSP_OK, Z_AREQ | Z_ZDO, ZDO_ACTIVE_EP_RSP, 0x00, 0x00 /* srcAddr */, Z_Success,
|
||||
ZBM(ZBR_ZDO_ACTIVEEPRSP_OK, Z_AREQ | Z_ZDO, ZDO_ACTIVE_EP_RSP, 0x00, 0x00 /* srcAddr */, Z_SUCCESS,
|
||||
0x00, 0x00 /* nwkaddr */, 0x02 /* activeepcount */, 0x0B, 0x01 /* the actual endpoints */) // 25050000 - no Ep running
|
||||
|
||||
// Z_AF:register profile:104, ep:01
|
||||
ZBM(ZBS_AF_REGISTER01, Z_SREQ | Z_AF, AF_REGISTER, 0x01 /* endpoint */, Z_B0(Z_PROF_HA), Z_B1(Z_PROF_HA), // 24000401050000000000
|
||||
0x05, 0x00 /* AppDeviceId */, 0x00 /* AppDevVer */, 0x00 /* LatencyReq */,
|
||||
0x00 /* AppNumInClusters */, 0x00 /* AppNumInClusters */)
|
||||
ZBM(ZBR_AF_REGISTER, Z_SRSP | Z_AF, AF_REGISTER, Z_Success) // 640000
|
||||
ZBM(ZBR_AF_REGISTER, Z_SRSP | Z_AF, AF_REGISTER, Z_SUCCESS) // 640000
|
||||
ZBM(ZBS_AF_REGISTER0B, Z_SREQ | Z_AF, AF_REGISTER, 0x0B /* endpoint */, Z_B0(Z_PROF_HA), Z_B1(Z_PROF_HA), // 2400040B050000000000
|
||||
0x05, 0x00 /* AppDeviceId */, 0x00 /* AppDevVer */, 0x00 /* LatencyReq */,
|
||||
0x00 /* AppNumInClusters */, 0x00 /* AppNumInClusters */)
|
||||
// Z_ZDO:mgmtPermitJoinReq
|
||||
ZBM(ZBS_PERMITJOINREQ_CLOSE, Z_SREQ | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_REQ, 0x02 /* AddrMode */, // 25360200000000
|
||||
0x00, 0x00 /* DstAddr */, 0x00 /* Duration */, 0x00 /* TCSignificance */)
|
||||
ZBM(ZBS_PERMITJOINREQ_OPEN_60, Z_SREQ | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_REQ, 0x0F /* AddrMode */, // 25360FFFFC3C00
|
||||
0xFC, 0xFF /* DstAddr */, 60 /* Duration */, 0x00 /* TCSignificance */)
|
||||
ZBM(ZBS_PERMITJOINREQ_OPEN_XX, Z_SREQ | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_REQ, 0x0F /* AddrMode */, // 25360FFFFCFF00
|
||||
0xFC, 0xFF /* DstAddr */, 0xFF /* Duration */, 0x00 /* TCSignificance */)
|
||||
ZBM(ZBR_PERMITJOINREQ, Z_SRSP | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_REQ, Z_Success) // 653600
|
||||
ZBM(ZBR_PERMITJOIN_AREQ_CLOSE, Z_AREQ | Z_ZDO, ZDO_PERMIT_JOIN_IND, 0x00 /* Duration */) // 45CB00
|
||||
ZBM(ZBR_PERMITJOIN_AREQ_OPEN_60, Z_AREQ | Z_ZDO, ZDO_PERMIT_JOIN_IND, 60 /* Duration */) // 45CB3C
|
||||
ZBM(ZBR_PERMITJOIN_AREQ_OPEN_FF, Z_AREQ | Z_ZDO, ZDO_PERMIT_JOIN_IND, 0xFF /* Duration */) // 45CBFF
|
||||
ZBM(ZBR_PERMITJOIN_AREQ_RSP, Z_AREQ | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_RSP, 0x00, 0x00 /* srcAddr*/, Z_Success ) // 45B6000000
|
||||
ZBM(ZBR_PERMITJOINREQ, Z_SRSP | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_REQ, Z_SUCCESS) // 653600
|
||||
ZBM(ZBR_PERMITJOIN_AREQ_RSP, Z_AREQ | Z_ZDO, ZDO_MGMT_PERMIT_JOIN_RSP, 0x00, 0x00 /* srcAddr*/, Z_SUCCESS ) // 45B6000000
|
||||
|
||||
static const Zigbee_Instruction zb_prog[] PROGMEM = {
|
||||
ZI_LABEL(0)
|
||||
|
@ -346,7 +339,6 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
|
|||
|
||||
ZI_LABEL(ZIGBEE_LABEL_START) // START ZNP App
|
||||
ZI_MQTT_STATE(ZIGBEE_STATUS_STARTING, "Configured, starting coordinator")
|
||||
//ZI_CALL(&Z_State_Ready, 1) // Now accept incoming messages
|
||||
ZI_ON_ERROR_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
// Z_ZDO:startupFromApp
|
||||
//ZI_LOG(LOG_LEVEL_INFO, D_LOG_ZIGBEE "starting zigbee coordinator")
|
||||
|
@ -366,53 +358,24 @@ ZI_SEND(ZBS_STARTUPFROMAPP) // start coordinator
|
|||
ZI_WAIT_RECV(1000, ZBR_AF_REGISTER)
|
||||
ZI_SEND(ZBS_AF_REGISTER0B) // Z_AF register for endpoint 0B, profile 0x0104 Home Automation
|
||||
ZI_WAIT_RECV(1000, ZBR_AF_REGISTER)
|
||||
// Z_ZDO:nodeDescReq ?? Is is useful to redo it? TODO
|
||||
// redo Z_ZDO:activeEpReq to check that Ep are available
|
||||
ZI_SEND(ZBS_ZDO_ACTIVEEPREQ) // Z_ZDO:activeEpReq
|
||||
ZI_WAIT_RECV(1000, ZBR_ZDO_ACTIVEEPREQ)
|
||||
ZI_WAIT_UNTIL(1000, ZBR_ZDO_ACTIVEEPRSP_OK)
|
||||
ZI_SEND(ZBS_PERMITJOINREQ_CLOSE) // Closing the Permit Join
|
||||
ZI_WAIT_RECV(1000, ZBR_PERMITJOINREQ)
|
||||
ZI_WAIT_UNTIL(1000, ZBR_PERMITJOIN_AREQ_RSP) // not sure it's useful
|
||||
//ZI_WAIT_UNTIL(500, ZBR_PERMITJOIN_AREQ_CLOSE)
|
||||
//ZI_SEND(ZBS_PERMITJOINREQ_OPEN_XX) // Opening Permit Join, normally through command
|
||||
//ZI_WAIT_RECV(1000, ZBR_PERMITJOINREQ)
|
||||
//ZI_WAIT_UNTIL(1000, ZBR_PERMITJOIN_AREQ_RSP) // not sure it's useful
|
||||
//ZI_WAIT_UNTIL(500, ZBR_PERMITJOIN_AREQ_OPEN_FF)
|
||||
|
||||
ZI_WAIT_UNTIL(1000, ZBR_PERMITJOIN_AREQ_RSP)
|
||||
|
||||
ZI_LABEL(ZIGBEE_LABEL_READY)
|
||||
ZI_MQTT_STATE(ZIGBEE_STATUS_OK, "Started")
|
||||
ZI_LOG(LOG_LEVEL_INFO, D_LOG_ZIGBEE "Zigbee started")
|
||||
ZI_CALL(&Z_State_Ready, 1) // Now accept incoming messages
|
||||
ZI_CALL(&Z_Load_Devices, 0)
|
||||
ZI_CALL(&Z_Query_Bulbs, 0)
|
||||
ZI_LABEL(ZIGBEE_LABEL_MAIN_LOOP)
|
||||
ZI_WAIT_FOREVER()
|
||||
ZI_GOTO(ZIGBEE_LABEL_READY)
|
||||
|
||||
ZI_LABEL(ZIGBEE_LABEL_PERMIT_JOIN_CLOSE)
|
||||
//ZI_MQTT_STATE(ZIGBEE_STATUS_PERMITJOIN_CLOSE, "Disable Pairing mode")
|
||||
ZI_SEND(ZBS_PERMITJOINREQ_CLOSE) // Closing the Permit Join
|
||||
ZI_WAIT_RECV(1000, ZBR_PERMITJOINREQ)
|
||||
//ZI_WAIT_UNTIL(1000, ZBR_PERMITJOIN_AREQ_RSP) // not sure it's useful
|
||||
//ZI_WAIT_UNTIL(500, ZBR_PERMITJOIN_AREQ_CLOSE)
|
||||
ZI_GOTO(ZIGBEE_LABEL_MAIN_LOOP)
|
||||
|
||||
ZI_LABEL(ZIGBEE_LABEL_PERMIT_JOIN_OPEN_60)
|
||||
//ZI_MQTT_STATE(ZIGBEE_STATUS_PERMITJOIN_OPEN_60, "Enable Pairing mode for 60 seconds")
|
||||
ZI_SEND(ZBS_PERMITJOINREQ_OPEN_60)
|
||||
ZI_WAIT_RECV(1000, ZBR_PERMITJOINREQ)
|
||||
//ZI_WAIT_UNTIL(1000, ZBR_PERMITJOIN_AREQ_RSP) // not sure it's useful
|
||||
//ZI_WAIT_UNTIL(500, ZBR_PERMITJOIN_AREQ_OPEN_60)
|
||||
ZI_GOTO(ZIGBEE_LABEL_MAIN_LOOP)
|
||||
|
||||
ZI_LABEL(ZIGBEE_LABEL_PERMIT_JOIN_OPEN_XX)
|
||||
//ZI_MQTT_STATE(ZIGBEE_STATUS_PERMITJOIN_OPEN_XX, "Enable Pairing mode until next boot")
|
||||
ZI_SEND(ZBS_PERMITJOINREQ_OPEN_XX)
|
||||
ZI_WAIT_RECV(1000, ZBR_PERMITJOINREQ)
|
||||
//ZI_WAIT_UNTIL(1000, ZBR_PERMITJOIN_AREQ_RSP) // not sure it's useful
|
||||
//ZI_WAIT_UNTIL(500, ZBR_PERMITJOIN_AREQ_OPEN_FF)
|
||||
ZI_GOTO(ZIGBEE_LABEL_MAIN_LOOP)
|
||||
|
||||
ZI_LABEL(50) // reformat device
|
||||
ZI_MQTT_STATE(ZIGBEE_STATUS_RESET_CONF, "Reseting configuration")
|
||||
//ZI_LOG(LOG_LEVEL_INFO, D_LOG_ZIGBEE "zigbee bad configuration of device, doing a factory reset")
|
||||
|
@ -533,6 +496,7 @@ void ZigbeeStateMachine_Run(void) {
|
|||
zigbee.recv_until = false;
|
||||
zigbee.state_no_timeout = false; // reset the no_timeout for next instruction
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeStateMachine_Run PC = %d, Mem1 = %d"), zigbee.pc, ESP.getFreeHeap());
|
||||
if (zigbee.pc > (sizeof(zb_prog)/sizeof(zb_prog[0]))) {
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Invalid pc: %d, aborting"), zigbee.pc);
|
||||
zigbee.pc = -1;
|
||||
|
|
|
@ -223,8 +223,6 @@ int32_t Z_ReceiveNodeDesc(int32_t res, const class SBuffer &buf) {
|
|||
uint8_t descriptorCapabilities = buf.get8(19);
|
||||
|
||||
if (0 == status) {
|
||||
zigbee_devices.updateLastSeen(nwkAddr);
|
||||
|
||||
uint8_t deviceType = logicalType & 0x7; // 0=coordinator, 1=router, 2=end device
|
||||
if (deviceType > 3) { deviceType = 3; }
|
||||
bool complexDescriptorAvailable = (logicalType & 0x08) ? 1 : 0;
|
||||
|
@ -364,11 +362,11 @@ int32_t Z_ReceiveIEEEAddr(int32_t res, const class SBuffer &buf) {
|
|||
// MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||
// XdrvRulesProcess();
|
||||
// Ping response
|
||||
const String * friendlyName = zigbee_devices.getFriendlyName(nwkAddr);
|
||||
const char * friendlyName = zigbee_devices.getFriendlyName(nwkAddr);
|
||||
if (friendlyName) {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_PING "\":{\"" D_JSON_ZIGBEE_DEVICE "\":\"0x%04X\""
|
||||
",\"" D_JSON_ZIGBEE_IEEE "\":\"0x%s\""
|
||||
",\"" D_JSON_ZIGBEE_NAME "\":\"%s\"}}"), nwkAddr, hex, friendlyName->c_str());
|
||||
",\"" D_JSON_ZIGBEE_NAME "\":\"%s\"}}"), nwkAddr, hex, friendlyName);
|
||||
} else {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_PING "\":{\"" D_JSON_ZIGBEE_DEVICE "\":\"0x%04X\""
|
||||
",\"" D_JSON_ZIGBEE_IEEE "\":\"0x%s\""
|
||||
|
@ -384,17 +382,23 @@ int32_t Z_ReceiveIEEEAddr(int32_t res, const class SBuffer &buf) {
|
|||
int32_t Z_BindRsp(int32_t res, const class SBuffer &buf) {
|
||||
Z_ShortAddress nwkAddr = buf.get16(2);
|
||||
uint8_t status = buf.get8(4);
|
||||
char status_message[32];
|
||||
|
||||
const String * friendlyName = zigbee_devices.getFriendlyName(nwkAddr);
|
||||
strncpy_P(status_message, (const char*) getZigbeeStatusMessage(status), sizeof(status_message));
|
||||
status_message[sizeof(status_message)-1] = 0; // truncate if needed, strlcpy is safer but strlcpy_P does not exist
|
||||
|
||||
const char * friendlyName = zigbee_devices.getFriendlyName(nwkAddr);
|
||||
if (friendlyName) {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_BIND "\":{\"" D_JSON_ZIGBEE_DEVICE "\":\"0x%04X\""
|
||||
",\"" D_JSON_ZIGBEE_NAME "\":\"%s\""
|
||||
",\"" D_JSON_ZIGBEE_Status "\":%d"
|
||||
"}}"), nwkAddr, friendlyName->c_str(), status);
|
||||
",\"" D_JSON_ZIGBEE_STATUS "\":%d"
|
||||
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
||||
"}}"), nwkAddr, friendlyName, status, status_message);
|
||||
} else {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_BIND "\":{\"" D_JSON_ZIGBEE_DEVICE "\":\"0x%04X\""
|
||||
",\"" D_JSON_ZIGBEE_Status "\":%d"
|
||||
"}}"), nwkAddr, status);
|
||||
",\"" D_JSON_ZIGBEE_STATUS "\":%d"
|
||||
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
||||
"}}"), nwkAddr, status, status_message);
|
||||
}
|
||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||
XdrvRulesProcess();
|
||||
|
@ -402,6 +406,31 @@ int32_t Z_BindRsp(int32_t res, const class SBuffer &buf) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Report any AF_DATA_CONFIRM message
|
||||
// Ex: {"ZbConfirm":{"Endpoint":1,"Status":0,"StatusMessage":"SUCCESS"}}
|
||||
//
|
||||
int32_t Z_DataConfirm(int32_t res, const class SBuffer &buf) {
|
||||
uint8_t status = buf.get8(2);
|
||||
uint8_t endpoint = buf.get8(3);
|
||||
//uint8_t transId = buf.get8(4);
|
||||
char status_message[32];
|
||||
|
||||
if (status) { // only report errors
|
||||
strncpy_P(status_message, (const char*) getZigbeeStatusMessage(status), sizeof(status_message));
|
||||
status_message[sizeof(status_message)-1] = 0; // truncate if needed, strlcpy is safer but strlcpy_P does not exist
|
||||
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_CONFIRM "\":{\"" D_CMND_ZIGBEE_ENDPOINT "\":%d"
|
||||
",\"" D_JSON_ZIGBEE_STATUS "\":%d"
|
||||
",\"" D_JSON_ZIGBEE_STATUS_MSG "\":\"%s\""
|
||||
"}}"), endpoint, status, status_message);
|
||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
|
||||
XdrvRulesProcess();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t Z_ReceiveEndDeviceAnnonce(int32_t res, const class SBuffer &buf) {
|
||||
Z_ShortAddress srcAddr = buf.get16(2);
|
||||
Z_ShortAddress nwkAddr = buf.get16(4);
|
||||
|
@ -453,21 +482,21 @@ int32_t Z_ReceiveTCDevInd(int32_t res, const class SBuffer &buf) {
|
|||
// Here we add a timer so if we don't receive a Occupancy event for 90 seconds, we send Occupancy:false
|
||||
const uint32_t OCCUPANCY_TIMEOUT = 90 * 1000; // 90 s
|
||||
|
||||
void Z_AqaraOccupancy(uint16_t shortaddr, uint16_t cluster, uint16_t endpoint, const JsonObject *json) {
|
||||
void Z_AqaraOccupancy(uint16_t shortaddr, uint16_t cluster, uint8_t endpoint, const JsonObject *json) {
|
||||
// Read OCCUPANCY value if any
|
||||
const JsonVariant &val_endpoint = getCaseInsensitive(*json, PSTR(OCCUPANCY));
|
||||
if (nullptr != &val_endpoint) {
|
||||
uint32_t occupancy = strToUInt(val_endpoint);
|
||||
|
||||
if (occupancy) {
|
||||
zigbee_devices.setTimer(shortaddr, OCCUPANCY_TIMEOUT, cluster, endpoint, 0, &Z_OccupancyCallback);
|
||||
zigbee_devices.setTimer(shortaddr, 0 /* groupaddr */, OCCUPANCY_TIMEOUT, cluster, endpoint, Z_CAT_VIRTUAL_ATTR, 0, &Z_OccupancyCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Publish the received values once they have been coalesced
|
||||
int32_t Z_PublishAttributes(uint16_t shortaddr, uint16_t cluster, uint16_t endpoint, uint32_t value) {
|
||||
int32_t Z_PublishAttributes(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) {
|
||||
const JsonObject *json = zigbee_devices.jsonGet(shortaddr);
|
||||
if (json == nullptr) { return 0; } // don't crash if not found
|
||||
// Post-provess for Aqara Presence Senson
|
||||
|
@ -491,7 +520,6 @@ int32_t Z_ReceiveAfIncomingMessage(int32_t res, const class SBuffer &buf) {
|
|||
|
||||
bool defer_attributes = false; // do we defer attributes reporting to coalesce
|
||||
|
||||
zigbee_devices.updateLastSeen(srcaddr);
|
||||
ZCLFrame zcl_received = ZCLFrame::parseRawFrame(buf, 19, buf.get8(18), clusterid, groupid,
|
||||
srcaddr,
|
||||
srcendpoint, dstendpoint, wasbroadcast,
|
||||
|
@ -503,7 +531,7 @@ int32_t Z_ReceiveAfIncomingMessage(int32_t res, const class SBuffer &buf) {
|
|||
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
|
||||
|
||||
if ( (!zcl_received.isClusterSpecificCommand()) && (ZCL_DEFAULT_RESPONSE == zcl_received.getCmdId())) {
|
||||
zcl_received.parseResponse();
|
||||
} else {
|
||||
|
@ -513,6 +541,7 @@ int32_t Z_ReceiveAfIncomingMessage(int32_t res, const class SBuffer &buf) {
|
|||
if (clusterid) { defer_attributes = true; } // don't defer system Cluster=0 messages
|
||||
} else if ( (!zcl_received.isClusterSpecificCommand()) && (ZCL_READ_ATTRIBUTES_RESPONSE == zcl_received.getCmdId())) {
|
||||
zcl_received.parseReadAttributes(json);
|
||||
if (clusterid) { defer_attributes = true; } // don't defer system Cluster=0 messages
|
||||
} else if (zcl_received.isClusterSpecificCommand()) {
|
||||
zcl_received.parseClusterSpecificCommand(json);
|
||||
}
|
||||
|
@ -538,7 +567,7 @@ int32_t Z_ReceiveAfIncomingMessage(int32_t res, const class SBuffer &buf) {
|
|||
zigbee_devices.jsonPublishFlush(srcaddr);
|
||||
}
|
||||
zigbee_devices.jsonAppend(srcaddr, json);
|
||||
zigbee_devices.setTimer(srcaddr, USE_ZIGBEE_COALESCE_ATTR_TIMER, clusterid, srcendpoint, 0, &Z_PublishAttributes);
|
||||
zigbee_devices.setTimer(srcaddr, 0 /* groupaddr */, USE_ZIGBEE_COALESCE_ATTR_TIMER, clusterid, srcendpoint, Z_CAT_READ_ATTR, 0, &Z_PublishAttributes);
|
||||
} else {
|
||||
// Publish immediately
|
||||
zigbee_devices.jsonPublishNow(srcaddr, json);
|
||||
|
@ -553,6 +582,7 @@ typedef struct Z_Dispatcher {
|
|||
} Z_Dispatcher;
|
||||
|
||||
// Filters for ZCL frames
|
||||
ZBM(AREQ_AF_DATA_CONFIRM, Z_AREQ | Z_AF, AF_DATA_CONFIRM) // 4480
|
||||
ZBM(AREQ_AF_INCOMING_MESSAGE, Z_AREQ | Z_AF, AF_INCOMING_MSG) // 4481
|
||||
ZBM(AREQ_END_DEVICE_ANNCE_IND, Z_AREQ | Z_ZDO, ZDO_END_DEVICE_ANNCE_IND) // 45C1
|
||||
ZBM(AREQ_END_DEVICE_TC_DEV_IND, Z_AREQ | Z_ZDO, ZDO_TC_DEV_IND) // 45CA
|
||||
|
@ -563,6 +593,7 @@ ZBM(AREQ_ZDO_IEEE_ADDR_RSP, Z_AREQ | Z_ZDO, ZDO_IEEE_ADDR_RSP) // 4581
|
|||
ZBM(AREQ_ZDO_BIND_RSP, Z_AREQ | Z_ZDO, ZDO_BIND_RSP) // 45A1
|
||||
|
||||
const Z_Dispatcher Z_DispatchTable[] PROGMEM = {
|
||||
{ AREQ_AF_DATA_CONFIRM, &Z_DataConfirm },
|
||||
{ AREQ_AF_INCOMING_MESSAGE, &Z_ReceiveAfIncomingMessage },
|
||||
{ AREQ_END_DEVICE_ANNCE_IND, &Z_ReceiveEndDeviceAnnonce },
|
||||
{ AREQ_END_DEVICE_TC_DEV_IND, &Z_ReceiveTCDevInd },
|
||||
|
@ -595,6 +626,42 @@ int32_t Z_Load_Devices(uint8_t value) {
|
|||
return 0; // continue
|
||||
}
|
||||
|
||||
int32_t Z_Query_Bulbs(uint8_t value) {
|
||||
// Scan all devices and send deferred requests to know the state of bulbs
|
||||
uint32_t wait_ms = 1000; // start with 1.0 s delay
|
||||
const uint32_t inter_message_ms = 100; // wait 100ms between messages
|
||||
for (uint32_t i = 0; i < zigbee_devices.devicesSize(); i++) {
|
||||
const Z_Device &device = zigbee_devices.devicesAt(i);
|
||||
|
||||
if (0 <= device.bulbtype) {
|
||||
uint16_t cluster;
|
||||
uint8_t endpoint;
|
||||
|
||||
cluster = 0x0006;
|
||||
endpoint = zigbee_devices.findClusterEndpointIn(device.shortaddr, cluster);
|
||||
if (endpoint) { // send only if we know the endpoint
|
||||
zigbee_devices.setTimer(device.shortaddr, 0 /* groupaddr */, wait_ms, cluster, endpoint, Z_CAT_NONE, 0 /* value */, &Z_ReadAttrCallback);
|
||||
wait_ms += inter_message_ms;
|
||||
}
|
||||
|
||||
cluster = 0x0008;
|
||||
endpoint = zigbee_devices.findClusterEndpointIn(device.shortaddr, cluster);
|
||||
if (endpoint) { // send only if we know the endpoint
|
||||
zigbee_devices.setTimer(device.shortaddr, 0 /* groupaddr */, wait_ms, cluster, endpoint, Z_CAT_NONE, 0 /* value */, &Z_ReadAttrCallback);
|
||||
wait_ms += inter_message_ms;
|
||||
}
|
||||
|
||||
cluster = 0x0300;
|
||||
endpoint = zigbee_devices.findClusterEndpointIn(device.shortaddr, cluster);
|
||||
if (endpoint) { // send only if we know the endpoint
|
||||
zigbee_devices.setTimer(device.shortaddr, 0 /* groupaddr */, wait_ms, cluster, endpoint, Z_CAT_NONE, 0 /* value */, &Z_ReadAttrCallback);
|
||||
wait_ms += inter_message_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; // continue
|
||||
}
|
||||
|
||||
int32_t Z_State_Ready(uint8_t value) {
|
||||
zigbee.init_phase = false; // initialization phase complete
|
||||
return 0; // continue
|
||||
|
|
|
@ -34,7 +34,8 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix
|
|||
D_CMND_ZIGBEE_STATUS "|" D_CMND_ZIGBEE_RESET "|" D_CMND_ZIGBEE_SEND "|"
|
||||
D_CMND_ZIGBEE_PROBE "|" D_CMND_ZIGBEE_READ "|" D_CMND_ZIGBEEZNPRECEIVE "|"
|
||||
D_CMND_ZIGBEE_FORGET "|" D_CMND_ZIGBEE_SAVE "|" D_CMND_ZIGBEE_NAME "|"
|
||||
D_CMND_ZIGBEE_BIND "|" D_CMND_ZIGBEE_PING "|" D_CMND_ZIGBEE_MODELID
|
||||
D_CMND_ZIGBEE_BIND "|" D_CMND_ZIGBEE_PING "|" D_CMND_ZIGBEE_MODELID "|"
|
||||
D_CMND_ZIGBEE_LIGHT
|
||||
;
|
||||
|
||||
void (* const ZigbeeCommand[])(void) PROGMEM = {
|
||||
|
@ -43,6 +44,7 @@ void (* const ZigbeeCommand[])(void) PROGMEM = {
|
|||
&CmndZbProbe, &CmndZbRead, &CmndZbZNPReceive,
|
||||
&CmndZbForget, &CmndZbSave, &CmndZbName,
|
||||
&CmndZbBind, &CmndZbPing, &CmndZbModelId,
|
||||
&CmndZbLight,
|
||||
};
|
||||
|
||||
int32_t ZigbeeProcessInput(class SBuffer &buf) {
|
||||
|
@ -106,7 +108,7 @@ int32_t ZigbeeProcessInput(class SBuffer &buf) {
|
|||
res = (*zigbee.recv_unexpected)(res, buf);
|
||||
}
|
||||
}
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "ZbProcessInput: res = %d"), res);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "ZbProcessInput: res = %d"), res);
|
||||
|
||||
// change state accordingly
|
||||
if (0 == res) {
|
||||
|
@ -217,6 +219,7 @@ void ZigbeeInput(void)
|
|||
|
||||
void ZigbeeInit(void)
|
||||
{
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem1 = %d"), ESP.getFreeHeap());
|
||||
zigbee.active = false;
|
||||
if ((pin[GPIO_ZIGBEE_RX] < 99) && (pin[GPIO_ZIGBEE_TX] < 99)) {
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "GPIOs Rx:%d Tx:%d"), pin[GPIO_ZIGBEE_RX], pin[GPIO_ZIGBEE_TX]);
|
||||
|
@ -228,13 +231,16 @@ void ZigbeeInit(void)
|
|||
uint32_t aligned_buffer = ((uint32_t)serial_in_buffer + 3) & ~3;
|
||||
zigbee_buffer = new PreAllocatedSBuffer(sizeof(serial_in_buffer) - 3, (char*) aligned_buffer);
|
||||
} else {
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem2 = %d"), ESP.getFreeHeap());
|
||||
zigbee_buffer = new SBuffer(ZIGBEE_BUFFER_SIZE);
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem3 = %d"), ESP.getFreeHeap());
|
||||
}
|
||||
zigbee.active = true;
|
||||
zigbee.init_phase = true; // start the state machine
|
||||
zigbee.state_machine = true; // start the state machine
|
||||
ZigbeeSerial->flush();
|
||||
}
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("ZigbeeInit Mem9 = %d"), ESP.getFreeHeap());
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
|
@ -341,30 +347,40 @@ void ZigbeeZNPSend(const uint8_t *msg, size_t len) {
|
|||
ToHex_P(msg, len, hex_char, sizeof(hex_char)));
|
||||
}
|
||||
|
||||
void ZigbeeZCLSend(uint16_t dtsAddr, uint16_t clusterId, uint8_t endpoint, uint8_t cmdId, bool clusterSpecific, const uint8_t *msg, size_t len, bool needResponse, uint8_t transacId) {
|
||||
SBuffer buf(25+len);
|
||||
buf.add8(Z_SREQ | Z_AF); // 24
|
||||
buf.add8(AF_DATA_REQUEST); // 01
|
||||
buf.add16(dtsAddr);
|
||||
buf.add8(endpoint); // dest endpoint
|
||||
buf.add8(0x01); // source endpoint
|
||||
void ZigbeeZCLSend_Raw(uint16_t shortaddr, uint16_t groupaddr, uint16_t clusterId, uint8_t endpoint, uint8_t cmdId, bool clusterSpecific, const uint8_t *msg, size_t len, bool needResponse, uint8_t transacId) {
|
||||
|
||||
SBuffer buf(32+len);
|
||||
buf.add8(Z_SREQ | Z_AF); // 24
|
||||
buf.add8(AF_DATA_REQUEST_EXT); // 02
|
||||
if (groupaddr) {
|
||||
buf.add8(Z_Addr_Group); // 01
|
||||
buf.add64(groupaddr); // group address, only 2 LSB, upper 6 MSB are discarded
|
||||
buf.add8(0xFF); // dest endpoint is not used for group addresses
|
||||
} else {
|
||||
buf.add8(Z_Addr_ShortAddress); // 02
|
||||
buf.add64(shortaddr); // dest address, only 2 LSB, upper 6 MSB are discarded
|
||||
buf.add8(endpoint); // dest endpoint
|
||||
}
|
||||
buf.add16(0x0000); // dest Pan ID, 0x0000 = intra-pan
|
||||
buf.add8(0x01); // source endpoint
|
||||
buf.add16(clusterId);
|
||||
buf.add8(transacId); // transacId
|
||||
buf.add8(0x30); // 30 options
|
||||
buf.add8(0x1E); // 1E radius
|
||||
buf.add8(transacId); // transacId
|
||||
buf.add8(0x30); // 30 options
|
||||
buf.add8(0x1E); // 1E radius
|
||||
|
||||
buf.add8(3 + len);
|
||||
buf.add16(3 + len);
|
||||
buf.add8((needResponse ? 0x00 : 0x10) | (clusterSpecific ? 0x01 : 0x00)); // Frame Control Field
|
||||
buf.add8(transacId); // Transaction Sequance Number
|
||||
buf.add8(transacId); // Transaction Sequance Number
|
||||
buf.add8(cmdId);
|
||||
if (len > 0) {
|
||||
buf.addBuffer(msg, len); // add the payload
|
||||
buf.addBuffer(msg, len); // add the payload
|
||||
}
|
||||
|
||||
ZigbeeZNPSend(buf.getBuffer(), buf.len());
|
||||
}
|
||||
|
||||
void zigbeeZCLSendStr(uint16_t dstAddr, uint8_t endpoint, bool clusterSpecific,
|
||||
// Send a command specified as an HEX string for the workload
|
||||
void zigbeeZCLSendStr(uint16_t shortaddr, uint16_t groupaddr, uint8_t endpoint, bool clusterSpecific,
|
||||
uint16_t cluster, uint8_t cmd, const char *param) {
|
||||
size_t size = param ? strlen(param) : 0;
|
||||
SBuffer buf((size+2)/2); // actual bytes buffer for data
|
||||
|
@ -376,26 +392,25 @@ void zigbeeZCLSendStr(uint16_t dstAddr, uint8_t endpoint, bool clusterSpecific,
|
|||
}
|
||||
}
|
||||
|
||||
if (0 == endpoint) {
|
||||
// endpoint is not specified, let's try to find it from shortAddr
|
||||
endpoint = zigbee_devices.findClusterEndpointIn(dstAddr, cluster);
|
||||
if ((0 == endpoint) && (shortaddr)) {
|
||||
// endpoint is not specified, let's try to find it from shortAddr, unless it's a group address
|
||||
endpoint = zigbee_devices.findClusterEndpointIn(shortaddr, cluster);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: guessing endpoint 0x%02X"), endpoint);
|
||||
}
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: dstAddr 0x%04X, cluster 0x%04X, endpoint 0x%02X, cmd 0x%02X, data %s"),
|
||||
dstAddr, cluster, endpoint, cmd, param);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: shortaddr 0x%04X, groupaddr 0x%04X, cluster 0x%04X, endpoint 0x%02X, cmd 0x%02X, data %s"),
|
||||
shortaddr, groupaddr, cluster, endpoint, cmd, param);
|
||||
|
||||
if (0 == endpoint) {
|
||||
if ((0 == endpoint) && (shortaddr)) {
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("ZbSend: unspecified endpoint"));
|
||||
return;
|
||||
}
|
||||
} // endpoint null is ok for group address
|
||||
|
||||
// everything is good, we can send the command
|
||||
ZigbeeZCLSend(dstAddr, cluster, endpoint, cmd, clusterSpecific, buf.getBuffer(), buf.len(), false, zigbee_devices.getNextSeqNumber(dstAddr));
|
||||
ZigbeeZCLSend_Raw(shortaddr, groupaddr, cluster, endpoint, cmd, clusterSpecific, buf.getBuffer(), buf.len(), true, zigbee_devices.getNextSeqNumber(shortaddr));
|
||||
// now set the timer, if any, to read back the state later
|
||||
if (clusterSpecific) {
|
||||
zigbeeSetCommandTimer(dstAddr, cluster, endpoint);
|
||||
zigbeeSetCommandTimer(shortaddr, groupaddr, cluster, endpoint);
|
||||
}
|
||||
ResponseCmndDone();
|
||||
}
|
||||
|
||||
void CmndZbSend(void) {
|
||||
|
@ -417,20 +432,27 @@ void CmndZbSend(void) {
|
|||
|
||||
// params
|
||||
static char delim[] = ", "; // delimiters for parameters
|
||||
uint16_t device = 0xFFFF; // 0xFFFF is broadcast, so considered valid
|
||||
uint16_t device = 0x0000; // 0xFFFF is broadcast, so considered valid
|
||||
uint16_t groupaddr = 0x0000; // ignore group address if 0x0000
|
||||
uint8_t endpoint = 0x00; // 0x00 is invalid for the dst endpoint
|
||||
// Command elements
|
||||
uint16_t cluster = 0;
|
||||
uint8_t cmd = 0;
|
||||
String cmd_str = ""; // the actual low-level command, either specified or computed
|
||||
const char *cmd_s; // pointer to payload string
|
||||
bool clusterSpecific = true;
|
||||
|
||||
// parse JSON
|
||||
const JsonVariant &val_device = getCaseInsensitive(json, PSTR("Device"));
|
||||
if (nullptr != &val_device) {
|
||||
device = zigbee_devices.parseDeviceParam(val_device.as<char*>());
|
||||
if (0xFFFF == device) { ResponseCmndChar("Invalid parameter"); return; }
|
||||
const JsonVariant &val_group = getCaseInsensitive(json, PSTR("Group"));
|
||||
if (nullptr != &val_group) { groupaddr = strToUInt(val_group); }
|
||||
if (0x0000 == groupaddr) { // if no group address, we need a device address
|
||||
const JsonVariant &val_device = getCaseInsensitive(json, PSTR("Device"));
|
||||
if (nullptr != &val_device) {
|
||||
device = zigbee_devices.parseDeviceParam(val_device.as<char*>());
|
||||
if (0xFFFF == device) { ResponseCmndChar("Invalid parameter"); return; }
|
||||
}
|
||||
if ((nullptr == &val_device) || (0x0000 == device)) { ResponseCmndChar("Unknown device"); return; }
|
||||
}
|
||||
if ((nullptr == &val_device) || (0x000 == device)) { ResponseCmndChar("Unknown device"); return; }
|
||||
|
||||
const JsonVariant &val_endpoint = getCaseInsensitive(json, PSTR("Endpoint"));
|
||||
if (nullptr != &val_endpoint) { endpoint = strToUInt(val_endpoint); }
|
||||
|
@ -500,19 +522,44 @@ void CmndZbSend(void) {
|
|||
}
|
||||
cmd_str = zigbeeCmdAddParams(cmd_str.c_str(), x, y, z); // fill in parameters
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: command_final = %s"), cmd_str.c_str());
|
||||
cmd_s = cmd_str.c_str();
|
||||
} else {
|
||||
// we have zero command, pass through until last error for missing command
|
||||
}
|
||||
} else if (val_cmd.is<char*>()) {
|
||||
// low-level command
|
||||
cmd_str = val_cmd.as<String>();
|
||||
// Now parse the string to extract cluster, command, and payload
|
||||
// Parse 'cmd' in the form "AAAA_BB/CCCCCCCC" or "AAAA!BB/CCCCCCCC"
|
||||
// where AA is the cluster number, BBBB the command number, CCCC... the payload
|
||||
// First delimiter is '_' for a global command, or '!' for a cluster specific command
|
||||
const char * data = cmd_str.c_str();
|
||||
cluster = parseHex(&data, 4);
|
||||
|
||||
// delimiter
|
||||
if (('_' == *data) || ('!' == *data)) {
|
||||
if ('_' == *data) { clusterSpecific = false; }
|
||||
data++;
|
||||
} else {
|
||||
ResponseCmndChar("Wrong delimiter for payload");
|
||||
return;
|
||||
}
|
||||
// parse cmd number
|
||||
cmd = parseHex(&data, 2);
|
||||
|
||||
// move to end of payload
|
||||
// delimiter is optional
|
||||
if ('/' == *data) { data++; } // skip delimiter
|
||||
|
||||
cmd_s = data;
|
||||
} else {
|
||||
// we have an unsupported command type, just ignore it and fallback to missing command
|
||||
}
|
||||
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbCmd_actual: ZigbeeZCLSend {\"device\":\"0x%04X\",\"endpoint\":%d,\"send\":\"%04X!%02X/%s\"}"),
|
||||
device, endpoint, cluster, cmd, cmd_str.c_str());
|
||||
zigbeeZCLSendStr(device, endpoint, true, cluster, cmd, cmd_str.c_str());
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZigbeeZCLSend device: 0x%04X, group: 0x%04X, endpoint:%d, cluster:0x%04X, cmd:0x%02X, send:\"%s\""),
|
||||
device, groupaddr, endpoint, cluster, cmd, cmd_s);
|
||||
zigbeeZCLSendStr(device, groupaddr, endpoint, clusterSpecific, cluster, cmd, cmd_s);
|
||||
ResponseCmndDone();
|
||||
} else {
|
||||
Response_P(PSTR("Missing zigbee 'Send'"));
|
||||
return;
|
||||
|
@ -520,16 +567,6 @@ void CmndZbSend(void) {
|
|||
|
||||
}
|
||||
|
||||
ZBM(ZBS_BIND_REQ, Z_SREQ | Z_ZDO, ZDO_BIND_REQ,
|
||||
0,0, // dstAddr - 16 bits, device to send the bind to
|
||||
0,0,0,0,0,0,0,0, // srcAddr - 64 bits, IEEE binding source
|
||||
0x00, // source endpoint
|
||||
0x00, 0x00, // cluster
|
||||
0x03, // DstAddrMode - 0x03 = ADDRESS_64_BIT
|
||||
0,0,0,0,0,0,0,0, // dstAddr - 64 bits, IEEE binding destination, i.e. coordinator
|
||||
0x01 // dstEndpoint - 0x01 for coordinator
|
||||
)
|
||||
|
||||
void CmndZbBind(void) {
|
||||
// ZbBind { "device":"0x1234", "endpoint":1, "cluster":6 }
|
||||
|
||||
|
@ -595,7 +632,7 @@ void CmndZbBind(void) {
|
|||
if (toGroup && dstLongAddr) { ResponseCmndChar("Cannot have both \"ToDevice\" and \"ToGroup\""); return; }
|
||||
if (!toGroup && !dstLongAddr) { ResponseCmndChar("Missing \"ToDevice\" or \"ToGroup\""); return; }
|
||||
|
||||
SBuffer buf(sizeof(ZBS_BIND_REQ));
|
||||
SBuffer buf(34);
|
||||
buf.add8(Z_SREQ | Z_ZDO);
|
||||
buf.add8(ZDO_BIND_REQ);
|
||||
buf.add16(srcDevice);
|
||||
|
@ -661,8 +698,8 @@ void CmndZbName(void) {
|
|||
if (0xFFFF == shortaddr) { ResponseCmndChar("Invalid parameter"); return; }
|
||||
|
||||
if (p == nullptr) {
|
||||
const String * friendlyName = zigbee_devices.getFriendlyName(shortaddr);
|
||||
Response_P(PSTR("{\"0x%04X\":{\"" D_JSON_ZIGBEE_NAME "\":\"%s\"}}"), shortaddr, friendlyName ? friendlyName->c_str() : "");
|
||||
const char * friendlyName = zigbee_devices.getFriendlyName(shortaddr);
|
||||
Response_P(PSTR("{\"0x%04X\":{\"" D_JSON_ZIGBEE_NAME "\":\"%s\"}}"), shortaddr, friendlyName ? friendlyName : "");
|
||||
} else {
|
||||
zigbee_devices.setFriendlyName(shortaddr, p);
|
||||
Response_P(PSTR("{\"0x%04X\":{\"" D_JSON_ZIGBEE_NAME "\":\"%s\"}}"), shortaddr, p);
|
||||
|
@ -690,14 +727,45 @@ void CmndZbModelId(void) {
|
|||
if (0xFFFF == shortaddr) { ResponseCmndChar("Invalid parameter"); return; }
|
||||
|
||||
if (p == nullptr) {
|
||||
const String * modelId = zigbee_devices.getModelId(shortaddr);
|
||||
Response_P(PSTR("{\"0x%04X\":{\"" D_JSON_ZIGBEE_MODELID "\":\"%s\"}}"), shortaddr, modelId ? modelId->c_str() : "");
|
||||
const char * modelId = zigbee_devices.getModelId(shortaddr);
|
||||
Response_P(PSTR("{\"0x%04X\":{\"" D_JSON_ZIGBEE_MODELID "\":\"%s\"}}"), shortaddr, modelId ? modelId : "");
|
||||
} else {
|
||||
zigbee_devices.setModelId(shortaddr, p);
|
||||
Response_P(PSTR("{\"0x%04X\":{\"" D_JSON_ZIGBEE_MODELID "\":\"%s\"}}"), shortaddr, p);
|
||||
}
|
||||
}
|
||||
|
||||
// Specify, read or erase a Light type for Hue/Alexa integration
|
||||
void CmndZbLight(void) {
|
||||
// Syntax is:
|
||||
// ZbLight <device_id>,<x> - assign a bulb type 0-5
|
||||
// ZbLight <device_id> - display the current bulb type and status
|
||||
//
|
||||
// Where <device_id> can be: short_addr, long_addr, device_index, friendly_name
|
||||
|
||||
if (zigbee.init_phase) { ResponseCmndChar(D_ZIGBEE_NOT_STARTED); return; }
|
||||
|
||||
// check if parameters contain a comma ','
|
||||
char *p;
|
||||
char *str = strtok_r(XdrvMailbox.data, ", ", &p);
|
||||
|
||||
// parse first part, <device_id>
|
||||
uint16_t shortaddr = zigbee_devices.parseDeviceParam(XdrvMailbox.data, true); // in case of short_addr, it must be already registered
|
||||
if (0x0000 == shortaddr) { ResponseCmndChar("Unknown device"); return; }
|
||||
if (0xFFFF == shortaddr) { ResponseCmndChar("Invalid parameter"); return; }
|
||||
|
||||
if (p) {
|
||||
int8_t bulbtype = strtol(p, nullptr, 10);
|
||||
zigbee_devices.setHueBulbtype(shortaddr, bulbtype);
|
||||
}
|
||||
String dump = zigbee_devices.dumpLightState(shortaddr);
|
||||
Response_P(PSTR("{\"" D_PRFX_ZB D_CMND_ZIGBEE_LIGHT "\":%s}"), dump.c_str());
|
||||
|
||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_PRFX_ZB D_CMND_ZIGBEE_LIGHT));
|
||||
XdrvRulesProcess();
|
||||
ResponseCmndDone();
|
||||
}
|
||||
|
||||
// Remove an old Zigbee device from the list of known devices, use ZigbeeStatus to know all registered devices
|
||||
void CmndZbForget(void) {
|
||||
if (zigbee.init_phase) { ResponseCmndChar(D_ZIGBEE_NOT_STARTED); return; }
|
||||
|
@ -734,17 +802,22 @@ void CmndZbRead(void) {
|
|||
|
||||
// params
|
||||
uint16_t device = 0xFFFF; // 0xFFFF is braodcast, so considered valid
|
||||
uint16_t groupaddr = 0x0000; // if 0x0000 ignore group adress
|
||||
uint16_t cluster = 0x0000; // default to general cluster
|
||||
uint8_t endpoint = 0x00; // 0x00 is invalid for the dst endpoint
|
||||
size_t attrs_len = 0;
|
||||
uint8_t* attrs = nullptr; // empty string is valid
|
||||
|
||||
const JsonVariant &val_device = getCaseInsensitive(json, PSTR("Device"));
|
||||
if (nullptr != &val_device) {
|
||||
device = zigbee_devices.parseDeviceParam(val_device.as<char*>());
|
||||
if (0xFFFF == device) { ResponseCmndChar("Invalid parameter"); return; }
|
||||
const JsonVariant &val_group = getCaseInsensitive(json, PSTR("Group"));
|
||||
if (nullptr != &val_group) { groupaddr = strToUInt(val_group); }
|
||||
if (0x0000 == groupaddr) { // if no group address, we need a device address
|
||||
const JsonVariant &val_device = getCaseInsensitive(json, PSTR("Device"));
|
||||
if (nullptr != &val_device) {
|
||||
device = zigbee_devices.parseDeviceParam(val_device.as<char*>());
|
||||
if (0xFFFF == device) { ResponseCmndChar("Invalid parameter"); return; }
|
||||
}
|
||||
if ((nullptr == &val_device) || (0x0000 == device)) { ResponseCmndChar("Unknown device"); return; }
|
||||
}
|
||||
if ((nullptr == &val_device) || (0x000 == device)) { ResponseCmndChar("Unknown device"); return; }
|
||||
|
||||
const JsonVariant &val_cluster = getCaseInsensitive(json, PSTR("Cluster"));
|
||||
if (nullptr != &val_cluster) { cluster = strToUInt(val_cluster); }
|
||||
|
@ -773,13 +846,16 @@ void CmndZbRead(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if (0 == endpoint) { // try to compute the endpoint
|
||||
if ((0 == endpoint) && (device)) { // try to compute the endpoint
|
||||
endpoint = zigbee_devices.findClusterEndpointIn(device, cluster);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ZbSend: guessing endpoint 0x%02X"), endpoint);
|
||||
}
|
||||
if (groupaddr) {
|
||||
endpoint = 0xFF; // endpoint not used for group addresses
|
||||
}
|
||||
|
||||
if ((0 != endpoint) && (attrs_len > 0)) {
|
||||
ZigbeeZCLSend(device, cluster, endpoint, ZCL_READ_ATTRIBUTES, false, attrs, attrs_len, true /* we do want a response */, zigbee_devices.getNextSeqNumber(device));
|
||||
ZigbeeZCLSend_Raw(device, groupaddr, cluster, endpoint, ZCL_READ_ATTRIBUTES, false, attrs, attrs_len, true /* we do want a response */, zigbee_devices.getNextSeqNumber(device));
|
||||
ResponseCmndDone();
|
||||
} else {
|
||||
ResponseCmndChar("Missing parameters");
|
||||
|
@ -789,20 +865,28 @@ void CmndZbRead(void) {
|
|||
}
|
||||
|
||||
// Allow or Deny pairing of new Zigbee devices
|
||||
void CmndZbPermitJoin(void)
|
||||
{
|
||||
void CmndZbPermitJoin(void) {
|
||||
if (zigbee.init_phase) { ResponseCmndChar(D_ZIGBEE_NOT_STARTED); return; }
|
||||
uint32_t payload = XdrvMailbox.payload;
|
||||
if (payload < 0) { payload = 0; }
|
||||
if ((99 != payload) && (payload > 1)) { payload = 1; }
|
||||
uint16_t dstAddr = 0xFFFC; // default addr
|
||||
uint8_t duration = 60; // default 60s
|
||||
|
||||
if (1 == payload) {
|
||||
ZigbeeGotoLabel(ZIGBEE_LABEL_PERMIT_JOIN_OPEN_60);
|
||||
} else if (99 == payload){
|
||||
ZigbeeGotoLabel(ZIGBEE_LABEL_PERMIT_JOIN_OPEN_XX);
|
||||
} else {
|
||||
ZigbeeGotoLabel(ZIGBEE_LABEL_PERMIT_JOIN_CLOSE);
|
||||
if (payload <= 0) {
|
||||
duration = 0;
|
||||
} else if (99 == payload) {
|
||||
duration = 0xFF; // unlimited time
|
||||
}
|
||||
|
||||
SBuffer buf(34);
|
||||
buf.add8(Z_SREQ | Z_ZDO); // 25
|
||||
buf.add8(ZDO_MGMT_PERMIT_JOIN_REQ); // 36
|
||||
buf.add8(0x0F); // AddrMode
|
||||
buf.add16(0xFFFC); // DstAddr
|
||||
buf.add8(duration);
|
||||
buf.add8(0x00); // TCSignificance
|
||||
|
||||
ZigbeeZNPSend(buf.getBuffer(), buf.len());
|
||||
|
||||
ResponseCmndDone();
|
||||
}
|
||||
|
||||
|
|
|
@ -50,70 +50,6 @@
|
|||
// addresses a bug in meter DWS74
|
||||
//#define DWS74_BUG
|
||||
|
||||
// max 23 chars
|
||||
#if MY_LANGUAGE==de-DE
|
||||
// german web text
|
||||
#define D_TPWRIN "Verbrauch"
|
||||
#define D_TPWROUT "Einspeisung"
|
||||
#define D_TPWRCURR "Aktueller Verbrauch"
|
||||
#define D_TPWRCURR1 "Verbrauch P1"
|
||||
#define D_TPWRCURR2 "Verbrauch P2"
|
||||
#define D_TPWRCURR3 "Verbrauch P3"
|
||||
#define D_Strom_L1 "Strom L1"
|
||||
#define D_Strom_L2 "Strom L2"
|
||||
#define D_Strom_L3 "Strom L3"
|
||||
#define D_Spannung_L1 "Spannung L1"
|
||||
#define D_Spannung_L2 "Spannung L2"
|
||||
#define D_Spannung_L3 "Spannung L3"
|
||||
#define D_METERNR "Zähler Nr"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Zählerstand" // Gas-Verbrauch
|
||||
#define D_H2oIN "Zählerstand" // H2o-Verbrauch
|
||||
#define D_StL1L2L3 "Ströme L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Spannung L1+L2+L3/3"
|
||||
|
||||
#else
|
||||
// other languages (tbd)
|
||||
#undef D_TPWRIN
|
||||
#undef D_TPWROUT
|
||||
#undef D_TPWRCURR
|
||||
#undef D_TPWRCURR1
|
||||
#undef D_TPWRCURR2
|
||||
#undef D_TPWRCURR3
|
||||
#undef D_Strom_L1
|
||||
#undef D_Strom_L2
|
||||
#undef D_Strom_L3
|
||||
#undef D_Spannung_L1
|
||||
#undef D_Spannung_L2
|
||||
#undef D_Spannung_L3
|
||||
#undef D_METERNR
|
||||
#undef D_METERSID
|
||||
#undef D_GasIN
|
||||
#undef D_H2oIN
|
||||
#undef D_StL1L2L3
|
||||
#undef D_SpL1L2L3
|
||||
|
||||
#define D_TPWRIN "Total-In"
|
||||
#define D_TPWROUT "Total-Out"
|
||||
#define D_TPWRCURR "Current-In/Out"
|
||||
#define D_TPWRCURR1 "Current-In p1"
|
||||
#define D_TPWRCURR2 "Current-In p2"
|
||||
#define D_TPWRCURR3 "Current-In p3"
|
||||
#define D_Strom_L1 "Current L1"
|
||||
#define D_Strom_L2 "Current L2"
|
||||
#define D_Strom_L3 "Current L3"
|
||||
#define D_Spannung_L1 "Voltage L1"
|
||||
#define D_Spannung_L2 "Voltage L2"
|
||||
#define D_Spannung_L3 "Voltage L3"
|
||||
#define D_METERNR "Meter_number"
|
||||
#define D_METERSID "Service ID"
|
||||
#define D_GasIN "Counter" // Gas-Verbrauch
|
||||
#define D_H2oIN "Counter" // H2o-Verbrauch
|
||||
#define D_StL1L2L3 "Current L1+L2+L3"
|
||||
#define D_SpL1L2L3 "Voltage L1+L2+L3/3"
|
||||
|
||||
#endif
|
||||
|
||||
// JSON Strings do not translate
|
||||
// max 23 char
|
||||
#define DJ_TPWRIN "Total_in"
|
||||
|
|
Loading…
Reference in New Issue