mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Removed the x2 to battery percentage
This commit is contained in:
parent
4af6b7d540
commit
ac80807c4e
@ -72,7 +72,7 @@ typedef struct Z_Device {
|
|||||||
uint16_t hue; // last Hue: 0..359
|
uint16_t hue; // last Hue: 0..359
|
||||||
uint16_t x, y; // last color [x,y]
|
uint16_t x, y; // last color [x,y]
|
||||||
uint8_t linkquality; // lqi from last message, 0xFF means unknown
|
uint8_t linkquality; // lqi from last message, 0xFF means unknown
|
||||||
uint8_t batterypercentx2;// battery percentage x 2 (0..200), 0xFF means unknwon
|
uint8_t batterypercent; // battery percentage (0..100), 0xFF means unknwon
|
||||||
} Z_Device;
|
} Z_Device;
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
@ -151,8 +151,8 @@ public:
|
|||||||
void setReachable(uint16_t shortaddr, bool reachable);
|
void setReachable(uint16_t shortaddr, bool reachable);
|
||||||
void setLQI(uint16_t shortaddr, uint8_t lqi);
|
void setLQI(uint16_t shortaddr, uint8_t lqi);
|
||||||
uint8_t getLQI(uint16_t shortaddr) const;
|
uint8_t getLQI(uint16_t shortaddr) const;
|
||||||
void setBatteryPercentx2(uint16_t shortaddr, uint8_t bpx2);
|
void setBatteryPercent(uint16_t shortaddr, uint8_t bp);
|
||||||
uint8_t getBatteryPercentx2(uint16_t shortaddr) const;
|
uint8_t getBatteryPercent(uint16_t shortaddr) const;
|
||||||
|
|
||||||
// get next sequence number for (increment at each all)
|
// get next sequence number for (increment at each all)
|
||||||
uint8_t getNextSeqNumber(uint16_t shortaddr);
|
uint8_t getNextSeqNumber(uint16_t shortaddr);
|
||||||
@ -642,17 +642,17 @@ uint8_t Z_Devices::getLQI(uint16_t shortaddr) const {
|
|||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Z_Devices::setBatteryPercentx2(uint16_t shortaddr, uint8_t bpx2) {
|
void Z_Devices::setBatteryPercent(uint16_t shortaddr, uint8_t bp) {
|
||||||
Z_Device & device = getShortAddr(shortaddr);
|
Z_Device & device = getShortAddr(shortaddr);
|
||||||
if (&device == nullptr) { return; } // don't crash if not found
|
if (&device == nullptr) { return; } // don't crash if not found
|
||||||
device.batterypercentx2 = bpx2;
|
device.batterypercent = bp;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Z_Devices::getBatteryPercentx2(uint16_t shortaddr) const {
|
uint8_t Z_Devices::getBatteryPercent(uint16_t shortaddr) const {
|
||||||
int32_t found = findShortAddr(shortaddr);
|
int32_t found = findShortAddr(shortaddr);
|
||||||
if (found >= 0) {
|
if (found >= 0) {
|
||||||
const Z_Device & device = devicesAt(found);
|
const Z_Device & device = devicesAt(found);
|
||||||
return device.batterypercentx2;
|
return device.batterypercent;
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
@ -1187,7 +1187,7 @@ int32_t Z_ModelKeepFunc(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObjec
|
|||||||
}
|
}
|
||||||
// Record BatteryPercentage
|
// Record BatteryPercentage
|
||||||
int32_t Z_BatteryPercentageKeepFunc(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObject& json, const char *name, JsonVariant& value, const String &new_name, uint16_t cluster, uint16_t attr) {
|
int32_t Z_BatteryPercentageKeepFunc(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObject& json, const char *name, JsonVariant& value, const String &new_name, uint16_t cluster, uint16_t attr) {
|
||||||
zigbee_devices.setBatteryPercentx2(shortaddr, value.as<uint8_t>());
|
zigbee_devices.setBatteryPercent(shortaddr, json[new_name]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1343,7 +1343,7 @@ int32_t Z_AqaraSensorFunc(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObj
|
|||||||
json[F("BatteryVoltage")] = batteryvoltage;
|
json[F("BatteryVoltage")] = batteryvoltage;
|
||||||
uint8_t batterypercentage = toPercentageCR2032(val);
|
uint8_t batterypercentage = toPercentageCR2032(val);
|
||||||
json[F("BatteryPercentage")] = batterypercentage;
|
json[F("BatteryPercentage")] = batterypercentage;
|
||||||
zigbee_devices.setBatteryPercentx2(shortaddr, batterypercentage * 2);
|
zigbee_devices.setBatteryPercent(shortaddr, batterypercentage);
|
||||||
// deprecated
|
// deprecated
|
||||||
json[F(D_JSON_VOLTAGE)] = batteryvoltage;
|
json[F(D_JSON_VOLTAGE)] = batteryvoltage;
|
||||||
json[F("Battery")] = toPercentageCR2032(val);
|
json[F("Battery")] = toPercentageCR2032(val);
|
||||||
|
@ -1094,6 +1094,11 @@ void ZigbeeShow(bool json)
|
|||||||
if (0xFF != lqi) {
|
if (0xFF != lqi) {
|
||||||
snprintf_P(spart2, sizeof(spart2), PSTR("%d"), lqi);
|
snprintf_P(spart2, sizeof(spart2), PSTR("%d"), lqi);
|
||||||
}
|
}
|
||||||
|
// uint8_t bp = zigbee_devices.getBatteryPercentx2(shortaddr);
|
||||||
|
// Be aware that bp
|
||||||
|
// if (0xFF != bp) {
|
||||||
|
// snprintf_P(spart2, sizeof(spart2), PSTR("%d"), bp);
|
||||||
|
// }
|
||||||
|
|
||||||
WSContentSend_PD(PSTR("{s}%s{m}LQI %s{e}"), name, spart2);
|
WSContentSend_PD(PSTR("{s}%s{m}LQI %s{e}"), name, spart2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user