Leggin / dirigera

This repository provides an unofficial Python client for controlling the IKEA Dirigera Smart Home Hub.
MIT License
105 stars 20 forks source link

Only one event on remote is send #28

Open sschnake opened 10 months ago

sschnake commented 10 months ago

When subscribing to the events I do only get one event on pressing the remote firmware_version='1.0.47', hardware_version='1', model='RODRET Dimmer', manufacturer='IKEA of Sweden', Need to reboot the hub to get the event only one time again. I do only have remotes on the hub as I wanted to use the Ikea devices to control other home devices. Current plan is to get all the remotes to mqtt.

Leggin commented 10 months ago

This sounds strange, but from the description I can't really think of a fix. Can you share your code?

bwiklak commented 6 months ago

Hi, I also have question about remotes. Is there a way to listen to events on remote in order to create own automations? I can list my controllers using get_controllers but I'm not receiving any messages from it. I have it currently linked to a bulb and I only see events from the bulb:

def on_message(ws: Any, message: str):
    message_dict = json.loads(message)
    data = message_dict["data"]
    print(data)

def on_error(ws: Any, message: str):
    print(message)

hub.create_event_listener(
    on_message=on_message, on_error=on_error
)

Example:

{'id': 'a83fc40d-3e29-4b63-b6c2-f61e5ccbbffa_1', 'type': 'light', 'deviceType': 'light', 'createdAt': '2024-02-20T20:19:10.000Z', 'isReachable': True, 'lastSeen': '2024-02-21T02:02:21.000Z', 'attributes': {'isOn': True}, 'remoteLinks': ['ce33f4cc-904b-4520-9c38-135352b576c6_1', 'e2e1d184-ad4f-4b53-ba05-f47cda3fd8b8_1']}

ce33f3cc is my Styrbar controller I'm currently testing.

TomyMMX commented 5 months ago

@bwiklak I actually think the remotes don't publish their events, sadly. My workaround is to create "fake" scenes that don't do anything (in the IKEA app) and then tie them to the controllers (at least that works for the action button). Then I just wait until that scene gets triggered and check if the trigger was my button. It is a bit annoying, but it works well enough.

bwiklak commented 5 months ago

Right, thanks for answer, I already bought action buttons so this should work.

Leggin commented 5 months ago

@TomyMMX that's a cool work around! With the normal remote control it does not seem to work sadly so I can't test it. But I thinks this would be a great addition to the readme for others to use in this scenario, would you be interested in opening a PR with these infos?

slajob commented 4 months ago

@bwiklak I actually think the remotes don't publish their events, sadly. My workaround is to create "fake" scenes that don't do anything (in the IKEA app) and then tie them to the controllers (at least that works for the action button). Then I just wait until that scene gets triggered and check if the trigger was my button. It is a bit annoying, but it works well enough.

How you can create a fake scenes? I can't create empty scene as provided in screenshot: IMG_948D7646D9B3-1 What's your workaround?

@Leggin How you are exploring dirigiera api? I didn't see anything about single, double and long press event :/ It will be perfect to get this actions :P

TomyMMX commented 4 months ago

@slajob yeah, scenes can't be empty. I have a light bulb that I only use when I go to sleep in the evening, so that "fake" scene just turns that off. Which is fine as it is always off when I use my action button. Not ideal, I know, but works for me.

slajob commented 4 months ago

Okey, maybe burned out old tradfri light could be perfect for that

Leggin commented 4 months ago

To summarize:

@slajob I found a way to create an empty scene via the api, I could add scene creating functionalities to the library if that helps?

slajob commented 4 months ago

@Leggin that will be great! Creating empty scenes can resolve that 🥹

Leggin commented 4 months ago

@slajob the first version for scene manipulation is release, please let me know if you encounter any problems.

slajob commented 4 months ago

@slajob the first version for scene manipulation is release, please let me know if you encounter any problems.

Thanks! I'll try it and give you some feedback