DavidMStraub / homeconnect

MIT License
31 stars 16 forks source link

Event object for handle_event() #6

Closed SantaFox closed 2 years ago

SantaFox commented 3 years ago

David hi,

can I ask you to add an Event object in callback in the HomeConnectAppliance.handle_event() method? Like this:

        event_data = json.loads(event.data)
        d = self.json2dict(event_data["items"])
        self.status.update(d)
        if callback is not None:
            callback(self, event)

I am still not good in Python to understand how to make it and send a pull request for you, keeping in mind that at least your component receives this callbacks and should not fall into problem with extra parameter.

P.S. in your version you reassign json.loads(event.data) back to the event variable; however in this case you loose an event type held in event.event. For example, if event.event == 'KEEP-ALIVE", it is possible to stop processing event and do not throw a callback.