leeyuentuen / localtuya

local handling for Tuya devices
GNU General Public License v3.0
71 stars 17 forks source link

Add button support #47

Open atlantden opened 1 year ago

atlantden commented 1 year ago

We need support for Zigbee buttons in integration, such as 1-3 key switches and similar ones. Currently, it is not possible to add them correctly through a single entity, as, for example, the sensor does not change state with a sequential single press - the status remains the same. The status only changes when a different action is taken, such as making a double press after a single press, and so on.

alexualbu commented 1 year ago

I am actually looking to buy a zigbee remote / switch. Do you have them set-up as different entities right now? Can you post the DPs details, maybe from tuyaconsole?

atlantden commented 1 year ago

I have the remote controls, but they are almost useless with LocalTuya because when I press the button again, no event occurs and the state does not change. The event and state changes only occur when using different button presses. For example, a second single click won't trigger an event in HA, only a double click after a single click will. This is the essence of the problem. I can provide a section of my configuration for the three-button remote control if needed.

#remote in the hall
  - parent_gateway: my_gateway_id # This tells it is a sub-device dependent on a parent gateway
    device_id: remote_cid (mac-address) # The cid of sub-device
    friendly_name: remote in the hall
    entities:
      - platform: sensor
        friendly_name: Button 1
        id: 1
      - platform: sensor
        friendly_name: Button 2
        id: 2
      - platform: sensor
        friendly_name: Button 3
        id: 3
      - platform: sensor
        friendly_name: Battery
        id: 10
        device_class: battery
alexualbu commented 1 year ago

@atlantden, i am looking for the DPs specification. Normally I would expect different DPs for the different actions (e.g. button 1 single press - dp 1, button 1 double press - dp 2 etc) because I am assuming the device is the one that interprets the action and sends the information. So can you provide the device specification from tuya developer console to confirm that?

atlantden commented 1 year ago

It has one DP for the each button. button 1 - dp 1, button 2 - dp 2 But events are "single_click" "double_click" "long_press". Thees events thats i get in HA I can't view DP in tuya console because they tell me - permission deny from some point when trying to view the device specification but I know that there will be 1 DP for each button, so it was before

alexualbu commented 1 year ago

When you say events, where do you receive them in HA? have you used this endpoint in the tuya console? there are a few and some give "permission deny" error. image

atlantden commented 1 year ago

Yes I use this endpoint. It used to show fine, now it has become so. Yes, I'm talking about an event in HA. I get this event both through the integration of Local Tuya and through ZHA integration with Xiaomi Gate v3 . So I think this is the raw data that the button sends to the outside world.