xaviml / controllerx

Create controller-based automations with ease to control your home devices and scenes.
https://xaviml.github.io/controllerx/
MIT License
332 stars 68 forks source link

support for deconz #10

Closed mario-tux closed 4 years ago

mario-tux commented 4 years ago

I'm not sure but, looking at the code, this app doesn't seem to support events coming from deconz: am I right? If it is not supported, this could be considered a feature request.

Thanks.

xaviml commented 4 years ago

Yes, that is right. At this stage, there is support only for zigbee2mqtt. I do not possess a conbee device to integrate this with deConz. The integration should be easy since we would be listening to events instead of sensors. If anyone has deConz running and some knowledge to develop it, I can merge the changes.

I leave the issue open with a feature request label.

mario-tux commented 4 years ago

I got a conbee device and some knowledge on Python. I can see a very different event management and also the event naming is different. Listening on deconz_event I can see the flow of events but each device emits events with specific numerical type ids. Maybe these are hidden in zigbee2mqtt and already mapped to nice name like brightness_up_click. This would be another not straightforward difference to manage.

xaviml commented 4 years ago

@mario-tux And do the devices always emit the same event with the same numerical type ids? I will code the base code to support deconz and I will keep you in contact to try it out. Which devices that I support do you have? Could you tell me the mapping with the event and the type of action?

xaviml commented 4 years ago

Hi @mario-tux,

I started implementing the deconz support and I gave support to the Hue dimmer switch since it is the only one I could find on the Internet the mapping for the event types. Since I do not have deConz running, I fired the events through HA. If you have the Hue Dimmer switch, you can try it out from the master branch and let me know about it. Otherwise, you will need to tell me the device you have and the event number for each action.

mario-tux commented 4 years ago

Hi @xaviml : sorry for the late reply but I was busy at work. I got:

This an example of the data on a deconz_event:

{
    "event_type": "deconz_event",
    "data": {
        "id": "my_switch",
        "unique_id": "cc:cc:cc:ff:fe:df:XX:XX",
        "event": 3002
    },
    "origin": "LOCAL",
    "time_fired": "2020-01-14T20:50:56.612580+00:00",
    "context": {
        "id": "44ded1e055a74b0d897358aeb2ada6a7",
        "parent_id": null,
        "user_id": null
    }
}

The numeric codes from the event field:

xaviml commented 4 years ago

Hi @mario-tux,

I just pushed the code with the mapping you gave me. Here you have three example configuration for your 2 devices:

yourApp:
  module: z2m_ikea_controller
  class: E1810Controller
  event_id: <the controller event id>
  light: <light entity>
yourApp:
  module: z2m_ikea_controller
  class: E1744LightController
  event_id: <the controller event id>
  light: <light entity>
yourApp:
  module: z2m_ikea_controller
  class: E1744MediaPlayerController
  event_id: <the controller event id>
  media_player: <media_player entity>

Let me know with the update :) Thank you!

mario-tux commented 4 years ago

I was able to make it start and I'm trying to use E1744MediaPlayerController at the moment. The single/double/triple click work well. I got problems using the spinning move to change volume. It looks that the stop button is not promptly recognized: the start event is promptly recognized but, without regards of the movement length, the stop event is always recognized after a long delay. The level bar stops only after reaching the extreme level (zero for the left spin, max for the right spin). I can see the message about the stop event at the end of the sequence so it looks that the event is delivered (but only at the end of the volume up/down sequence).

The log could help to understand what is going on:

2020-01-15 11:41:00.633517 DEBUG TestApp: Button pressed: 2001
2020-01-15 11:41:00.638155 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:01.286578 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:01.878957 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:02.479621 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:03.090038 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:03.698000 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:04.441605 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:05.101867 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:05.784983 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:06.410132 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:07.051476 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:07.704669 DEBUG TestApp: Button pressed: 2003
2020-01-15 11:41:07.752166 DEBUG TestApp: Button pressed: 2001
2020-01-15 11:41:07.756380 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:08.360497 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:08.970741 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:09.617970 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:10.216011 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:10.794115 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:11.382948 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:11.998926 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:12.594119 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:13.199915 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:13.852684 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:14.586768 DEBUG TestApp: Button pressed: 2003
2020-01-15 11:41:14.629011 DEBUG TestApp: Button pressed: 2001
2020-01-15 11:41:14.633439 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:15.279922 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:15.907777 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:16.523768 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:17.148811 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:17.775537 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:18.395819 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:19.011944 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:19.642498 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:20.245160 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:20.904508 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:21.547494 DEBUG TestApp: Button pressed: 2003
2020-01-15 11:41:24.344466 DEBUG TestApp: Button pressed: 3001
2020-01-15 11:41:24.349630 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:24.988632 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:25.907133 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:26.566470 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:27.203719 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:27.887503 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:28.657003 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:29.373102 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:30.028062 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:30.639215 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:31.325618 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:31.940695 DEBUG TestApp: Button pressed: 3003
2020-01-15 11:41:49.898636 DEBUG TestApp: Button pressed: 3001
2020-01-15 11:41:49.903056 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:50.608351 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:51.199628 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:51.807347 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:52.370844 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:52.942696 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:53.513134 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:54.090435 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:54.672488 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:55.250206 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:55.823539 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:41:56.457541 DEBUG TestApp: Button pressed: 3003
2020-01-15 11:43:01.596561 DEBUG TestApp: Button pressed: 1002
2020-01-15 11:43:01.600384 DEBUG TestApp: call_service: media_player/media_play_pause, {'entity_id': 'media_player.stereo'}
2020-01-15 11:43:06.790384 DEBUG TestApp: Button pressed: 1004
2020-01-15 11:43:06.799485 DEBUG TestApp: call_service: media_player/media_next_track, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:10.720138 DEBUG TestApp: Button pressed: 2001
2020-01-15 11:45:10.725931 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:11.408946 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:12.000536 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:12.604645 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:13.235559 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:13.835192 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:14.434869 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:15.032701 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:15.615484 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:16.212859 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:16.840714 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:17.486817 DEBUG TestApp: Button pressed: 2003
2020-01-15 11:45:18.345442 DEBUG TestApp: Button pressed: 3001
2020-01-15 11:45:18.351925 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:19.099811 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:19.713154 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:20.302320 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:20.896528 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:21.504112 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:22.103460 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:22.720531 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:23.317138 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:23.935701 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:24.521332 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 11:45:25.138419 DEBUG TestApp: Button pressed: 3003
mario-tux commented 4 years ago

In don't know if it matters but I switched to AppDaemon 4.

mario-tux commented 4 years ago

It looks that the sequences length is not related to the actual volume level: it looks fixed (11 commands). In other words, if I make three spinning-left gestures, I can see three separate sequences of n.11 volume_down commands. Each sequence is followed by the, in late, recognition of the stop event. See below the log. It looks a bug in app.

2020-01-15 11:54:22.685552 DEBUG TestApp: Button pressed: 2001
2020-01-15 11:54:22.691366 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:23.348764 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:23.944341 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:24.837603 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:25.484091 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:26.229951 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:27.065529 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:27.739341 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:28.319011 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:28.903832 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:29.483303 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:30.092496 DEBUG TestApp: Button pressed: 2003
2020-01-15 11:54:30.129275 DEBUG TestApp: Button pressed: 2001
2020-01-15 11:54:30.132919 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:30.704534 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:31.325084 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:31.958021 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:32.575383 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:33.176055 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:33.785980 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:34.359811 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:34.938685 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:35.556750 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:36.187506 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:36.826495 DEBUG TestApp: Button pressed: 2003
2020-01-15 11:54:36.863023 DEBUG TestApp: Button pressed: 2001
2020-01-15 11:54:36.867057 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:37.435221 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:38.009177 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:38.623753 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:39.223957 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:39.806878 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:40.392309 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:41.002310 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:41.581221 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:42.156628 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:42.723269 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 11:54:43.331984 DEBUG TestApp: Button pressed: 2003
xaviml commented 4 years ago

Hi @mario-tux,

Thanks for the feedback. The way the app is developed it requires different threads acting to the same instance. In AD 4.0 they added a new feature called 'app pinning' that allows threads to assign apps, so only 1 thread per app. This option comes by default in AD, since it is the recommended way.

The problem is that when I developed the app, I developed it for AD 3.x, so I wanted to make sure it worked for that version. Now that AD 3.0 addon is deprecated, I will have to migrate the code so it works with the default config of AD 4.0.

In the meantime, you have 2 options:

the pin_apps to false disables the fact that is 1 app 1 thread and the load_distribution makes sure that the messages are loaded in order, otherwise, you will see some rotation_left after a rotation_stop.

I hope this solves your issue in the meantime that I make the app work much efficient on AD 4.0. Also, let me know about the integration with the 5 button ikea controller when you have a chance to do so.

Thank you!

mario-tux commented 4 years ago

Hi @xaviml . Thanks for the internal detail on AppDaemon 4. I applied the suggested changes to my AD4:

---
secrets: /config/secrets.yaml
appdaemon:
  latitude: !secret home_latitude
  longitude: !secret home_longitude
  elevation: !secret home_elevation
  time_zone: !secret home_time_zone
  production_mode: false
  load_distribution: load
  pin_apps: false
  plugins:
    HASS:
      type: hass
http:
  url: http://127.0.0.1:5050
admin:
api:
hadashboard:

As bad news, this didn't change so much. Here the log:

2020-01-15 19:31:10.901428 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/modules/z2m_ikea_controller.py
2020-01-15 19:31:10.917634 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2020-01-15 19:31:10.928245 INFO AppDaemon: Initializing app TestApp using class E1744MediaPlayerController from module z2m_ikea_controller
2020-01-15 19:31:11.680459 INFO hello_world: Hello from AppDaemon
2020-01-15 19:31:11.699326 INFO hello_world: You are now ready to run Apps!
2020-01-15 19:31:11.718741 DEBUG TestApp: Calling listen_event for TestApp
2020-01-15 19:31:11.738039 INFO AppDaemon: App initialization complete
2020-01-15 19:31:19.590023 DEBUG TestApp: Button pressed: 3001
2020-01-15 19:31:19.593942 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:20.165013 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:20.739947 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:21.333918 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:21.903809 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:22.481499 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:23.063708 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:23.637532 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:24.227107 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:24.794727 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:25.364896 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:25.998748 DEBUG TestApp: Button pressed: 3003
2020-01-15 19:31:33.168062 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:31:33.174145 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:33.782126 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:34.383366 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:35.004289 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:35.599788 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:36.193704 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:36.816204 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:37.433953 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:38.027568 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:38.993652 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:39.668442 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:31:40.314675 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:32:09.818506 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:32:09.822927 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:10.468906 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:11.077606 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:11.647482 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:12.227449 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:12.806610 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:13.387910 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:13.965996 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:14.574289 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:15.245773 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:15.821845 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:32:16.460775 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:12.378461 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:12.383290 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:13.038000 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:13.623140 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:14.207669 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:14.818057 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:15.536531 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:16.272162 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:16.873929 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:17.489261 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:18.105455 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:18.676085 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:19.286937 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:21.546563 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:21.550629 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:22.120280 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:22.630653 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:22.763380 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:22.865538 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:23.413373 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:31.749414 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:31.754462 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:32.322134 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:32.515122 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:32.690754 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:36.966368 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:36.972706 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:37.548432 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:37.643836 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:37.768764 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:38.184809 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:42.724861 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:42.730275 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:43.281379 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:43.307730 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:43.460345 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:44.000425 DEBUG TestApp: Button pressed: 2003
2020-01-15 19:33:46.967358 DEBUG TestApp: Button pressed: 2001
2020-01-15 19:33:46.972144 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:47.557244 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:48.127993 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:48.728895 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:49.379307 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:49.983931 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:50.633495 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:51.241631 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:51.821201 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:52.421462 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:53.033249 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-15 19:33:53.768377 DEBUG TestApp: Button pressed: 2003

The first attempts were using single-rapid spin gesture: the behavior looks unchanged. In the following attempts (between 19:33:19 and 19:33:46) I used two rapid spin gestures: the app reaction is even stranger.

xaviml commented 4 years ago

Just for checking, but did you restart the appdaemon server/addon after the changes? @mario-tux

mario-tux commented 4 years ago

Just for checking, but did you restart the appdaemon server/addon after the changes? @mario-tux

Yes, I did. It looks I can send one/two volume_down/up making two rapid spin gestures. A single isolated gesture trigger the 11-command sequence.

xaviml commented 4 years ago

Hi @mario-tux

Sorry for the problems you are having. I just migrated all the code with the support of async programming, this means that works with the recommended configuration for appdaemon. You can try to remove the two lines of code I mentioned and restart the addon/server.

I have tried the app with the E1744 for a light and for a media_player (google home speaker) with zigbee2mqtt. They both worked now as they did before with AD 3.x. I changed the default delay to 1s for the E1744 media player controller. Let me know if you have any problems with it.

Thank you for your help!

mario-tux commented 4 years ago

@xaviml, thank you for your effort. I'll carry on some testing this night/tomorrow.

xaviml commented 4 years ago

Thanks @mario-tux,

Dresden Elektronik, the company behind deConz, messaged me this morning telling me that they will support me with a free ConBee II, so once I have it I will be able to do the testing as well.

mario-tux commented 4 years ago

Thanks @mario-tux,

Dresden Elektronik, the company behind deConz, messaged me this morning telling me that they will support me with a free ConBee II, so once I have it I will be able to do the testing as well.

Oh, great! They are recognizing your efforts.

mario-tux commented 4 years ago

Hi @xaviml. I've just tested your recent changes. It works better and it looks to manage well the single spin events. On the other side I have to say that sometimes, using multiple spins (rapidly executed) in the same verse: the long sequence of commands volume_up/down start without and ending event. It looks that the app is missing the stop event or it could be a bug of deconz.

At this point I think it is worthy to wait the arrival of your conbee II usb key to get a direct feedback on the app behavior. In any case I'm available to test further changes.

A log with the new changes:

2020-01-16 21:56:21.485999 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2020-01-16 21:56:21.708173 INFO HASS: HASS Plugin Initializing
2020-01-16 21:56:21.710389 INFO HASS: HASS Plugin initialization complete
2020-01-16 21:56:21.714591 INFO AppDaemon: Initializing HTTP
2020-01-16 21:56:21.718045 INFO AppDaemon: Using 'ws' for event stream
2020-01-16 21:56:21.817350 INFO AppDaemon: Starting API
2020-01-16 21:56:21.856972 INFO AppDaemon: Starting Admin Interface
2020-01-16 21:56:21.860620 INFO AppDaemon: Starting Dashboards
2020-01-16 21:56:21.946803 INFO HASS: Connected to Home Assistant 0.104.0
2020-01-16 21:56:22.117195 INFO AppDaemon: App 'hello_world' added
2020-01-16 21:56:22.120801 INFO AppDaemon: App 'TestApp' added
2020-01-16 21:56:22.126802 INFO AppDaemon: Found 2 total apps
2020-01-16 21:56:22.130752 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2020-01-16 21:56:22.141118 INFO AppDaemon: Running on port 5050
2020-01-16 21:56:22.365831 INFO HASS: Evaluating startup conditions
2020-01-16 21:56:22.523717 INFO AppDaemon: Got initial state from namespace default
2020-01-16 21:56:24.182650 INFO AppDaemon: Scheduler running in realtime
2020-01-16 21:56:24.222916 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2020-01-16 21:56:24.225980 INFO AppDaemon: Adding /config/appdaemon/apps/modules to module import path
2020-01-16 21:56:24.229312 INFO AppDaemon: Adding /config/appdaemon/apps/apps to module import path
2020-01-16 21:56:24.273810 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/modules/tradfri_remote.py - ignoring
2020-01-16 21:56:24.284643 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/modules/deconz_symfonisk_remote.py - ignoring
2020-01-16 21:56:24.292758 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/modules/tradfri.py - ignoring
2020-01-16 21:56:24.299754 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/modules/hello.py
2020-01-16 21:56:24.344555 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/modules/dimmer.py - ignoring
2020-01-16 21:56:24.352293 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/modules/z2m_ikea_controller.py
2020-01-16 21:56:24.379938 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2020-01-16 21:56:24.390205 INFO AppDaemon: Initializing app TestApp using class E1744MediaPlayerController from module z2m_ikea_controller
2020-01-16 21:56:25.138283 INFO hello_world: Hello from AppDaemon
2020-01-16 21:56:25.147524 INFO hello_world: You are now ready to run Apps!
2020-01-16 21:56:25.165559 DEBUG TestApp: Calling listen_event for TestApp
2020-01-16 21:56:25.178910 INFO AppDaemon: App initialization complete
2020-01-16 21:57:31.806288 DEBUG TestApp: Button pressed after: 1002
2020-01-16 21:57:31.830934 DEBUG TestApp: call_service: media_player/media_play_pause, {'entity_id': 'media_player.stereo'}
2020-01-16 21:57:41.441889 DEBUG TestApp: Button pressed after: 1004
2020-01-16 21:57:41.461207 DEBUG TestApp: call_service: media_player/media_next_track, {'entity_id': 'media_player.stereo'}
2020-01-16 21:57:46.013035 DEBUG TestApp: Button pressed after: 1005
2020-01-16 21:57:46.038575 DEBUG TestApp: call_service: media_player/media_previous_track, {'entity_id': 'media_player.stereo'}
2020-01-16 21:57:51.078009 DEBUG TestApp: Button pressed after: 2001
2020-01-16 21:57:51.082708 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:57:51.318065 DEBUG TestApp: Button pressed after: 2003
2020-01-16 21:57:57.219280 DEBUG TestApp: Button pressed after: 2001
2020-01-16 21:57:57.224452 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:57:57.405988 DEBUG TestApp: Button pressed after: 2003
2020-01-16 21:58:01.707791 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:01.712817 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:01.888000 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:06.163996 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:06.168689 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:06.455525 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:06.737242 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:06.742388 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:06.924701 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:16.596671 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:16.603013 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:17.047677 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:21.200489 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:21.205417 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:21.479086 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:26.953576 DEBUG TestApp: Button pressed after: 2001
2020-01-16 21:58:26.958027 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:27.264593 DEBUG TestApp: Button pressed after: 2003
2020-01-16 21:58:27.662386 DEBUG TestApp: Button pressed after: 2001
2020-01-16 21:58:27.667186 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:27.960636 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:28.668468 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:28.966723 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:29.672396 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:29.970845 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:30.675313 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:30.973597 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:31.677287 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:31.977985 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:32.681564 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:32.981636 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:39.986958 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:40.233027 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:46.368264 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:46.373721 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:47.195890 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:51.307947 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:51.312582 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:51.551745 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:51.783283 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:51.787382 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:52.050628 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:58:57.147793 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:58:57.155364 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:58:57.424042 DEBUG TestApp: Button pressed after: 3003
2020-01-16 21:59:04.267981 DEBUG TestApp: Button pressed after: 3001
2020-01-16 21:59:04.272141 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:59:05.274144 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:59:06.277169 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:59:07.280561 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:59:08.283518 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:59:09.286979 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 21:59:10.288868 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
xaviml commented 4 years ago

Good to know that it works better now. The way is done, the volume will be go down or up as long as stop is not triggered, if the stop is not triggered, then the loop will be called 10 times tops (to avoid infinite loop). So I think what is happening is expected, although is not desired.

When you have time, let me know about the E1810 (5 buttons) controller. Just to know that the mapping is correct and the device works. With this, I will close this issue.

Thank you for your contribution @mario-tux

mario-tux commented 4 years ago

Good to know that it works better now. The way is done, the volume will be go down or up as long as stop is not triggered, if the stop is not triggered, then the loop will be called 10 times tops (to avoid infinite loop). So I think what is happening is expected, although is not desired.

Yes, that was my understanding on the way the volume-up or down was managed, but the main question is why the app is missing the stop event: a problem of the app or a bug of deconz?

xaviml commented 4 years ago

@mario-tux If you rotate (left or right) for 2 seconds and stop, does the stop event get fired? Or this happens only when you move left and right quickly?

mario-tux commented 4 years ago

I did some tests:

At the end also a strange volume_up/volume_down mixed action happened... :-)

2020-01-16 22:26:34.451995 INFO AppDaemon: Python version is 3.8.1
2020-01-16 22:26:34.453655 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2020-01-16 22:26:34.455423 INFO AppDaemon: Added log: AppDaemon
2020-01-16 22:26:34.457138 INFO AppDaemon: Added log: Error
2020-01-16 22:26:34.458865 INFO AppDaemon: Added log: Access
2020-01-16 22:26:34.460632 INFO AppDaemon: Added log: Diag
2020-01-16 22:26:34.586458 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2020-01-16 22:26:34.766287 INFO HASS: HASS Plugin Initializing
2020-01-16 22:26:34.769080 INFO HASS: HASS Plugin initialization complete
2020-01-16 22:26:34.774197 INFO AppDaemon: Initializing HTTP
2020-01-16 22:26:34.777830 INFO AppDaemon: Using 'ws' for event stream
2020-01-16 22:26:34.869394 INFO AppDaemon: Starting API
2020-01-16 22:26:34.912437 INFO AppDaemon: Starting Admin Interface
2020-01-16 22:26:34.916241 INFO AppDaemon: Starting Dashboards
2020-01-16 22:26:35.013725 INFO HASS: Connected to Home Assistant 0.104.0
2020-01-16 22:26:35.554311 INFO AppDaemon: App 'hello_world' added
2020-01-16 22:26:35.558391 INFO AppDaemon: App 'TestApp' added
2020-01-16 22:26:35.567494 INFO AppDaemon: Found 2 total apps
2020-01-16 22:26:35.572197 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2020-01-16 22:26:35.582344 INFO AppDaemon: Running on port 5050
2020-01-16 22:26:35.712948 INFO HASS: Evaluating startup conditions
2020-01-16 22:26:35.886230 INFO AppDaemon: Got initial state from namespace default
2020-01-16 22:26:37.622000 INFO AppDaemon: Scheduler running in realtime
2020-01-16 22:26:37.645436 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2020-01-16 22:26:37.649184 INFO AppDaemon: Adding /config/appdaemon/apps/modules to module import path
2020-01-16 22:26:37.653008 INFO AppDaemon: Adding /config/appdaemon/apps/apps to module import path
2020-01-16 22:26:37.691195 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/modules/tradfri_remote.py - ignoring
2020-01-16 22:26:37.698110 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/modules/deconz_symfonisk_remote.py - ignoring
2020-01-16 22:26:37.705181 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/modules/tradfri.py - ignoring
2020-01-16 22:26:37.713039 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/modules/hello.py
2020-01-16 22:26:37.750577 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/modules/dimmer.py - ignoring
2020-01-16 22:26:37.757356 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/modules/z2m_ikea_controller.py
2020-01-16 22:26:37.780351 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2020-01-16 22:26:37.789835 INFO AppDaemon: Initializing app TestApp using class E1744MediaPlayerController from module z2m_ikea_controller
2020-01-16 22:26:38.460014 INFO hello_world: Hello from AppDaemon
2020-01-16 22:26:38.469435 INFO hello_world: You are now ready to run Apps!
2020-01-16 22:26:38.486130 DEBUG TestApp: Calling listen_event for TestApp
2020-01-16 22:26:38.498049 INFO AppDaemon: App initialization complete
2020-01-16 22:26:48.981926 DEBUG TestApp: Button pressed after: 1002
2020-01-16 22:26:49.003612 DEBUG TestApp: call_service: media_player/media_play_pause, {'entity_id': 'media_player.stereo'}
2020-01-16 22:26:56.343297 DEBUG TestApp: Button pressed after: 3001
2020-01-16 22:26:56.349107 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:26:57.350698 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:26:58.355621 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:26:58.653623 DEBUG TestApp: Button pressed after: 3003
2020-01-16 22:27:05.543262 DEBUG TestApp: Button pressed after: 2001
2020-01-16 22:27:05.548233 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:06.551472 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:06.666432 DEBUG TestApp: Button pressed after: 2003
2020-01-16 22:27:07.124034 DEBUG TestApp: Button pressed after: 2001
2020-01-16 22:27:07.129837 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:07.554152 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:07.704497 DEBUG TestApp: Button pressed after: 2003
2020-01-16 22:27:18.134119 DEBUG TestApp: Button pressed after: 3001
2020-01-16 22:27:18.139472 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:19.142165 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:20.147575 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:20.269600 DEBUG TestApp: Button pressed after: 3003
2020-01-16 22:27:28.541061 DEBUG TestApp: Button pressed after: 3001
2020-01-16 22:27:28.545503 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:28.835259 DEBUG TestApp: Button pressed after: 3003
2020-01-16 22:27:29.207253 DEBUG TestApp: Button pressed after: 3001
2020-01-16 22:27:29.211714 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:29.461626 DEBUG TestApp: Button pressed after: 3003
2020-01-16 22:27:34.553196 DEBUG TestApp: Button pressed after: 2001
2020-01-16 22:27:34.561453 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:34.632572 DEBUG TestApp: Button pressed after: 3001
2020-01-16 22:27:35.561611 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:36.566169 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:37.569644 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:38.573073 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:39.576499 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:40.579678 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:41.583387 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:42.590516 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:43.592170 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:44.595344 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:45.600588 WARNING AppDaemon: callback idle has now completed
2020-01-16 22:27:55.567044 DEBUG TestApp: Button pressed after: 2001
2020-01-16 22:27:55.841213 DEBUG TestApp: Button pressed after: 2003
2020-01-16 22:27:56.196169 DEBUG TestApp: Button pressed after: 2001
2020-01-16 22:27:56.200913 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:27:56.397870 DEBUG TestApp: Button pressed after: 2003
2020-01-16 22:28:00.941464 DEBUG TestApp: Button pressed after: 3001
2020-01-16 22:28:00.946112 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:01.072720 DEBUG TestApp: Button pressed after: 2001
2020-01-16 22:28:01.315942 DEBUG TestApp: Button pressed after: 2003
2020-01-16 22:28:01.536734 DEBUG TestApp: Button pressed after: 2001
2020-01-16 22:28:01.541855 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:01.947948 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:02.547562 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:02.951115 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:03.556953 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:03.953528 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:04.554889 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:04.955963 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:05.557476 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:05.958304 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:06.561247 DEBUG TestApp: call_service: media_player/volume_down, {'entity_id': 'media_player.stereo'}
2020-01-16 22:28:06.963373 DEBUG TestApp: call_service: media_player/volume_up, {'entity_id': 'media_player.stereo'}
xaviml commented 4 years ago

@mario-tux This is valuable, thanks! I see that when rotated left or right for 1 or 2 seconds, the behaviour is the expected one, I see that the stop event is fired. I will check on the quick movements again with the zigbee2mqtt to see if that happens and how it can be fixed.

mario-tux commented 4 years ago

When you have time, let me know about the E1810 (5 buttons) controller. Just to know that the mapping is correct and the device works. With this, I will close this issue.

Today I did some testing with my E1810 5 buttons control jointly with a color bulb (TRADFRI bulb E27 WS opal 1000lm). The center (toggle), up/down (click and holding) work well. I have a problem with left/right buttons to change color temperature but I guess it is related to a bug of deconz with the Ikea color bulbs. See https://github.com/dresden-elektronik/deconz-rest-plugin/issues/1861: in many occasions HA doesn't report neither color_temp nor color_xy so I guess your app can't work. For the rest, I think it is fine.

2020-01-17 14:45:01.215490 DEBUG TestLightApp: Button pressed after: 3001
2020-01-17 14:45:01.252164 DEBUG TestLightApp: Attribute: brightness; Current value: 1
2020-01-17 14:45:01.261687 DEBUG TestLightApp: call_service: homeassistant/turn_on, {'entity_id': 'light.nicoletta_light', 'brightness': 1, 'transition': 0.35}
2020-01-17 14:45:01.321845 DEBUG TestLightApp: Button pressed after: 3003
2020-01-17 14:45:02.081829 DEBUG TestLightApp: Button pressed after: 3002
2020-01-17 14:45:02.120191 DEBUG TestLightApp: Attribute: brightness; Current value: 1
2020-01-17 14:45:02.143099 DEBUG TestLightApp: call_service: homeassistant/turn_on, {'entity_id': 'light.nicoletta_light', 'brightness': 1, 'transition': 0.35}
2020-01-17 14:45:03.792046 DEBUG TestLightApp: Button pressed after: 1002
2020-01-17 14:45:03.813258 DEBUG TestLightApp: call_service: homeassistant/toggle, {'entity_id': 'light.nicoletta_light'}
2020-01-17 14:45:08.165693 DEBUG TestLightApp: Button pressed after: 1002
2020-01-17 14:45:08.186013 DEBUG TestLightApp: call_service: homeassistant/toggle, {'entity_id': 'light.nicoletta_light'}
2020-01-17 14:45:12.994577 DEBUG TestLightApp: Button pressed after: 4002
2020-01-17 14:45:13.007263 WARNING TestLightApp: ------------------------------------------------------------
2020-01-17 14:45:13.010792 WARNING TestLightApp: Unexpected error in worker for App TestLightApp:
2020-01-17 14:45:13.013984 WARNING TestLightApp: Worker Ags: {'id': '8a361501779a4b9c9b60c3ebbabf16f3', 'name': 'TestLightApp', 'objectid': 'a495470641d84666af7c201de109fe32', 'type': 'event', 'event': 'deconz_event', 'function': <bound method Controller.event_callback of <z2m_ikea_controller.E1810Controller object at 0x75156c58>>, 'data': {'id': 'nicoletta_switch', 'unique_id': 'cc:cc:cc:ff:fe:df:39:a2', 'event': 4002}, 'pin_app': True, 'pin_thread': 2, 'kwargs': {'id': 'nicoletta_switch', '__thread_id': 'MainThread'}}
2020-01-17 14:45:13.016765 WARNING TestLightApp: ------------------------------------------------------------
2020-01-17 14:45:13.021784 WARNING TestLightApp: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 725, in async_worker
    await funcref(args["event"], data, args["kwargs"])
  File "/config/appdaemon/apps/modules/z2m_ikea_controller.py", line 106, in event_callback
    await self.handle_action(data["event"])
  File "/config/appdaemon/apps/modules/z2m_ikea_controller.py", line 116, in handle_action
    await action(*args)
  File "/config/appdaemon/apps/modules/z2m_ikea_controller.py", line 26, in _action_impl
    await method(self, *args, **kwargs)
  File "/config/appdaemon/apps/modules/z2m_ikea_controller.py", line 349, in click
    attribute = await self.get_attribute(attribute)
  File "/config/appdaemon/apps/modules/z2m_ikea_controller.py", line 315, in get_attribute
    raise ValueError(
ValueError: This light does not support xy_color or color_temp
2020-01-17 14:45:13.024794 WARNING TestLightApp: ------------------------------------------------------------
xaviml commented 4 years ago

Hi @mario-tux,

As the error suggest, the light bulb does not support either xy_color or color_temp. So if you go to HA and click to the light, can you change the color temperature from there?

I see that according to the Ikea catalog it does no support color temperature, since it does not say anything about it, just brightness. So, I think is not a deConz issue, it's a hardware issue.

Thank you anyway for letting me know. With this, I will close the issue, we can open another if needed. I will check upon the symfonisk controller once I have the ConBee II as well.

mario-tux commented 4 years ago

As the error suggest, the light bulb does not support either xy_color or color_temp. So if you go to HA and click to the light, can you change the color temperature from there?

Yes, I can change the color from the web interface of HA and Deconz so it supports it.

I see that according to the Ikea catalog it does no support color temperature, since it does not say anything about it, just brightness.

I did a quick and weird copy&paste of the model from the Deconz web interface so maybe it was the wrong one.

Anyway it is a known bug of Deconz (see reference above) and unrelated with your software.

Thank you anyway for letting me know. With this, I will close the issue, we can open another if needed. I will check upon the symfonisk controller once I have the ConBee II as well.

Ok, great.

Another question: sorry to dirty this thread but I don't know where ask (mail, another report/question?). Is it possible to override some o all the actions of the app? For example: I want to map the remote control on a media_player but I want to override the volume_up/volume_down methods used by the app to something else (as a HA service call). Can I do this in app or should I create another media_player template combining the desired method and to control it with your app? I hope it is clear enough...

xaviml commented 4 years ago

Another question: sorry to dirty this thread but I don't know where ask (mail, another report/question?). Is it possible to override some o all the actions of the app? For example: I want to map the remote control on a media_player but I want to override the volume_up/volume_down methods used by the app to something else (as a HA service call). Can I do this in app or should I create another media_player template combining the desired method and to control it with your app? I hope it is clear enough...

Right now, this is not supported, all devices and their actions are defined on the python code with internal functions. However, it wouldn't be a bad idea to create a CustomController type to map actions and services together.

I don't exactly know what you are looking for, but I just merged a PR (#11) from @EPMatt that allows the E1810 to work as a Media player controller.

mario-tux commented 4 years ago

Right now, this is not supported, all devices and their actions are defined on the python code with internal functions. However, it wouldn't be a bad idea to create a CustomController type to map actions and services together.

Do you mean that, in order to personalize the actions, one should change the python code or the app parameters? The second would be cool.

I don't exactly know what you are looking for

Just to let you understand what I would do: I got an audio home theater connected with a raspberry pi (kodi) and with a chromecast audio. Depending on the service I want to use (audio or TV) I need to change the volume of the HT (I'm using an ESP8266 to send IR signal to the old HT). Having the possibility to map the single volume_up/down to some custom HA services would allow more freedom. Probably I could approach the same problem creating a third media_player template that merge the undergoing devices/media_players. Just an idea.

xaviml commented 4 years ago

Do you mean that, in order to personalize the actions, one should change the python code or the app parameters? The second would be cool.

The purpose of this app since the beginning is to provide the logic you lose on the devices when getting rid off the official hubs. Zigbee2mqtt + Home Assistant is great, it allows to integrate the devices, but it does not add the logic of the controller over the lights for example. So right now, we can easily integrate new devices through python. However, as I said, I think is a good idea to allow the users to map actions with home assistant services. I will create a new task for that, thank you for the suggestion @mario-tux