mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
Send MQTT message when weight/impedance is stabilized or direct bridge mode is enabled.
Fixed impedance measurement on V2 scale.
This commit is contained in:
parent
a0ba50d38d
commit
d13381f130
@ -1745,19 +1745,17 @@ void MI32ParseMiScalePacket(const uint8_t * _buf, uint32_t length, const uint8_t
|
||||
MIBLEsensors[_slot].weight = 0.0f;
|
||||
}
|
||||
|
||||
if(MI32.option.directBridgeMode) {
|
||||
MIBLEsensors[_slot].shallSendMQTT = 1;
|
||||
MI32.mode.shallTriggerTele = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mi Scale V2
|
||||
else if (length == 13 && UUID == 0x181b) { // 17-1-1-2
|
||||
weight_stabilized = (_packetV2->status & (1 << 5)) ? 1 : 0;
|
||||
weight_removed = (_packetV2->status & (1 << 7)) ? 1 : 0;
|
||||
impedance_stabilized = (_packetV2->status & (1 << 1)) ? 1 : 0;
|
||||
if (!MI32.option.directBridgeMode && (!weight_stabilized || weight_removed /* || !impedance_stabilized */))
|
||||
if (!MI32.option.directBridgeMode && (!weight_stabilized || weight_removed))
|
||||
return;
|
||||
|
||||
uint32_t _slot = MIBLEgetSensorSlot(addr, UUID, 0);
|
||||
@ -1771,8 +1769,6 @@ void MI32ParseMiScalePacket(const uint8_t * _buf, uint32_t length, const uint8_t
|
||||
|
||||
MIBLEsensors[_slot].weight_stabilized = weight_stabilized;
|
||||
MIBLEsensors[_slot].weight_removed = weight_removed;
|
||||
MIBLEsensors[_slot].impedance_stabilized = impedance_stabilized;
|
||||
MIBLEsensors[_slot].impedance = _packetV2->impedance;
|
||||
|
||||
if (_packetV2->weight_unit & (1 << 4)) {
|
||||
strcpy(MIBLEsensors[_slot].weight_unit, PSTR("jin"));
|
||||
@ -1788,17 +1784,25 @@ void MI32ParseMiScalePacket(const uint8_t * _buf, uint32_t length, const uint8_t
|
||||
MIBLEsensors[_slot].weight = (float)_packetV2->weight / 100.0f;
|
||||
}
|
||||
|
||||
if (MIBLEsensors[_slot].weight_removed) {
|
||||
if (weight_removed) {
|
||||
MIBLEsensors[_slot].weight = 0.0f;
|
||||
MIBLEsensors[_slot].impedance = 0;
|
||||
}
|
||||
|
||||
if(MI32.option.directBridgeMode) {
|
||||
MIBLEsensors[_slot].impedance = 0;
|
||||
if (MI32.option.directBridgeMode || impedance_stabilized)
|
||||
{
|
||||
MIBLEsensors[_slot].impedance_stabilized = impedance_stabilized;
|
||||
MIBLEsensors[_slot].impedance = _packetV2->impedance;
|
||||
|
||||
if (weight_removed) {
|
||||
MIBLEsensors[_slot].impedance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
MIBLEsensors[_slot].shallSendMQTT = 1;
|
||||
MI32.mode.shallTriggerTele = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user