thomasloven / hass-plejd

🔹 Plejd BLE integration for Home Assistant
87 stars 9 forks source link

Scene event #7

Closed bnordli closed 1 year ago

bnordli commented 1 year ago

Fire an HA event ("plejd_scene_event") when the Plejd mesh initiates a scene. This applies both to normal scenes and timer triggered scenes ("hiddenFromSceneList"). (The latter are still not added as a HA button.)

Example event:

event_type: plejd_scene_event
data:
  index: 11
  name: All on
  state: "on"
origin: LOCAL
time_fired: "2022-10-26T19:28:32.389326+00:00"
context:
  id: 01GGAW9245929EQATP7SJBWY1E
  parent_id: null
  user_id: null
bnordli commented 1 year ago

Note: It might be more useful to instead activate a device trigger (on the "Plejd Scene" device), but I have never implemented a device trigger before, so this is what I made for now.

thomasloven commented 1 year ago

I agree that a device trigger would make more sense. I've never implemented them either, but I have a WPH-01 in the mail so when that arrives I intend to learn anyway...

bnordli commented 1 year ago

I gave the device triggers a shot, but I couldn't find a good way to hook them up. Have you made any more attempts towards this?

If not, I suggest triggering an event like this as a temporary solution.

astrandb commented 1 year ago

I suggest triggering an event like this as a temporary solution

I think this is the right way to go. Make sure the event solution is stable and work fine before you dive into Device Triggers. They are basically just a way to simplify for users in automations. A more user-fiendly way to identify events.

thomasloven commented 1 year ago

I'm trying to keep the pyplejd package somwehat freestanding from Home Assistant, so I think I would prefer some form of callback and trigger the hass event from the integration rather than from PlejdDevice.

bnordli commented 1 year ago

Sounds reasonable. Changed to callback!

ricmik commented 1 year ago

Hey there! Are we any closer to getting events implemented?😊

thomasloven commented 1 year ago

We definitely are. The pyplejd package has just been updated to make this easier.

thomasloven commented 1 year ago

There should now be event entities for each scene.

oyvindwe commented 1 year ago

There should now be event entities for each scene.

I can confirm it works. Got an entity for my scene and an event when I triggered it using the button:

image

I think this PR can be closed.