I’m having problems of using the deconz and appdaemon components together. After a google search I found out the following
The deconz components uses “event” as an parameter in event_data. Appdaemon also has “event” as a parameter for its listen_event() function. When I want to listen to a specific event of the deconz component, lets say Xiaomi button pressed, I have to use the event parameter twice, which gives an error. This is because I use “event” as a keyword argument and as a possitional argument.
My suggestion is to change the naming of “event” in event_data of the Deconz component to “event_id” (or something)
Or changing “event” to “event_name” in the listen.event() function of Appdaemon. This way it is also consistent with the naming in the Event Callback where also event_name is used
Or do you know a workaround? I’m really new in python.
No changes planned but I don’t want to be the bad guy and force the issue … Now in beta is a good time to make breaking changes. It’s late tonight, let me think a little and we can discuss more tomorrow.
i think that if there is an option to change names from other parties, or use other ways to avoid double names, there is no reason to create breaking changes.
there will always be third parties that use the same names, for sure when it gets to things like “events, entities, new, old, attributes, etc” in an automation development.
it could very well be that if Andrew changes it to “event_name” then some other components will get a problem, because they use event_name in stead of event.
i didnt get that you are the third party
isnt that event also in the attributes?
or could you add it there?
then there wouldnt be a need for listen_event at all and noone would have to have breaking changes.
This is the way to go I think - the filtering function of listen_event() is optional - you will still get the callback, and you simply need to use an if statement in your callback to check the id and event entries in the data parameter that AppDaemon supplies to you.
It’s a couple of lines more code, but no one has to make any breaking changes
Not really - the filtering is just a convenience function - either way there is an if/then evaluation either implicitly in the appdaemon code if you specify the additional arguments and they match fields in the event data, or in the app where you are handed a complete set of the event data anyway.
@Try2Fly would you be willing to post a full AD example of this? Either here or as an PR for the component documentation. Would be really nice to have an AD example in the documentation.
btw chances are that the event codes 1000 and 1002 for pressed and released will be swapped in the next version of the deconz rest api, as this is now a pull request.