Sian-Lee-SA / Home-Assistant-Switch-Manager

Switch manager is a centralised component to handle button pushes for your wireless switches. This includes anything passed through the event bus. The component relies on switch blueprints which is easily made to allow GUI configuration of your switches and their button pushes. This helps remove clutter from the automations.
Other
222 stars 84 forks source link

Could a HomeKit Device switch be used with Switch Manager? #164

Closed diegocjorge closed 1 year ago

diegocjorge commented 1 year ago

I have about 24 Terncy Zigbee Wall Switches (https://www.terncy.com/en-us/wallswitch-withneutral/) and they have a quite a unique set of features that are only accessible using the Terncy App, so the only way I found to integrate them to Home Assistant is thru the HomeKit Devices integration.

But I’m not sure how to create a blueprint for them because the event they fire is quite limited. Here are some examples:

Single Press of the 2nd button from “Escritório Diego” switch:

event_type: state_changed
data:
  entity_id: event.escritorio_diego_b2
  old_state:
    entity_id: event.escritorio_diego_b2
    state: unknown
    attributes:
      event_types:
        - single_press
        - double_press
        - long_press
      event_type: single_press
      device_class: button
      friendly_name: Escritório Diego B2
    last_changed: "2023-08-09T20:38:53.644020+00:00"
    last_updated: "2023-08-09T20:38:53.644020+00:00"
    context:
      id: 01H7E0C5ECZ4AM4D807V6565PG
      parent_id: null
      user_id: null
  new_state:
    entity_id: event.escritorio_diego_b2
    state: "2023-08-09T22:29:59.041+00:00"
    attributes:
      event_types:
        - single_press
        - double_press
        - long_press
      event_type: single_press
      device_class: button
      friendly_name: Escritório Diego B2
    last_changed: "2023-08-09T22:29:59.042094+00:00"
    last_updated: "2023-08-09T22:29:59.042094+00:00"
    context:
      id: 01H7E6QJM2X8MT2PZ6263SVTZX
      parent_id: null
      user_id: null
origin: LOCAL
time_fired: "2023-08-09T22:29:59.042094+00:00"
context:
  id: 01H7E6QJM2X8MT2PZ6263SVTZX
  parent_id: null
  user_id: null

And here is the event for pressing the 4th button of the same “Escritório Diego” switch:

event_type: state_changed
data:
  entity_id: event.escritorio_diego_b4
  old_state:
    entity_id: event.escritorio_diego_b4
    state: unknown
    attributes:
      event_types:
        - single_press
        - double_press
        - long_press
      event_type: single_press
      device_class: button
      friendly_name: Escritório Diego B4
    last_changed: "2023-08-09T20:38:53.653767+00:00"
    last_updated: "2023-08-09T20:38:53.653767+00:00"
    context:
      id: 01H7E0C5ENMQ4SNEM4RNGPD0JV
      parent_id: null
      user_id: null
  new_state:
    entity_id: event.escritorio_diego_b4
    state: "2023-08-09T22:30:05.311+00:00"
    attributes:
      event_types:
        - single_press
        - double_press
        - long_press
      event_type: single_press
      device_class: button
      friendly_name: Escritório Diego B4
    last_changed: "2023-08-09T22:30:05.312195+00:00"
    last_updated: "2023-08-09T22:30:05.312195+00:00"
    context:
      id: 01H7E6QRR0GVJYS0Z0YER67DC0
      parent_id: null
      user_id: null
origin: LOCAL
time_fired: "2023-08-09T22:30:05.312195+00:00"
context:
  id: 01H7E6QRR0GVJYS0Z0YER67DC0
  parent_id: null
  user_id: null

Has you can see there is no unique identifier for the device (Escritório Diego) and the buttons are only identifiable by the entity_id, but even so it still not usable because it includes the device name.

Is there any way I could create a blueprint for such device?

Here’s the device page from Home Assistant:

switch

Sian-Lee-SA commented 1 year ago

I'm not familiar with HomeKit and personally I find an integration that wont convert stateless presses to events (Event Bus, not to be confused with an entity_id in the event domain) just poor. Alternatively you can handle them by an automation then apply the event as an action and use those events in your blueprint. Why you're at it, I would also query the developer of the integration and ask if they have events for button presses and if not, then why.

ironcrafter54 commented 1 year ago

Homekit lifx user here, would love to hear if you have figured this out as I really want to use my lifx switch with switch manager and have no clue where to start.

Sian-Lee-SA commented 1 year ago

As stated, if home assistant can handle the device from automations then just use an automation as a proxy and create an Event action which you can then create a blueprint from.