mirror of https://github.com/arendst/Tasmota.git
Zigebee add persisence for Alarm config
This commit is contained in:
parent
2987540e21
commit
182aabe34d
|
@ -74,6 +74,9 @@ public:
|
|||
|
||||
void toAttributes(Z_attribute_list & attr_list, Z_Data_Type type) const;
|
||||
|
||||
// update internal structures after an attribut update
|
||||
inline void update(void) { }
|
||||
|
||||
static const Z_Data_Type type = Z_Data_Type::Z_Unknown;
|
||||
static bool ConfigToZData(const char * config_str, Z_Data_Type * type, uint8_t * ep, uint8_t * config);
|
||||
|
||||
|
@ -364,11 +367,28 @@ public:
|
|||
inline bool validZoneType(void) const { return 0xFFFF != zone_type; }
|
||||
|
||||
inline uint16_t getZoneType(void) const { return zone_type; }
|
||||
inline bool isPIR(void) const { return 0x000d == zone_type; }
|
||||
inline bool isContact(void) const { return 0x0015 == zone_type; }
|
||||
inline bool isPIR(void) const { return 0x1 == _config; }
|
||||
inline bool isContact(void) const { return 0x2 == _config; }
|
||||
|
||||
inline void setZoneType(uint16_t _zone_type) { zone_type = _zone_type; }
|
||||
|
||||
void update(void) {
|
||||
switch (zone_type) {
|
||||
case 0x0000: _config = 0x0; break; // 0x0 : Standard CIE
|
||||
case 0x000d: _config = 0x1; break; // 0x1 : PIR
|
||||
case 0x0015: _config = 0x2; break; // 0x2 : Contact
|
||||
case 0x0028: _config = 0x3; break; // 0x3 : Fire
|
||||
case 0x002a: _config = 0x4; break; // 0x4 : Leak
|
||||
case 0x002b: _config = 0x5; break; // 0x5 : CO
|
||||
case 0x002c: _config = 0x6; break; // 0x6 : Personal
|
||||
case 0x002d: _config = 0x7; break; // 0x7 : Movement
|
||||
case 0x010f:
|
||||
case 0x0115:
|
||||
case 0x021d: _config = 0x8; break; // 0x8 : Panic
|
||||
case 0x0226: _config = 0x9; break; // 0x9 : Glass break
|
||||
}
|
||||
}
|
||||
|
||||
// 4 bytes
|
||||
uint16_t zone_status; // last known state for sensor 1 & 2
|
||||
uint16_t zone_type; // mapped to the Zigbee standard
|
||||
|
@ -401,6 +421,8 @@ public:
|
|||
// getX() always returns a valid object, and creates the object if there is none
|
||||
// find() does not create an object if it does not exist, and returns *(X*)nullptr
|
||||
|
||||
// Emulate a virtuel update method for Z_Data
|
||||
static void updateData(Z_Data & elt);
|
||||
|
||||
template <class M>
|
||||
M & get(uint8_t ep = 0);
|
||||
|
@ -413,6 +435,17 @@ public:
|
|||
M & addIfNull(M & cur, uint8_t ep = 0);
|
||||
};
|
||||
|
||||
void Z_Data_Set::updateData(Z_Data & elt) {
|
||||
switch (elt._type) {
|
||||
case Z_Data_Type::Z_Light: ((Z_Data_Light&) elt).update(); break;
|
||||
case Z_Data_Type::Z_Plug: ((Z_Data_Plug&) elt).update(); break;
|
||||
case Z_Data_Type::Z_Alarm: ((Z_Data_Alarm&) elt).update(); break;
|
||||
case Z_Data_Type::Z_Thermo: ((Z_Data_Thermo&) elt).update(); break;
|
||||
case Z_Data_Type::Z_OnOff: ((Z_Data_OnOff&) elt).update(); break;
|
||||
case Z_Data_Type::Z_PIR: ((Z_Data_PIR&) elt).update(); break;
|
||||
}
|
||||
}
|
||||
|
||||
Z_Data & Z_Data_Set::getByType(Z_Data_Type type, uint8_t ep) {
|
||||
switch (type) {
|
||||
case Z_Data_Type::Z_Light:
|
||||
|
|
|
@ -276,6 +276,7 @@ void hydrateSingleDevice(const SBuffer & buf_d, uint32_t version) {
|
|||
Z_Data & z_data = device.data.getByType(type, ep);
|
||||
if (&z_data != nullptr) {
|
||||
z_data.setConfig(config);
|
||||
Z_Data_Set::updateData(z_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1851,6 +1851,7 @@ void Z_postProcessAttributes(uint16_t shortaddr, uint16_t src_ep, class Z_attrib
|
|||
case Zint16: *(int16_t*)attr_address = ival32; break;
|
||||
case Zint32: *(int32_t*)attr_address = ival32; break;
|
||||
}
|
||||
Z_Data_Set::updateData(data);
|
||||
}
|
||||
|
||||
uint16_t uval16 = attr.getUInt(); // call converter to uint only once
|
||||
|
|
Loading…
Reference in New Issue