jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
196 stars 48 forks source link

Aqara Button #59

Open xe1gyq opened 4 years ago

xe1gyq commented 4 years ago

I have integrated this Aqara Button under Hubitat and trying to read its events under Home Assistant. The following steps were executed:

  1. Hubitat up and running
  2. Devices added, one Aqara Button and four Xiaomi Door/Window Sensor
  3. HACS Hubitat v0.5.6
  4. Hubitat Integration setup including:

    
     URL to send device events to by POST 
     http://192.168.1.111:12400
     [Y] Include location events to be sent by POST?
  5. Once integration is completed in Home Assistant, only Aqara Sensor Battery is available.

I cannot listen for events using hubitat_events, not available including the following output under Configuration > Logger:

Error doing job: Exception in callback Hub.process_event({'content': {'data': None, 'descriptionText': 'Button was single-clicked', 'deviceId': '8', 'displayName': 'Aqara Button One', ...}})

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/hub.py", line 163, in process_event
    listener(evt)
  File "/config/custom_components/hubitat/device.py", line 395, in handle_event
    super().handle_event(event)
  File "/config/custom_components/hubitat/device.py", line 362, in handle_event
    evt = dict(event)
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/types.py", line 129, in __iter__
    yield key, getattr(self, key)
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/types.py", line 114, in type
    return self._properties["type"]
KeyError: 'type'

Logger with:

logger:                                                                                                                             $
  default: info                                                                                                                     $
  logs:                                                                                                                             $
    hubitatmaker: debug                                                                                                             $
    homeassistant.custom_components.hubitat: debug
jason0x43 commented 4 years ago

Thanks for the detailed report!

Once integration is completed in Home Assistant, only Aqara Sensor Battery is available.

This is expected for button controllers. The buttons themselves generate events but don't have associated entities.

Error doing job: Exception in callback Hub.process_event({'content': {'data': None, 'descriptionText': 'Button was single-clicked', 'deviceId': '8', 'displayName': 'Aqara Button One', ...}})

When you push a button on your controller, do you see a message in the log where the event was received, before Home Assistant tried to process it? It would look something like this (but for your button device):

2020-08-01 19:40:10 DEBUG (MainThread) [custom_components.hubitat.device] Emitted event {'device_id': '180', 'device_name': 'Triple switch', 'attribute': 'pushed', 'value': '1', 'description': 'Triple switch button 1 was pushed', 'type': None, 'hub': 'fec5aa7d'}

From your error, it looks like the received event might not have a type property. I can work around that, but I'd like to verify if that's actually the issue.

xe1gyq commented 4 years ago

Thanks to you @jason0x43 for the quick response :) here you have the log of button pressed and button released:

2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '1', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Button was single-clicked', 'unit': None, 'data': None},
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Updating pushed of 8 to 1,
2020-08-02 10:01:02 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Hub.process_event({'content': {'data': None, 'descriptionText': 'Button was single-clicked', 'deviceId': '8', 'displayName': 'Aqara Button One', ...}}),
Traceback (most recent call last):,
  File "/usr/local/lib/python3.8/asyncio/events.py", line 81, in _run,
    self._context.run(self._callback, *self._args),
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/hub.py", line 163, in process_event,
    listener(evt),
  File "/config/custom_components/hubitat/device.py", line 395, in handle_event,
    super().handle_event(event),
  File "/config/custom_components/hubitat/device.py", line 362, in handle_event,
    evt = dict(event),
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/types.py", line 129, in __iter__,
    yield key, getattr(self, key),
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/types.py", line 114, in type,
    return self._properties["type"],
KeyError: 'type',
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastCheckinTime', 'value': 'Aug 2, 2020 10:01:02 AM', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': None, 'unit': None, 'data': None},
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Updating lastCheckinTime of 8 to Aug 2, 2020 10:01:02 AM,
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'buttonPressedEpoch', 'value': '1596380462617', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Updated buttonPressedEpoch', 'unit': None, 'data': None},
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Updating buttonPressedEpoch of 8 to 1596380462617,
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'buttonPressedTime', 'value': 'Aug 2, 2020 10:01:02 AM', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Updated buttonPressedTime', 'unit': None, 'data': None},
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Updating buttonPressedTime of 8 to Aug 2, 2020 10:01:02 AM,
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastCheckinEpoch', 'value': '1596380462605', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': None, 'unit': None, 'data': None},
2020-08-02 10:01:02 DEBUG (MainThread) [hubitatmaker.hub] Updating lastCheckinEpoch of 8 to 1596380462605,

And now of button held and button released:

2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'buttonHeldEpoch', 'value': '1596380639728', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Updated buttonHeldEpoch', 'unit': None, 'data': None},
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Updating buttonHeldEpoch of 8 to 1596380639728,
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastCheckinEpoch', 'value': '1596380639718', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': None, 'unit': None, 'data': None},
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Updating lastCheckinEpoch of 8 to 1596380639718,
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'held', 'value': '1', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Button was held', 'unit': None, 'data': None},
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Updating held of 8 to 1,
2020-08-02 10:03:59 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Hub.process_event({'content': {'data': None, 'descriptionText': 'Button was held', 'deviceId': '8', 'displayName': 'Aqara Button One', ...}}),
Traceback (most recent call last):,
  File "/usr/local/lib/python3.8/asyncio/events.py", line 81, in _run,
    self._context.run(self._callback, *self._args),
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/hub.py", line 163, in process_event,
    listener(evt),
  File "/config/custom_components/hubitat/device.py", line 395, in handle_event,
    super().handle_event(event),
  File "/config/custom_components/hubitat/device.py", line 362, in handle_event,
    evt = dict(event),
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/types.py", line 129, in __iter__,
    yield key, getattr(self, key),
  File "/usr/local/lib/python3.8/site-packages/hubitatmaker/types.py", line 114, in type,
    return self._properties["type"],
KeyError: 'type',
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'buttonHeldTime', 'value': 'Aug 2, 2020 10:03:59 AM', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Updated buttonHeldTime', 'unit': None, 'data': None},
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Updating buttonHeldTime of 8 to Aug 2, 2020 10:03:59 AM,
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastCheckinTime', 'value': 'Aug 2, 2020 10:03:59 AM', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': None, 'unit': None, 'data': None},
2020-08-02 10:03:59 DEBUG (MainThread) [hubitatmaker.hub] Updating lastCheckinTime of 8 to Aug 2, 2020 10:03:59 AM,
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'released', 'value': '1', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Button was released', 'unit': None, 'data': None},
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Updating released of 8 to 1,
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'buttonReleasedEpoch', 'value': '1596380641542', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Updated buttonReleasedEpoch', 'unit': None, 'data': None},
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Updating buttonReleasedEpoch of 8 to 1596380641542,
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'buttonReleasedTime', 'value': 'Aug 2, 2020 10:04:01 AM', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': 'Updated buttonReleasedTime', 'unit': None, 'data': None},
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Updating buttonReleasedTime of 8 to Aug 2, 2020 10:04:01 AM,
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastCheckinTime', 'value': 'Aug 2, 2020 10:04:01 AM', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': None, 'unit': None, 'data': None},
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Updating lastCheckinTime of 8 to Aug 2, 2020 10:04:01 AM,
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastCheckinEpoch', 'value': '1596380641532', 'displayName': 'Aqara Button One', 'deviceId': '8', 'descriptionText': None, 'unit': None, 'data': None},
2020-08-02 10:04:01 DEBUG (MainThread) [hubitatmaker.hub] Updating lastCheckinEpoch of 8 to 1596380641532,
AzureAzim commented 4 years ago

EDIT: Disregard my complaining, i figured it out. I just needed tor record the different button events in the Get all hubitat_events in nodered and then was able to create a subflow for my button presses. Thanks for everything you are creating here.

I think I am having a similar problem with the Aeotec Nanomote. The nanomote only shows as a battery device. Works fine when joined to HomeAssistant via zwave directly (would rather use Hubitat for zwave). WOndering if there is a way to make HACS present the button as a scene controller or something I can use to trigger events. When i am trying to capture the event in node-red, it does not dump record any event.

image

20-09-05 13:46:29 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '3', 'displayName': 'HankButton', 'deviceId': '353', 'descriptionText': 'HankButton Button 3 pushed', 'unit': None, 'type': 'physical', 'data': None}
2020-09-05 13:46:29 DEBUG (MainThread) [hubitatmaker.hub] Updating pushed of 353 to 3
2020-09-05 13:46:30 WARNING (event_thread_0) [sucks] Ping did not reach VacBot. Will retry.
2020-09-05 13:46:30 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '2', 'displayName': 'HankButton', 'deviceId': '353', 'descriptionText': 'HankButton Button 2 pushed', 'unit': None, 'type': 'physical', 'data': None}

Here is the result of the curl cmd

{
    "id": "353",
    "name": "Aeotec NanoMote",
    "label": "HankButton",
    "attributes": [
        {
            "name": "battery",
            "currentValue": 100,
            "dataType": "NUMBER"
        },
        {
            "name": "held",
            "currentValue": null,
            "dataType": "NUMBER"
        },
        {
            "name": "numberOfButtons",
            "currentValue": 4,
            "dataType": "NUMBER"
        },
        {
            "name": "pushed",
            "currentValue": 2,
            "dataType": "NUMBER"
        },
        {
            "name": "released",
            "currentValue": null,
            "dataType": "NUMBER"
        }
    ],
    "capabilities": [
        "Battery",
        {
            "attributes": [
                {
                    "name": "battery",
                    "dataType": null
                }
            ]
        },
        "Sensor",
        "HoldableButton",
        {
            "attributes": [
                {
                    "name": "held",
                    "dataType": null
                }
            ]
        },
        "PushableButton",
        {
            "attributes": [
                {
                    "name": "numberOfButtons",
                    "dataType": null
                },
                {
                    "name": "pushed",
                    "dataType": null
                }
            ]
        },
        "ReleasableButton",
        {
            "attributes": [
                {
                    "name": "released",
                    "dataType": null
                }
            ]
        }
    ],
    "commands": [
        "hold",
        "push",
        "release"
    ]
fxl90 commented 3 years ago

I hate to add to something that seemed solved, but I am seeing issues with these Aqara buttons and even Smartthings buttons.

Previously the hubitat integration, along with the automation UI in home assistant, would present the button events as trigger options in the UI. Seems like those options stopped being presented. Now I can only trigger on battery state but not on buttons pushed or held events.

fxl90 commented 3 years ago

Well ignore that last statement, looks like this issue is probably my problem: #65

jason0x43 commented 3 years ago

@xe1gyq - I published an updated version of the integration that should take care of the missing type property issue. Let me know if that helps.

xe1gyq commented 3 years ago

Thanks @AzureAzim for your comments and thanks @jason0x43 for updating the version :+1: The integration is at my parents home and I am planning to be there early next month, I will for sure report the results.

If someone else could test, We will appreciate to get this tested and closed.

github-actions[bot] commented 3 years ago

Stale issue message

xe1gyq commented 3 years ago

I am still here but away from the Hubitat setup. I will arrive to my parents' home next month. So give me more time to report back. Thanks :) Sorry for the inconvenience.