Knocki integration

Hi everyone!

We’re currently attempting to integrate Knocki into Home Assistant (HA). Knocki is a smart home device that transforms any surface into a gesture-enabled control interface for managing your favorite functions.

For our initial release, We’re aiming to execute a Home Assistant automation whenever a specific action is triggered through Knocki. Each action is identified by an ID along with a description. Knocki will send a payload to a topic configured in Home Assistant using either MQTT or WebSockets, whichever is easiest. Essentially, the payload will only contain the triggered action ID. Upon reception, Home Assistant should then verify existing automations using the action id as a trigger.

We’ve prepared a diagram illustrating the flow:

However, we have some uncertainties regarding how Home Assistant operates, such as:

We’re relatively new to Home Assistant, and any assistance you can offer would be greatly appreciated! Our aim is to keep things as straightforward as possible during this initial phase. Therefore, we believe your insights could provide valuable guidance on how to proceed.

Yes that would be best. One event for each action.

1 Like

Thank you @tom_l!

We’re excited to get our Home Assistant integration ready for the community - our customers have been requesting this for a long time.

@juanknocki do we have any other technical questions for Tom_I and/or the community?

If any of you are willing to connect with us via Slack and help out with the integration, we’d gladly throw a free Knocki your way to show our appreciation.

Hey @tom_l! We’re fairly new here. We’ve created the Event Entity and successfully instantiated our first entity. Now, we’re exploring methods to subscribe to incoming events, such as MQTT or WebSockets. What would you recommend? In your documentation (Event entity | Home Assistant Developer Docs), it’s mentioned that we need to call my_device_api.listen . Could you provide some examples or guidelines to get started on this? While I’ve begun examining examples on GitHub of your existing integrations, having a straightforward method would be greatly appreciated! Additionally, as @knocki mentioned earlier, we’re open to collaborating with anyone interested in working together.

I am not a developer, just a lowly forum moderator. You would be best to ask these questions in one of the developer channels on the Home Assistant Discord server.

@tom_l thanks for the pointer. We’ve posted our questions on HA’s Discord per your advice and already have a few folks generously offering to help. Hopefully we can get the integration out by June!

2 Likes

@knocki @juanknocki Hi. I hadn’t heard about Knocki before the integration appeared in the last HA release. So I bought one to evaluate. After some challenges it is now sitting on one of my VLANs and I’m receiving notifications on my phone.
My next challenge is to build an HA/Node-RED automation and I note that the integration fires an event - but which event? Is it a state_changed event for example, or something else?
I really like MQTT for this kind of thing and use zigbee2MQTT extensively for my sensors. I consider its pub/sub architecture to be superior to webhooks on many counts. If my Knocki could send MQTT packets to my Mosquitto broker I’d be a happy bunny.

I should add…If you are new to HA you might not know that the MQTT integration can create devices and entities for you - something called MQTT Discovery:

Hey, just got my knocki integrated and everything works.

Im trying to figure out how to create an automation trigger for the event entity it makes.

At the moment, have separate event entities for 3 and 4 knocks. When it activates, it just says event detected.

I’d rather not use just any state change for the automation trigger so therefore finding the actual event details would be beneficial here.

Listening to events I’ve tried already but for some reason I can’t see it on the list of events maybe because I have too many events happening? How do I listen to a specific entity?

Thank you!

@Anto79-ops Same problem here. I am used to events being behind-the-scenes things which change device/entity states, not things I should find a way to ‘subscribe to’ in my automations. For me, triggers are usually based on entity state changes not events. I’m pretty sure that’s the way HA users think, generally.

I can see that an event arrived named:

event.knc1_w_000xxxxx_testing_knocki_1

but can’t capture any data associated with it so I can’t proceed. Perhaps that’s all there is. Maybe @knocki can clarify.

From my testing, for anyone trying out Knocki -

  • Get the latest firmware (ask Knocki support to push it to your device). Mine is currently 1.0.5-rc4. The Knocki app’s Home Assistant Task doesn’t appear in 1.0.2 which the device arrived with.
  • Then reload the knocki integration
  • In the mobile app log out and back in.

@hunterdrayman I hear you, from what I understand, you ahve to listen to any events that the entity gives, at least for now. Here’s my automation, for example, that turns a lightt on and off. Notice the not to and not from additions. I relize this is not the most robost way to do it, but it works.

PS. you may wish to edit your post and remove the serial number in your entity.

alias: Knocki control for master bedroom
description: Control various tasks from the Knocki
trigger:
  - platform: state
    entity_id:
      - event.knc1_bxxxxxxx_3_knocks
    not_from:
      - unknown
      - unavailable
      - None
    not_to:
      - unknown
      - unavailable
      - None
    id: 3_knocks
  - platform: state
    entity_id:
      - event.knc1_bbxxxxxxx_4_knocks
    not_from:
      - unknown
      - unavailable
      - None
    not_to:
      - unknown
      - unavailable
      - None
    id: 4_knocks
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - 3_knocks
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.master_bedroom_main_lights
            data: {}
      - conditions:
          - condition: trigger
            id:
              - 4_knocks
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.master_bedroom_main_lights
            data: {}
mode: single

Thanks @Anto79-ops. That was a very helpful example and after some customisation (and integration reload) it worked for me. I can now experiment further whilst hoping that a more conventional mechanism will be developed.
I might just emit an MQTT message and have the MQTT integration create a device/state entity on which I can base my automations.