Help getting deconz_helper.py creating an sensor for each event_id?

Hi

I have a Deconz integration and installed the app deconz-helper.py

Anyone have an idea on how to edit it so that it so that it create an sensor for each “event_id?

Like: “sensor.deconz_event_{event_id}” in the code below

import appdaemon.plugins.hass.hassapi as hass
import datetime
from datetime import datetime


class DeconzHelper(hass.Hass):
    def initialize(self) -> None:
        self.listen_event(self.event_received, "deconz_event")

    def event_received(self, event_name, data, kwargs):
        event_data = data["event"]
        event_id = data["id"]
        event_received = datetime.now()

        self.log(f"Deconz event received from {event_id}. Event was: {event_data}")
        self.set_state(
            "sensor.deconz_event",
            state=event_data,
            attributes={
                "event_trigger": event_id,
                "event_received": str(event_received),

Take a look at this awesome AppDaemon app from @xaviml , highly probability that your remote is already supported by this app.

1 Like

Hit

Thanks, but not supported. My switch is an Namron 4512703 that reports for 4 different groups, on decon_event

Ask @xaviml to add it to his app, I’m almost sure he will be happy to add new devices to his app :slight_smile:

But why do you want to create a sensor for each remote and not just use the events directly in your automations? Or do you know some Python, thencreate the automation directly in AppDaemon. Seems like an unnecessary extra step.

1 Like

Its for self help, waiting for an full support in Deconz

Solved with:

       self.log(f"Deconz event received from {event_id}. Event was: {event_data}")
        self.set_state(
            "sensor.deconz_event_" + event_id,
            state=event_data,
            attributes={
                "event_trigger": event_id,
                "event_received": str(event_received),
            },
        )

Can you elaborate a bit more? I’m curious.

What do you mean with this? There seems to be support in Deconz or how do you get the events otherwise?

Hi @monsivar,

If you are interested in integrating this device into ControllerX, you can also report the events that the button send in here and then I can add the device and give it a default behaviour or you can also already use Custom Controllers to give the behavior that you wish.

Cheers,
Xavi M.

EDIT:
Thanks @Burningstone for tagging me out!

1 Like

Hei

The switch is not fully supportet in Deconz and the API. so to handle it, im just for self help and learning createt sensor for folowing up the state changes and createt an viritual switch (sensor) in HA that holds values that i use in automations.

Thanks, I’ll ask when the switch is fully supported in Deconz, right now, it is not reporting as one, but 4 different groups.
Info on how its implemented in Deconz here: https://github.com/dresden-elektronik/deconz-rest-plugin/issues/2158#issuecomment-604481688

I still don’t get this, why don’t you use the events directly instead of creating a sensor as the middle man?