Skip to content

Add event key to discovery message for Push Button events #134

@fvanroie

Description

@fvanroie

Version of the custom_component

0.7.3

Issue

When a GPIO is configured as an input Push Button, then the messages do not correspond to HA boolean values.
To handle these messages a new "events" key is added to the discovery message to map these GPIOs to HA events.

Note: This only applies to Push Buttons. Other sensors and Switch inputs do send the normal 'on'/'off' payloads and work as expected.

The events send by a Push Button GPIO are:

  • down : Occurs when a button goes from depressed to pressed (the moment of touch)
  • up : The button was released within a short time i.e. a short press has occurred
  • release : The button is released after being pressed for over the threshold time
  • long : Event is sent when the button is still being pressed after the threshold time of 400ms
  • hold : The HOLD event is repeated every 200ms while the button is still pressed

Discovery Message

{
  "node": "plate01",
  "mdl": "FreeTouchDeck",
  "mf": "openHASP",
  "hwid": "7c87cee34b7c",
  "pages": 12,
  "sw": "0.7.0-rc12",
  "node_t": "hasp/plate01/",
  "uri": "http://191.168.0.133",
  "input": {},
  "power": [],
  "light": [],
  "dim": [],
  "event": [
    0
  ]
}

A new event key lists the GPIO ids of the Push Button inputs.

Debug log

Currently these events result in an error message in HA log:

2024-07-23 21:13:01.659 ERROR (MainThread) [custom_components.openhasp.binary_sensor] extra keys not allowed @ data['event']
2024-07-23 21:13:03.487 ERROR (MainThread) [custom_components.openhasp.binary_sensor] extra keys not allowed @ data['event']
2024-07-23 21:13:03.889 ERROR (MainThread) [custom_components.openhasp.binary_sensor] extra keys not allowed @ data['event']
2024-07-23 21:13:05.144 ERROR (MainThread) [custom_components.openhasp.binary_sensor] extra keys not allowed @ data['event']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions