jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
199 stars 47 forks source link

zwave scene events? #6

Closed rhd closed 4 years ago

rhd commented 4 years ago

Hi, is it possible for you to forward zwave scene related things to home assistant? For example, a double tap on an inovelli light switch. Although, playing around with hubitat, it seems the drivers convert the zwave scene events into button presses similar to this. Do those automatically get forwarded?

jason0x43 commented 4 years ago

As long as Hubitat forwards some event related to the scenes over the Maker API, this integration will be able to make it show up in Home Assistant. I'm actually working on pushbutton support right now (#7), so if the scenes show up as button pushes you should be good.

rhd commented 4 years ago

Great timing! When #7 is ready I'll give it a test...

Thanks!

jason0x43 commented 4 years ago

@rhd When you get a chance, see how #7 works out for this.

rhd commented 4 years ago

Wow - this is great!

So, I see the events in HE

app:982020-02-18 08:57:12.876 pm infoReceiver Zone 2: Living Room Rear Door Light Switch held 2
app:652020-02-18 08:57:12.794 pm debugdevice event: {"name":"held","value":"2","displayName":"Living Room Rear Door Light Switch","deviceId":"71","descriptionText":null,"unit":null,"data":null}
app:652020-02-18 08:57:12.774 pm debugdevice event: {"name":"lastEvent","value":" Tap \u25bc\u25bc","displayName":"Living Room Rear Door Light Switch","deviceId":"71","descriptionText":null,"unit":null,"data":null}
app:982020-02-18 08:57:03.815 pm infoReceiver Zone 2: Living Room Rear Door Light Switch pushed 2
app:652020-02-18 08:57:03.681 pm debugdevice event: {"name":"pushed","value":"2","displayName":"Living Room Rear Door Light Switch","deviceId":"71","descriptionText":null,"unit":null,"data":null}
app:652020-02-18 08:57:03.676 pm debugdevice event: {"name":"lastEvent","value":" Tap \u25b2\u25b2","displayName":"Living Room Rear Door Light Switch","deviceId":"71","descriptionText":null,"unit":null,"data":null}

In HA I get this in the log file with corresponds to a click on the up paddle of the switch. The way these work is that the upper paddle corresponds to a pushed event and the lower paddle corresponds to a held event. I'm not seeing the held events.

2020-02-18 21:52:17 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=1>
2020-02-18 21:52:31 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=2>
2020-02-18 21:53:49 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=2>
2020-02-18 21:54:16 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=2>

I'd expect attribute=held debug lines here as well. Any ideas?

jason0x43 commented 4 years ago

Enable debug logging for hubitatmaker as well:

logger:
  default: info
  logs:
    custom_components.hubitat: debug
    hubitatmaker: debug

That will show, at a lower level, which events the integration is receiving from Hubitat. When an event comes in you should see a line like:

2020-02-19 08:25:00 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '1', 'displayName': 'Triple switch', 'deviceId': '180', 'descriptionText': 'Triple switch button 1 was pushed', 'unit': None, 'data': None}

Hopefully you'll see "held" events coming through, in which case it just means that there's a problem handling them.

rhd commented 4 years ago

hubitatmaker is showing the events! So it seems I just need to learn how to use them...

2020-02-19 07:45:51 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastEvent', 'value': ' Tap ▲▲', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 07:45:51 DEBUG (MainThread) [hubitatmaker.hub] Updating lastEvent of 71 to  Tap ▲▲
2020-02-19 07:45:51 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '2', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 07:45:51 DEBUG (MainThread) [hubitatmaker.hub] Updating pushed of 71 to 2
2020-02-19 07:45:51 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=2>

2020-02-19 07:45:56 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'held', 'value': '2', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 07:45:56 DEBUG (MainThread) [hubitatmaker.hub] Updating held of 71 to 2
2020-02-19 07:45:56 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastEvent', 'value': ' Tap ▼▼', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 07:45:56 DEBUG (MainThread) [hubitatmaker.hub] Updating lastEvent of 71 to  Tap ▼▼
jason0x43 commented 4 years ago

Hmmm....custom_components.hubitat.device should have emitted an event for held, like it did for pushed. (It doesn't understand lastEvent, so it will ignore that one.)

rhd commented 4 years ago
$ cat /config/home-assistant.log | grep custom_components.hubitat.device
2020-02-19 07:12:02 DEBUG (MainThread) [custom_components.hubitat.switch] Added entities for pushbutton controllers: [<custom_components.hubitat.device.HubitatEventDevice object at 0x6bce4d70>]
2020-02-19 07:45:28 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=2>
2020-02-19 07:45:41 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=2>
2020-02-19 07:45:51 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=2>

How else can I help debug this?

jason0x43 commented 4 years ago

Oh, I see why it's not. That part of the code is only paying attention to pushed events. 🤦‍♂

rhd commented 4 years ago

:+1: Hopefully an easy fix!

jason0x43 commented 4 years ago

Give v0.4.4 a try.

rhd commented 4 years ago

Hi! I just tried 0.4.4. Here is the log:

2020-02-19 10:38:06 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '2', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 10:38:06 DEBUG (MainThread) [hubitatmaker.hub] Updating pushed of 71 to 2
2020-02-19 10:38:06 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=71 attribute=pushed value=2>
2020-02-19 10:38:06 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastEvent', 'value': ' Tap ▲▲', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 10:38:06 DEBUG (MainThread) [hubitatmaker.hub] Updating lastEvent of 71 to  Tap ▲▲

2020-02-19 10:38:10 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastEvent', 'value': ' Tap ▼▼', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 10:38:10 DEBUG (MainThread) [hubitatmaker.hub] Updating lastEvent of 71 to  Tap ▼▼
2020-02-19 10:38:10 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'held', 'value': '2', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 10:38:10 DEBUG (MainThread) [hubitatmaker.hub] Updating held of 71 to 2

I'm not seeing the emitted event for the "held" event.

BTW, I'm using the inovelli drivers (from inovelli) for this device. Another device, I'm using the driver built into HE and they provide a slightly different event - doubleTapped.

2020-02-19 10:41:39 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'doubleTapped', 'value': '2', 'displayName': 'Dining Room Outdoor Light Switch ', 'deviceId': '101', 'descriptionText': 'Dining Room Outdoor Light Switch  button 2 was doubleTapped', 'unit': None, 'data': None}
2020-02-19 10:41:39 DEBUG (MainThread) [hubitatmaker.hub] Updating doubleTapped of 101 to 2

2020-02-19 10:41:42 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'held', 'value': '2', 'displayName': 'Dining Room Outdoor Light Switch ', 'deviceId': '101', 'descriptionText': 'Dining Room Outdoor Light Switch  button 2 was held', 'unit': None, 'data': None}
2020-02-19 10:41:42 DEBUG (MainThread) [hubitatmaker.hub] Updating held of 101 to 2

2020-02-19 10:41:45 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '2', 'displayName': 'Dining Room Outdoor Light Switch ', 'deviceId': '101', 'descriptionText': 'Dining Room Outdoor Light Switch  button 2 was pushed', 'unit': None, 'data': None}
2020-02-19 10:41:45 DEBUG (MainThread) [hubitatmaker.hub] Updating pushed of 101 to 2
2020-02-19 10:41:45 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id=101 attribute=pushed value=2>

It still seems that the pushed event is the only one propagating out of the hubitatmaker?

BTW, thanks for all this hard work - I appreciate it. This bridge interface is going to be amazing!

jason0x43 commented 4 years ago

Try reinstalling the integration in HACS and/or restarting Home Assistant. The event message in 0.4.4 should have some additional fields:

2020-02-19 14:12:08 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id="180" device_name="Triple switch" attribute="pushed" value="1" description="Triple switch button 1 was pushed">

BTW, I'm using the inovelli drivers (from inovelli) for this device.

Ah, that's where that lastEvent event was coming from. Weird that they didn't use the standard capabilities; that's just asking to cause problems. I wonder -- with that driver, does the device even report that it supports HoldableButton or DoubleTapableButton (the Hubitat capabilities)?

rhd commented 4 years ago

I did a reinstall/reboot and now the log shows this (inovelli driver)

2020-02-19 17:26:48 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '2', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 17:26:48 DEBUG (MainThread) [hubitatmaker.hub] Updating pushed of 71 to 2
2020-02-19 17:26:48 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id="71" device_name="Living Room Rear Door Light Switch" attribute="pushed" value="2" description="None">
2020-02-19 17:26:48 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastEvent', 'value': ' Tap ▲▲', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 17:26:48 DEBUG (MainThread) [hubitatmaker.hub] Updating lastEvent of 71 to  Tap ▲▲

2020-02-19 17:26:51 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'held', 'value': '2', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 17:26:51 DEBUG (MainThread) [hubitatmaker.hub] Updating held of 71 to 2
2020-02-19 17:26:51 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id="71" device_name="Living Room Rear Door Light Switch" attribute="held" value="2" description="None">
2020-02-19 17:26:51 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'lastEvent', 'value': ' Tap ▼▼', 'displayName': 'Living Room Rear Door Light Switch', 'deviceId': '71', 'descriptionText': None, 'unit': None, 'data': None}
2020-02-19 17:26:51 DEBUG (MainThread) [hubitatmaker.hub] Updating lastEvent of 71 to  Tap ▼▼

And the HE driver

2020-02-19 17:27:45 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'doubleTapped', 'value': '2', 'displayName': 'Dining Room Outdoor Light Switch ', 'deviceId': '101', 'descriptionText': 'Dining Room Outdoor Light Switch  button 2 was doubleTapped', 'unit': None, 'data': None}
2020-02-19 17:27:45 DEBUG (MainThread) [hubitatmaker.hub] Updating doubleTapped of 101 to 2
2020-02-19 17:27:45 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id="101" device_name="Dining Room Outdoor Light Switch " attribute="doubleTapped" value="2" description="Dining Room Outdoor Light Switch  button 2 was doubleTapped">

2020-02-19 17:27:48 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'held', 'value': '2', 'displayName': 'Dining Room Outdoor Light Switch ', 'deviceId': '101', 'descriptionText': 'Dining Room Outdoor Light Switch  button 2 was held', 'unit': None, 'data': None}
2020-02-19 17:27:48 DEBUG (MainThread) [hubitatmaker.hub] Updating held of 101 to 2
2020-02-19 17:27:48 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id="101" device_name="Dining Room Outdoor Light Switch " attribute="held" value="2" description="Dining Room Outdoor Light Switch  button 2 was held">

2020-02-19 17:27:52 DEBUG (MainThread) [hubitatmaker.hub] Received event: {'name': 'pushed', 'value': '2', 'displayName': 'Dining Room Outdoor Light Switch ', 'deviceId': '101', 'descriptionText': 'Dining Room Outdoor Light Switch  button 2 was pushed', 'unit': None, 'data': None}
2020-02-19 17:27:52 DEBUG (MainThread) [hubitatmaker.hub] Updating pushed of 101 to 2
2020-02-19 17:27:52 DEBUG (MainThread) [custom_components.hubitat.device] emitted event <Event device_id="101" device_name="Dining Room Outdoor Light Switch " attribute="pushed" value="2" description="Dining Room Outdoor Light Switch  button 2 was pushed">

So, seems all is working?

rhd commented 4 years ago

This is the driver.

        capability "Switch"
        capability "Refresh"
        capability "Actuator"
        capability "Sensor"
        capability "PushableButton"
        capability "HoldableButton"
        capability "Configuration"
        capability "Energy Meter"
        capability "Power Meter"
jason0x43 commented 4 years ago

Yeah, it looks like it's working as intended now.

The innovelli driver doesn't support double-tapping, at least not as a discrete event. The lastEvent event it emits is just a repeat of the last actual event, with a value in a custom innovelli format. (The driver keeps lastEvent as a separate state attribute, and when it updates the attribute, Hubitat emits an event.)

I'm going to close this since the integration appears to be doing what it's supposed to, but we can reopen it if that's not the case.