{
# https://github.com/AlexxIT/XiaomiGateway3/pull/1303
17825: ["Unknown", "Eight scene knob switch", "cxw.remote.ble006"],
"spec": [
# mibeacon2 spec
BLEByteConv("battery", "sensor", mi=23555), # uint8
BaseConv("action", "sensor"), # uint8
MapConv("action", mi=22028, map={"01": BUTTON_1_SINGLE, "02": BUTTON_2_SINGLE, "03": BUTTON_3_SINGLE, "04": BUTTON_4_SINGLE, "05": "button_5_single", "06": "button_6_single", "07": "button_7_single", "08": "button_8_single"}),
MapConv("action", mi=22029, map={"01": BUTTON_1_DOUBLE, "02": BUTTON_2_DOUBLE, "03": BUTTON_3_DOUBLE, "04": BUTTON_4_DOUBLE, "05": "button_5_double", "06": "button_6_double", "07": "button_7_double", "08": "button_8_double"}),
MapConv("action", mi=22030, map={"01": BUTTON_1_HOLD, "02": BUTTON_2_HOLD, "03": BUTTON_3_HOLD, "04": BUTTON_4_HOLD, "05": "button_5_hold", "06": "button_6_hold", "07": "button_7_hold", "08": "button_8_hold"}),
BLENegativeConv("rotate", "sensor", mi=22052),
MapConv("action", mi=22052, map={"-0b": "knob_anticlockwise_after_toggling_button_1",
"-0c": "knob_anticlockwise_after_toggling_button_2",
"-0d": "knob_anticlockwise_after_toggling_button_3",
"-0e": "knob_anticlockwise_after_toggling_button_4",
"-0f": "knob_anticlockwise_after_toggling_button_5",
"-10": "knob_anticlockwise_after_toggling_button_6",
"-11": "knob_anticlockwise_after_toggling_button_7",
"-12": "knob_anticlockwise_after_toggling_button_8",
"0b": "knob_clockwise_after_toggling_button_1",
"0c": "knob_clockwise_after_toggling_button_2",
"0d": "knob_clockwise_after_toggling_button_3",
"0e": "knob_clockwise_after_toggling_button_4",
"0f": "knob_clockwise_after_toggling_button_5",
"10": "knob_clockwise_after_toggling_button_6",
"11": "knob_clockwise_after_toggling_button_7",
"12": "knob_clockwise_after_toggling_button_8",
"-16": "knob_anticlockwise_after_toggling_button_1_and_knob",
"-17": "knob_anticlockwise_after_toggling_button_2_and_knob",
"-18": "knob_anticlockwise_after_toggling_button_3_and_knob",
"-19": "knob_anticlockwise_after_toggling_button_4_and_knob",
"-20": "knob_anticlockwise_after_toggling_button_5_and_knob",
"-21": "knob_anticlockwise_after_toggling_button_6_and_knob",
"-22": "knob_anticlockwise_after_toggling_button_7_and_knob",
"-23": "knob_anticlockwise_after_toggling_button_8_and_knob",
"16": "knob_clockwise_after_toggling_button_1_and_knob",
"17": "knob_clockwise_after_toggling_button_2_and_knob",
"18": "knob_clockwise_after_toggling_button_3_and_knob",
"19": "knob_clockwise_after_toggling_button_4_and_knob",
"20": "knob_clockwise_after_toggling_button_5_and_knob",
"21": "knob_clockwise_after_toggling_button_6_and_knob",
"22": "knob_clockwise_after_toggling_button_7_and_knob",
"23": "knob_clockwise_after_toggling_button_8_and_knob",}),
# The knob in this device can be tuned clockwise and anti-clockwise. It can also be pressed.
# The device does not report how much the knob is turned and only report one knob event per second.
# However, the device remembers the previous state and report the previous state along with the knob event.
# Such complex events are designed to map different clockwise/anti-clockwise knob events to each button, so users do not need to create dedicated state machine to track it.
# e.g. a usecase is that button 1 controls the ceiling light and knob for its brightness. Button 2 controls lamps and knob for their brightness.
# When the knob is pressed, the knob events controls the temperature of these lights instead.
# The toggling knob state will get reset after you press a different button
# e.g. 1) press button_1 and turn knob -> knob_anti_clockwise_after_pressing_button_1
# 2) press the knob and turn knob -> knob_anti_clockwise_after_toggling_knob_and_pressing_button_1
# 3) press button_2 and turn knob -> knob_anti_clockwise_after_pressing_button_2
# Therefore, if you only uses clockwise and anti-clockwise events on its own, you need to merge these events into two triggers in your automation.
],
# "ttl": "6h" # battery every 6 hours
},
2. mibeacon.py 加入 BLENegativeConv,加上了处理负数
class BLENegativeConv(BaseConv):
def decode(self, device: "XDevice", payload: dict, data: str):
value = int(data[:2], 16)
if value > 0x7F: # 处理int8的16进制负数
value = -(0xFF - value + 1)
payload[self.attr] = value
class BLENegativeConv(BaseConv):
def decode(self, device: "XDevice", payload: dict, data: str):
value = int(data[:2], 16)
if value > 0x7F: # 处理int8的16进制负数
value = -(0xFF - value + 1)
payload[self.attr] = value
{
# https://github.com/AlexxIT/XiaomiGateway3/pull/1303
17825: ["Unknown", "Eight scene knob switch", "cxw.remote.ble006"],
"spec": [
# mibeacon2 spec
BLEByteConv("battery", "sensor", mi=23555), # uint8
BaseConv("action", "sensor"), # uint8
MapConv("action", mi=22028, map={"01": BUTTON_1_SINGLE, "02": BUTTON_2_SINGLE, "03": BUTTON_3_SINGLE, "04": BUTTON_4_SINGLE, "05": "button_5_single", "06": "button_6_single", "07": "button_7_single", "08": "button_8_single"}),
MapConv("action", mi=22029, map={"01": BUTTON_1_DOUBLE, "02": BUTTON_2_DOUBLE, "03": BUTTON_3_DOUBLE, "04": BUTTON_4_DOUBLE, "05": "button_5_double", "06": "button_6_double", "07": "button_7_double", "08": "button_8_double"}),
MapConv("action", mi=22030, map={"01": BUTTON_1_HOLD, "02": BUTTON_2_HOLD, "03": BUTTON_3_HOLD, "04": BUTTON_4_HOLD, "05": "button_5_hold", "06": "button_6_hold", "07": "button_7_hold", "08": "button_8_hold"}),
BLENegativeConv("rotate", "sensor", mi=22052),
MapConv("action", mi=22052, map={"f5": "knob_anticlockwise_after_toggling_button_1",
"f4": "knob_anticlockwise_after_toggling_button_2",
"f3": "knob_anticlockwise_after_toggling_button_3",
"f2": "knob_anticlockwise_after_toggling_button_4",
"f1": "knob_anticlockwise_after_toggling_button_5",
"f0": "knob_anticlockwise_after_toggling_button_6",
"ef": "knob_anticlockwise_after_toggling_button_7",
"ee": "knob_anticlockwise_after_toggling_button_8",
"0b": "knob_clockwise_after_toggling_button_1",
"0c": "knob_clockwise_after_toggling_button_2",
"0d": "knob_clockwise_after_toggling_button_3",
"0e": "knob_clockwise_after_toggling_button_4",
"0f": "knob_clockwise_after_toggling_button_5",
"10": "knob_clockwise_after_toggling_button_6",
"11": "knob_clockwise_after_toggling_button_7",
"12": "knob_clockwise_after_toggling_button_8",
"eb": "knob_anticlockwise_after_toggling_button_1_and_knob",
"ea": "knob_anticlockwise_after_toggling_button_2_and_knob",
"e9": "knob_anticlockwise_after_toggling_button_3_and_knob",
"e8": "knob_anticlockwise_after_toggling_button_4_and_knob",
"e7": "knob_anticlockwise_after_toggling_button_5_and_knob",
"e6": "knob_anticlockwise_after_toggling_button_6_and_knob",
"e5": "knob_anticlockwise_after_toggling_button_7_and_knob",
"e4": "knob_anticlockwise_after_toggling_button_8_and_knob",
"16": "knob_clockwise_after_toggling_button_1_and_knob",
"17": "knob_clockwise_after_toggling_button_2_and_knob",
"18": "knob_clockwise_after_toggling_button_3_and_knob",
"19": "knob_clockwise_after_toggling_button_4_and_knob",
"20": "knob_clockwise_after_toggling_button_5_and_knob",
"21": "knob_clockwise_after_toggling_button_6_and_knob",
"22": "knob_clockwise_after_toggling_button_7_and_knob",
"23": "knob_clockwise_after_toggling_button_8_and_knob",}),
# The knob in this device can be tuned clockwise and anti-clockwise. It can also be pressed.
# The device does not report how much the knob is turned and only report one knob event per second.
# However, the device remembers the previous state and report the previous state along with the knob event.
# Such complex events are designed to map different clockwise/anti-clockwise knob events to each button, so users do not need to create dedicated state machine to track it.
# e.g. a usecase is that button 1 controls the ceiling light and knob for its brightness. Button 2 controls lamps and knob for their brightness.
# When the knob is pressed, the knob events controls the temperature of these lights instead.
# The toggling knob state will get reset after you press a different button
# e.g. 1) press button_1 and turn knob -> knob_anti_clockwise_after_pressing_button_1
# 2) press the knob and turn knob -> knob_anti_clockwise_after_toggling_knob_and_pressing_button_1
# 3) press button_2 and turn knob -> knob_anti_clockwise_after_pressing_button_2
# Therefore, if you only uses clockwise and anti-clockwise events on its own, you need to merge these events into two triggers in your automation.
],
# "ttl": "6h" # battery every 6 hours
},