Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support 090615.switch.akpro4 #1547

Open
hzonz opened this issue Jan 20, 2025 · 16 comments
Open

Add support 090615.switch.akpro4 #1547

hzonz opened this issue Jan 20, 2025 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@hzonz
Copy link

hzonz commented Jan 20, 2025

from custom_components.xiaomi_gateway3.core.devices import *

DEVICES = [{
    21145: ["PTX", "PTX Wall Switch", "AK4 Pro Mesh2.0", "090615.switch.akpro4"],
    "spec": [
        # 开关控制
        BaseConv("Channel_1", "switch", mi="2.p.1"),
        BaseConv("Channel_2", "switch", mi="3.p.1"),
        BaseConv("Channel_3", "switch", mi="4.p.1"),
        BaseConv("Channel_4", "switch", mi="5.p.1"),
        # 按键模式
        MapConv("Channel_1_Mode", "select", mi="2.p.2", map={0: "Wired And Wireless", 1: "Wireless"}, entity=ENTITY_CONFIG),
        MapConv("Channel_2_Mode", "select", mi="3.p.2", map={0: "Wired And Wireless", 1: "Wireless"}, entity=ENTITY_CONFIG),
        MapConv("Channel_3_Mode", "select", mi="4.p.2", map={0: "Wired And Wireless", 1: "Wireless"}, entity=ENTITY_CONFIG),
        MapConv("Channel_4_Mode", "select", mi="5.p.2", map={0: "Wired And Wireless", 1: "Wireless"}, entity=ENTITY_CONFIG),
        # LED
        BaseConv("indicator_light", "switch", mi="11.p.1", entity=ENTITY_CONFIG),
        # 开关扩展 电动模式
        MapConv("Channel_1_diandong", "select", mi="12.p.1", map={0: "None", 1: "Wireless", 2: "Diandong", 3: "Localscene", 5: "Smarcurtain"}, entity=ENTITY_CONFIG),
        MapConv("Channel_2_diandong", "select", mi="13.p.1", map={0: "None", 1: "Wireless", 2: "Diandong", 3: "Localscene", 5: "Smarcurtain"}, entity=ENTITY_CONFIG),
        MapConv("Channel_3_diandong", "select", mi="14.p.1", map={0: "None", 1: "Wireless", 2: "Diandong", 3: "Localscene", 5: "Smarcurtain"}, entity=ENTITY_CONFIG),
        MapConv("Channel_4_diandong", "select", mi="15.p.1", map={0: "None", 1: "Wireless", 2: "Diandong", 3: "Localscene", 5: "Smarcurtain"}, entity=ENTITY_CONFIG),
        # 开关扩展 继电器状态
        BaseConv("jdq_status_1", "switch", mi="12.p.11"),
        BaseConv("jdq_status_2", "switch", mi="13.p.11"),
        BaseConv("jdq_status_3", "switch", mi="14.p.11"),
        BaseConv("jdq_status_4", "switch", mi="15.p.11"),        
        # 电源恢复状态
        MapConv("power_on_status", "select", mi="2.p.5", map={0: "off", 1: "on", 2: "Default"}, entity=ENTITY_CONFIG),
        # 场景操作模式
        MapConv("key_mode", "select", mi="16.p.1", map={0: "Standard Mode", 1: "High Speed Mode"}, entity=ENTITY_CONFIG),
        # 事件
        BaseConv("action", "sensor"),
        MapConv("action", mi="6.e.1.p.1", map={1: BUTTON_1_SINGLE, 2: BUTTON_2_SINGLE, 3: BUTTON_3_SINGLE, 4: BUTTON_4_SINGLE}),
        MapConv("action", mi="6.e.2.p.1", map={1: BUTTON_1_HOLD, 2: BUTTON_2_HOLD, 3: BUTTON_3_HOLD, 4: BUTTON_4_HOLD}),
        MapConv("action", mi="6.e.3.p.1", map={1: BUTTON_1_DOUBLE, 2: BUTTON_2_DOUBLE, 3: BUTTON_3_DOUBLE, 4: BUTTON_4_DOUBLE}),
    ],
}] + DEVICES
@hzonz
Copy link
Author

hzonz commented Jan 20, 2025

I am unable to use 'action' as an automation trigger, and I am not sure where the issue lies.

@AlexxIT AlexxIT added the enhancement New feature or request label Jan 20, 2025
@AlexxIT AlexxIT self-assigned this Jan 20, 2025
@AlexxIT
Copy link
Owner

AlexxIT commented Jan 20, 2025

@hzonz
Copy link
Author

hzonz commented Jan 21, 2025

https://github.com/AlexxIT/XiaomiGateway3/wiki/Handle-BLE-Locks

The lumi.remote.b286opcn01 can use action as a trigger condition, with multiple options such as button_1_single, button_2_single, and more available for selection.

device_id: f7096c292be14f4ca2c85edd89eadbd9
domain: xiaomi_gateway3
type: action
metadata: {}
trigger: device
state: button_1_single

I want to implement this method as a trigger condition.

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 21, 2025

I don't understand your question. Above is all the information you need to use the automation.

@hzonz
Copy link
Author

hzonz commented Jan 21, 2025

I don't understand your question. Above is all the information you need to use the automation.

The 090615.switch.akpro4 cannot use action as a trigger condition like the lumi.remote.b286opcn01.

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 21, 2025

You needs to collect debug logs for this device.

@hzonz
Copy link
Author

hzonz commented Jan 21, 2025

You needs to collect debug logs for this device.

Debug Log:

{'topic': 'miio/report', 'data': b'{"id":1325804123,"method":"event_occured","params":{"did":"792983587","siid":6,"eiid":3,"tid":213,"ts":1737368102,"arguments":[{"piid":1,"value":1}]},"type":16}'}
{'uid': '844693525d5c', 'did': '792983587', 'msg': 'on_report', 'data': {'action': 'double_click'}}
{'topic': 'miio/report', 'data': b'{"id":1602614126,"method":"event_occured","params":{"did":"792983587","siid":6,"eiid":1,"tid":214,"ts":1737368103,"arguments":[{"piid":1,"value":2}]},"type":16}'}
{'uid': '844693525d5c', 'did': '792983587', 'msg': 'on_report', 'data': {'action': 'click'}}
{'topic': 'central/report', 'data': b'{"id":1686498241,"_to":128,"type":16,"method":"event_occured","params":{"did":"792983587","siid":6,"eiid":3,"tid":217,"ts":1737368105,"arguments":[{"piid":1,"value":2}]}}'}
{'uid': '844693525d5c', 'did': '792983587', 'msg': 'on_report', 'data': {'action': 'double_click'}}
{'topic': 'central/report', 'data': b'{"id":1004155245,"_to":128,"type":16,"method":"event_occured","params":{"did":"792983587","siid":6,"eiid":1,"tid":218,"ts":1737368106,"arguments":[{"piid":1,"value":1}]}}'}
{'uid': '844693525d5c', 'did': '792983587', 'msg': 'on_report', 'data': {'action': 'click'}}

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 25, 2025

Please show info (from notification) for your device 090615.switch.akpro4.

@hzonz
Copy link
Author

hzonz commented Jan 26, 2025

Please show info (from notification) for your device .090615.switch.akpro4

Debug log:

2025-01-26 18:56:14.646 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report', 'data': b'{"id":699581165,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":93,"ts":1737888974,"arguments":[{"piid":1,"value":1}]},"type":16}'}
2025-01-26 18:56:14.646 DEBUG (MainThread) [custom_components.xiaomi_gateway3.gate.10.10.11.20] {'uid': '8446935148c7', 'did': '792912782', 'msg': 'on_report', 'data': {'action': 'button_1_single'}}
2025-01-26 18:56:20.389 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'central/report', 'data': b'{"id":979406028,"_to":128,"type":16,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":95,"ts":1737888980,"arguments":[{"piid":1,"value":1}]}}'}
2025-01-26 18:56:20.389 DEBUG (MainThread) [custom_components.xiaomi_gateway3.gate.10.10.11.20] {'uid': '8446935148c7', 'did': '792912782', 'msg': 'on_report', 'data': {'action': 'button_1_single'}}
2025-01-26 18:56:20.391 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report', 'data': b'{"id":391415171,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":95,"ts":1737888980,"arguments":[{"piid":1,"value":1}]},"type":16}'}
2025-01-26 18:56:20.447 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report_ack', 'data': b'{"id":391415171,"result":"ok"}'}
2025-01-26 18:56:21.955 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'central/report', 'data': b'{"id":1986634031,"_to":128,"type":16,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":96,"ts":1737888981,"arguments":[{"piid":1,"value":2}]}}'}
2025-01-26 18:56:21.955 DEBUG (MainThread) [custom_components.xiaomi_gateway3.gate.10.10.11.20] {'uid': '8446935148c7', 'did': '792912782', 'msg': 'on_report', 'data': {'action': 'button_2_single'}}
2025-01-26 18:56:21.958 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report', 'data': b'{"id":229838172,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":96,"ts":1737888981,"arguments":[{"piid":1,"value":2}]},"type":16}'}
2025-01-26 18:56:22.005 DEBUG (MainThread) 
2025-01-26 18:56:22.951 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report', 'data': b'{"id":853411175,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":97,"ts":1737888982,"arguments":[{"piid":1,"value":2}]},"type":16}'}
2025-01-26 18:56:22.951 DEBUG (MainThread) [custom_components.xiaomi_gateway3.gate.10.10.11.20] {'uid': '8446935148c7', 'did': '792912782', 'msg': 'on_report', 'data': {'action': 'button_2_single'}}
2025-01-26 18:56:24.712 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'central/report', 'data': b'{"id":906583036,"_to":128,"type":16,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":98,"ts":1737888984,"arguments":[{"piid":1,"value":2}]}}'}
2025-01-26 18:56:24.712 DEBUG (MainThread) [custom_components.xiaomi_gateway3.gate.10.10.11.20] {'uid': '8446935148c7', 'did': '792912782', 'msg': 'on_report', 'data': {'action': 'button_2_single'}}
2025-01-26 18:56:24.713 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report', 'data': b'{"id":483001176,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":98,"ts":1737888984,"arguments":[{"piid":1,"value":2}]},"type":16}'}
2025-01-26 18:56:24.765 DEBUG (MainThread) 
2025-01-26 18:56:25.941 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'central/report', 'data': b'{"id":111077039,"_to":128,"type":16,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":99,"ts":1737888985,"arguments":[{"piid":1,"value":3}]}}'}
2025-01-26 18:56:25.941 DEBUG (MainThread) [custom_components.xiaomi_gateway3.gate.10.10.11.20] {'uid': '8446935148c7', 'did': '792912782', 'msg': 'on_report', 'data': {'action': 'button_3_single'}}
2025-01-26 18:56:25.942 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report', 'data': b'{"id":1963478177,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":99,"ts":1737888985,"arguments":[{"piid":1,"value":3}]},"type":16}'}
2025-01-26 18:56:25.985 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report_ack', 'data': b'{"id":1963478177,"result":"ok"}'}
2025-01-26 18:56:30.475 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report', 'data': b'{"id":1586660183,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":102,"ts":1737888990,"arguments":[{"piid":1,"value":4}]},"type":16}'}
2025-01-26 18:56:30.475 DEBUG (MainThread) [custom_components.xiaomi_gateway3.gate.10.10.11.20] {'uid': '8446935148c7', 'did': '792912782', 'msg': 'on_report', 'data': {'action': 'button_4_single'}}
2025-01-26 18:56:30.476 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'central/report', 'data': b'{"id":998401047,"_to":128,"type":16,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":1,"tid":102,"ts":1737888990,"arguments":[{"piid":1,"value":4}]}}'}
2025-01-26 18:56:30.526 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report_ack', 'data': b'{"id":1586660183,"result":"ok"}'}
2025-01-26 18:56:35.238 DEBUG (MainThread) [custom_components.xiaomi_gateway3.mqtt.10.10.11.20] {'topic': 'miio/report', 'data': b'{"id":114416189,"method":"event_occured","params":{"did":"792912782","siid":6,"eiid":2,"tid":104,"ts":1737888994,"arguments":[{"piid":1,"value":4}]},"type":16}'}
2025-01-26 18:56:35.238 DEBUG (MainThread) [custom_components.xiaomi_gateway3.gate.10.10.11.20] {'uid': '8446935148c7', 'did': '792912782', 'msg': 'on_report', 'data': {'action': 'button_4_hold'}}

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 26, 2025

@hzonz
Copy link
Author

hzonz commented Jan 26, 2025

I needs info: https://github.com/AlexxIT/XiaomiGateway3?tab=readme-ov-file#device-command-select

extra:
  cloud_fw: 3.0.2_0002
  cloud_name: 洗漱池四键零火
  did: '792912782'
  mac: 84:46:93:51:48:c7
  market_brand: PTX
  market_model: AK4 Pro Mesh2.0, 090615.switch.akpro4
  market_name: PTX Wall Switch
  rssi_54ef4440705c: -59
  seq: 164
  type: mesh
last_report:
  jdq_status_1: true
last_report_gw:
  fw_ver: 1.0.7_0021
  host: 10.10.11.20
  mac: 54:ef:44:40:70:5c
  model: lumi.gateway.mcn001
  name: 小米多模网关
last_report_ts: 4m53s
last_request_ts: 10m6s
last_seen:
  54ef4440705c: 4m53s
listeners: 11
model: 21145
params:
  action: button_4_hold
  jdq_status_1: true
  jdq_status_2: true
ttl: 50m
uid: 8446935148c7

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 26, 2025

I see in the log that you are receiving events from this device. I don't understand what exactly you're missing.

@hzonz
Copy link
Author

hzonz commented Jan 26, 2025

I see in the log that you are receiving events from this device. I don't understand what exactly you're missing.

Sorry, my question caused a misunderstanding.

I am using the 090615.switch.akpro4 as a wireless switch.
In automation, for the device 090615.switch.akpro4, I cannot select Action as a trigger condition.

For example:

For the device lumi.remote.b286opcn01, Action can be selected as a trigger condition in automation.
lumi.remote.b286opcn01 is a wireless switch.

description: ""
mode: single
triggers:
  - device_id: f7096c292be14f4ca2c85edd89eadbd9       **lumi.remote.b286opcn01**
    domain: xiaomi_gateway3
    type: action    
    metadata: {}
    trigger: device
    state: button_1_single
conditions: []
actions: []

However, the 090615.switch.akpro4 does not have the Action option.

description: ""
mode: single
triggers:
  - type: turned_off        **There is no Action option.**
    device_id: 7a6571c99a94aa14d07c1c862f510c03      **090615.switch.akpro4**
    entity_id: 107962afbf7eac647cbd06c6089c19aa
    domain: switch
    trigger: device
conditions: []
actions: []

Using Action as a trigger condition allows for simple execution of automation, so I would like to use this method as the trigger condition for automation.

Thank you for your attention!

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 26, 2025

Ah. It's because you using custom (not built-in) converter. You should write state triggers. They always works fine.

@hzonz
Copy link
Author

hzonz commented Jan 26, 2025

Ah. It's because you using custom (not built-in) converter. You should write state triggers. They always works fine.

Thank you! Do you have any plans to update xiaomigateway3 in the near future?

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 26, 2025

I'm not sure. Lots of other projects. Just on the queue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants