- 积分
- 737
- 金钱
- 641
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
高级会员
- 积分
- 737
- 金钱
- 641
- HASS币
- 0
|
本帖最后由 invincible 于 2024-6-19 11:42 编辑
今天到手了一个四键旋钮,接入米家并且能够获取旋转角度。
参照@relliky大佬的帖子https://bbs.hassbian.com/thread-25298-1-1.html折腾了一晚上,实在是心有余力不足,特来请教各位大佬。
https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:remote-control:0000A021:lemesh-ts10:1
https://home.miot-spec.com/spec?type=urn:miot-spec-v2:device:remote-control:0000A021:lemesh-ts10:1
目前xiaomi_gateway3.py的内容如下:
from custom_components.xiaomi_gateway3.core.devices import *
DEVICES = [{
17658: ["LeMesh", "Scenario knob remote control Alpha", "lemesh.remote.ts10"],
"spec": [
BaseConv("battery", mi="4.p.1003"), # uint8
BaseConv("action", "sensor"),
MapConv("action", mi="5.e.1012.p.1", map={1: "button_up_single", 2: "button_right_single", 3: "button_down_single", 4: "button_left_single", 5: "right_rotation", 6: "left_rotation", 11: "press_up_right_rotation", 12: "press_up_left_rotation", 13: "press_right_right_rotation", 14: "press_right_left_rotation", 7: "press_down_right_rotation", 8: "press_down_left_rotation", 9: "press_left_right_rotation", 10: "press_left_left_rotation"}),
MapConv("action", mi="5.e.1013.p.1", map={1: "button_up_double", 2: "button_right_double", 3: "button_down_double", 4: "button_left_double"}),
MapConv("action", mi="5.e.1014.p.1", map={1: "button_up_hold", 2: "button_right_hold", 3: "button_down_hold", 4: "button_left_hold"}),
ConstConv("action", mi="5.e.1036", value="rotate"),
BaseConv("rotate", mi="5.e.1036.p.2"),
],
}] + DEVICES
xiaomi_gateway3插件log示例如下:
#这是上键单击
2024-06-17 14:18:29.820 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.192.168.2.133] {'topic': 'miio/report', 'data': b'{"id":1771553510,"method":"_async.ble_event","params":{"dev":{"did":"blt.3.1i12kt5104k03","mac":"78:DA:07:F2:BC:2D","pdid":17658},"evt":[{"eid":22028,"edata":"01"}],"frmCnt":6,"gwts":1718633908}}'}
#这是上键双击
2024-06-17 14:18:32.370 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.192.168.2.133] {'topic': 'miio/report', 'data': b'{"id":551606511,"method":"_async.ble_event","params":{"dev":{"did":"blt.3.1i12kt5104k03","mac":"78:DA:07:F2:BC:2D","pdid":17658},"evt":[{"eid":22029,"edata":"01"}],"frmCnt":7,"gwts":1718633910}}'}
#这是上键长按
2024-06-17 14:18:35.940 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.192.168.2.133] {'topic': 'miio/report', 'data': b'{"id":2090572513,"method":"_async.ble_event","params":{"dev":{"did":"blt.3.1i12kt5104k03","mac":"78:DA:07:F2:BC:2D","pdid":17658},"evt":[{"eid":22030,"edata":"01"}],"frmCnt":8,"gwts":1718633914}}'}
#这是右旋,两条。eid:22028与单击一样,edata:05。eid:22052是旋转,edata:19是旋转角度(十六进制)
2024-06-17 14:18:40.020 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.192.168.2.133] {'topic': 'miio/report', 'data': b'{"id":1927828514,"method":"_async.ble_event","params":{"dev":{"did":"blt.3.1i12kt5104k03","mac":"78:DA:07:F2:BC:2D","pdid":17658},"evt":[{"eid":22028,"edata":"05"}],"frmCnt":9,"gwts":1718633918}}'}
2024-06-17 14:18:41.550 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.192.168.2.133] {'topic': 'miio/report', 'data': b'{"id":884777515,"method":"_async.ble_event","params":{"dev":{"did":"blt.3.1i12kt5104k03","mac":"78:DA:07:F2:BC:2D","pdid":17658},"evt":[{"eid":22052,"edata":"19"}],"frmCnt":10,"gwts":1718633920}}'}
#这是按住上键右旋,也是两条。
2024-06-17 14:18:46.650 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.192.168.2.133] {'topic': 'miio/report', 'data': b'{"id":2102658517,"method":"_async.ble_event","params":{"dev":{"did":"blt.3.1i12kt5104k03","mac":"78:DA:07:F2:BC:2D","pdid":17658},"evt":[{"eid":22028,"edata":"0b"}],"frmCnt":11,"gwts":1718633925}}'}
2024-06-17 14:18:48.180 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.192.168.2.133] {'topic': 'miio/report', 'data': b'{"id":540644518,"method":"_async.ble_event","params":{"dev":{"did":"blt.3.1i12kt5104k03","mac":"78:DA:07:F2:BC:2D","pdid":17658},"evt":[{"eid":22052,"edata":"1e"}],"frmCnt":12,"gwts":1718633926}}'}
然后现在action无数据,旋转和电量都是不可用。
|
|