ControllerX. Bring full functionality to light and media player controllers

@Carlos_Luis I have it running in docker fine. What tag are you pulling? I’m using dev and it works well. I think it might not be happy with your ha_url and dash_url as I think it’s expecting http prefix. This is mine using HA and AppDameon in separate containers on the same machine

appdaemon:
  latitude: 12.23457
  longitude: -98.96543
  elevation: 200
  time_zone: America/Toronto
  threads: 10
  plugins:
    HASS:
      type: hass
      ha_url: 'http://192.168.20.10:8123'
      token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
hadashboard:
  dash_url: http://192.168.20.10:5050

@tube0013 I’ve got the Picos working PERFECTLY using this configuration:

PicoTestRemote:
  module: controllerx
  class: CustomLightController
  integration: z2m
  controller: sensor.kids_bedroom_pico
  light: light.ikea_test_bulb
  mapping:
    "1": on_full_brightness
    "8": hold_brightness_up
    "2": set_half_brightness
    "16": hold_brightness_down
    "4": "off"
    "0": release
  smooth_power_on: true

I’ve put in a PR for non-custom support but it will work as is with the z2m integration and this config above.

Kudos to @xaviml !

1 Like

Hi, I would like to use the E1810 as follows:

Brightness up & down buttons to control/dim an Ikea bulb
The other three (middle toggle, <, >) to switch on/off other devices.

How can this be done?

You will need to set up a custom controller for each device you want controlled and then map those buttons to that device. You should have one appdaemon app for each device. See the docs on customcontrollers here

The key mappings vary for each integration (zha,deconz,z2m) and can be found here.

EDIT - fixed controllers doc link

1 Like

waauw great documentation, thnx

1 Like

Dear @sreknob thanks a lot for sharing your config with me. It help a little bit. But I’m still getting some issues.
Thanks as well @xaviml for your great support, although for me isn’t working yet, but I’m pretty sure I will get it soon :wink:

First I would like to explain you my setup:

  • Intel Nuc i3 8th generation with 8GB RAM running Ubuntu Server with Docker CE
  • I have HA up and running under docker with the following docker-compose.yaml file:

#####################3

version: '3'
services:
  homeassistant:
    container_name: home-assistant
    image: homeassistant/home-assistant:stable
    volumes:
      - /home/luiscarlos/dockerdisco2/volumes/ha-data:/config
#    devices:
#      - /dev/ttyUSB0:/dev/ttyUSB0
#     - /dev/ttyUSB1:/dev/ttyUSB1
#      - /dev/ttyACM0:/dev/ttyACM0
    environment:
      - TZ=Europe/Madrid
    restart: unless-stopped
    network_mode: host

  • Yes the USB devices are #commented because as far as I know I don’t need them in HA. But maybe I’m wrong with that.
  • I have the ConBee 2 as ZigBee USB Sniffer up and running under docker as well, hereby my docker-compose.yaml file:
  # Deconz

version: '3'
services:
  deconz:
    container_name: deconz_conbee
    image: marthoc/deconz
    restart: unless-stopped
    network_mode: host
    environment:
      # You can access Deconz at this port
      DECONZ_WEB_PORT: 8081
      DECONZ_WS_PORT: 8088

      # Set VNC_MODE to 0 to disable it completely
      DECONZ_VNC_MODE: 0
      DECONZ_VNC_PORT: 5900
      DECONZ_VNC_PASSWORD: "${VNC_PASSWORD}"
      TZ: "Europe/Amsterdam"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      # Replace <local path> with a path where all deconz config will be stored.
      - /home/luiscarlos/dockerdisco2/volumes/deCONZ-conbee:/root/.local/share/dresden-elektronik/deCONZ
    devices:
      - "/dev/ttyACM0:/dev/ttyACM0"

  • The docker-compose.yaml from my AppDaemon under docker:
appdaemon:
  container_name: AppDaemon
  restart: unless-stopped
  image: acockburn/appdaemon:latest
  environment:
    TZ: "Europe/Madrid"
    HA_URL: "3.0.0.232:8123"
    TOKEN: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjMGEzMzc4MjNhMWU0NmFmYmYzYWMyNzExOTdlMGQxYSIsImlhdCI6MTU4MjI3NTQ3NiwiZXhwIjoxODk3NjM1NDc2fQ.KvhquQEY6zjJJ_8tikYJDtm4XvjzseRT-614BfuiuqE"
    DASH_URL: "3.0.0.232:5050"
  ports:
    - "5050:5050"
  volumes:
    # Set which local directory will contain all your app daemon configuration
    - /home/luiscarlos/dockerdisco2/volumes/AppDaemon/conf:/conf
  • Here my AppDaemon/config/appdaemon.yam config file:
  • At this point, “http” before the my local IP of HA will be missed after closing the file and restart the docker container “AppDaemon”. Example: ha_url: http://3.0.0.232:8123 will be 3.0.0.232:8123
appdaemon:
  latitude: 40.4165001
  longitude: -3.7025599
  elevation: 667
  time_zone: Europe/Madrid
  threads: 10
  plugins:
    HASS:
      type: hass
      ha_url: 3.0.0.232:8123
      token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjMGEzMzc4MjNhMWU0NmFmYmYzYWMyNzExOTdlMGQxYSIsImlhdCI6MTU4MjI3NTQ3NiwiZXhwIjoxODk3NjM1NDc2fQ.KvhquQEY6zjJJ_8tikYJDtm4XvjzseRT-614BfuiuqE
hadashboard:
  dash_url: http://3.0.0.232:5050

  • If I open on my web browser http://3.0.0.232:5050 nothing happens. Should I see a web interface?
  • Here my /AppDaemon/conf/apps/apps.yaml config file:

#hello_world:
#  module: hello
#  class: HelloWorld

Luz_Mesa_Comedor_controller_IKEA_E1810:
  module: controllerx
  class: E1810Controller
  controller: controller_ikea
  integration: deconz
  light: light.mesa_comedor

  • With this setups: HA is working fine, deConz for my ConBee 2 USB ZigBee Sniffer is working good as well, but my container called AppDaemon is showing me the following error:

2020-02-25 17:12:42.437953 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds

  • Any Ideas?
    Thanks in advance
    Regards, Luis.

Hi @Carlos_Luis again,

I know that this error appears when AppDaemon could not connect to HA. This problem comes from ha_url or token.

How did you generate the token? Is it a Long-Lived Access Tokens?

Have you tried to put the http in the ha_url and also wrap it up between quotes (")?

Hi again as well @xaviml,

It is a Long-Lived Access Token:

Do you know another way to check if the token is a valid one?

Thanks again!

Once the token is created, there is no way to check if it’s correct. You could remove that one and create a new one. I would recommend you to wrap it between quotes as well, just in case.

@Carlos_Luis - change your docker compose for appdaemon to the dev tag and try again.

image: acockburn/appdaemon:dev

I looked and the appdaemon addon is pinned to 4.0.1 but they have some custom stuff going on to automatically set access to HA.

Just tried latest and 4.0.1 with my working config I posted earlier and I was getting errors. When I do a fresh pull with dev tag she fires up no problem. There must be some changes between them but I haven’t investigated it further yet. If it ain’t broke, don’t fix it, right?

Let me know how it goes!

EDIT
Two things I just noticed after looking at your config again.

  1. Generate a new access token and use that if you’ve posted your actual token! Not sure if you have external access set up, but better safe than sorry when it comes to passwords on public forums.

  2. I think the reason that your http:// keeps disappearing is because your docker-compose file re-writes your config on start with the “HA_URL” and “DASH_URL” that you use on the container start. To fix this, you need to change your docker compose to have the http:/// part.

appdaemon:
  container_name: AppDaemon
  restart: unless-stopped
  image: acockburn/appdaemon:dev
  environment:
    TZ: "Europe/Madrid"
    HA_URL: "http://3.0.0.232:8123"
    TOKEN: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjMGEzMzc4MjNhMWU0NmFmYmYzYWMyNzExOTdlMGQxYSIsImlhdCI6MTU4MjI3NTQ3NiwiZXhwIjoxODk3NjM1NDc2fQ.KvhquQEY6zjJJ_8tikYJDtm4XvjzseRT-614BfuiuqE"
    DASH_URL: "http://3.0.0.232:5050"
  ports:
    - "5050:5050"
  volumes:
    # Set which local directory will contain all your app daemon configuration
    - /home/luiscarlos/dockerdisco2/volumes/AppDaemon/conf:/conf

If you’re starting from a command line you may have to escape the URL to make it run but hopefully not.

Dear @sreknob thanks for try.
Here my results after testing with the following docker-compose.yaml:

appdaemon:
  container_name: AppDaemon
  restart: unless-stopped
  image: acockburn/appdaemon:dev
  environment:
    TZ: "Europe/Madrid"
    HA_URL: "3.0.0.232:8123"
    TOKEN: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjMGEzMzc4MjNhMWU0NmFmYmYzYWMyNzExOTdlMGQxYSIsImlhdCI6MTU4MjI3NTQ3NiwiZXhwIjoxODk3NjM1NDc2fQ.KvhquQEY6zjJJ_8tikYJDtm4XvjzseRT-614BfuiuqE"
    DASH_URL: "3.0.0.232:5050"
  ports:
    - "5050:5050"
  volumes:
    # Set which local directory will contain all your app daemon configuration
    - /home/luiscarlos/dockerdisco2/volumes/AppDaemon/conf:/conf

Before set up the new docker container I deleted the old one " image: acockburn/appdaemon:latest"

Unfortunately I’m still getting the same error with the following configuration:

appdaemon:
  latitude: 40.4165001
  longitude: -3.7025599
  elevation: 667
  time_zone: Europe/Madrid
  threads: 10
  plugins:
    HASS:
      type: hass
      ha_url: 3.0.0.232:8123
      token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjMGEzMzc4MjNhMWU0NmFmYmYzYWMyNzExOTdlMGQxYSIsImlhdCI6MTU4MjI3NTQ3NiwiZXhwIjoxODk3NjM1NDc2fQ.KvhquQEY6zjJJ_8tikYJDtm4XvjzseRT-614BfuiuqE
hadashboard:
  dash_url: "http://3.0.0.232:5050"

  • Error:
2020-02-25 21:58:19.709953 INFO AppDaemon: AppDaemon Version 4.0.2 starting


2020-02-25 21:58:19.710061 INFO AppDaemon: Python version is 3.8.1


2020-02-25 21:58:19.710140 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml


2020-02-25 21:58:19.710221 INFO AppDaemon: Added log: AppDaemon


2020-02-25 21:58:19.710307 INFO AppDaemon: Added log: Error


2020-02-25 21:58:19.710380 INFO AppDaemon: Added log: Access


2020-02-25 21:58:19.710454 INFO AppDaemon: Added log: Diag


2020-02-25 21:58:19.719642 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin


2020-02-25 21:58:19.724355 INFO HASS: HASS Plugin Initializing


2020-02-25 21:58:19.724465 INFO HASS: HASS Plugin initialization complete


2020-02-25 21:58:19.724705 INFO AppDaemon: HTTP is disabled


2020-02-25 21:58:19.726304 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 21:58:19.727144 WARNING AppDaemon: Threads directive is deprecated apps - will be pinned. Use total_threads if you want to unpin your apps


2020-02-25 21:58:19.729459 INFO AppDaemon: App 'Luz_Mesa_Comedor_controller_IKEA_E1810' added


2020-02-25 21:58:19.729808 INFO AppDaemon: Found 1 total apps


2020-02-25 21:58:19.729999 INFO AppDaemon: Starting Apps with 1 workers and 1 pins


2020-02-25 21:58:24.729450 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 21:58:29.732236 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 21:58:34.735566 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 21:58:39.738679 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
  • The following Loop repeats every 5" : 2020-02-25 21:58:39.738679 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds

I’m still a little bit lose. Don’t know why is not working yet.
Anyway, thanks for your help @sreknob @xaviml much appreciate it !!

@Carlos_Luis I see we were writing at the same time. See the updated docker-compose part.

And for posterity sake, I found the issue as to why mine is only loading with the dev branch.

Turns out there is an issue if the http interface isn’t loaded in the config. The two issues and related PRs to fix this are here and here. Looks like it will be in 4.0.2 though. Otherwise you can work around it by adding the missing http section with admin interface to appdaemon.yaml

1 Like

Ohhh Right! We’re writing in this forum at the same time.

Please don’t worry about my Token, I will create a new one after solve this issue. At the moment I have no ports open, everything works locally.

You’re right now the issue seems to be solved:

2020-02-25 22:21:20.534173 INFO AppDaemon: AppDaemon is stopped.


2020-02-25 22:21:22.277444 INFO AppDaemon: AppDaemon Version 4.0.2 starting


2020-02-25 22:21:22.277594 INFO AppDaemon: Python version is 3.8.1


2020-02-25 22:21:22.277684 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml


2020-02-25 22:21:22.277767 INFO AppDaemon: Added log: AppDaemon


2020-02-25 22:21:22.277862 INFO AppDaemon: Added log: Error


2020-02-25 22:21:22.277947 INFO AppDaemon: Added log: Access


2020-02-25 22:21:22.278029 INFO AppDaemon: Added log: Diag


2020-02-25 22:21:22.289289 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin


2020-02-25 22:21:22.296186 INFO HASS: HASS Plugin Initializing


2020-02-25 22:21:22.296319 INFO HASS: HASS Plugin initialization complete


2020-02-25 22:21:22.296606 INFO AppDaemon: HTTP is disabled


2020-02-25 22:21:22.299511 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 22:21:22.300949 WARNING AppDaemon: Threads directive is deprecated apps - will be pinned. Use total_threads if you want to unpin your apps


2020-02-25 22:21:22.315918 INFO AppDaemon: App 'Luz_Mesa_Comedor_controller_IKEA_E1810' added


2020-02-25 22:21:22.319649 INFO AppDaemon: Found 1 total apps


2020-02-25 22:21:22.319924 INFO AppDaemon: Starting Apps with 1 workers and 1 pins


2020-02-25 22:21:27.303008 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 22:21:32.305591 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 22:21:37.307707 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 22:21:42.309730 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 22:21:47.312246 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds


2020-02-25 22:21:52.321493 INFO HASS: Connected to Home Assistant 0.105.3


2020-02-25 22:21:52.656239 INFO HASS: Evaluating startup conditions


2020-02-25 22:21:52.662461 INFO AppDaemon: Got initial state from namespace default


2020-02-25 22:21:54.355986 INFO AppDaemon: Scheduler running in realtime


2020-02-25 22:21:54.358606 INFO AppDaemon: Adding /conf/apps to module import path


2020-02-25 22:21:54.360253 WARNING AppDaemon: No app description found for: /conf/apps/hello.py - ignoring


2020-02-25 22:21:54.361194 INFO AppDaemon: App initialization complete

I just restarted all my containers: HA, deConz, AppDaemon but my IKEA smart button doesn’t modify any light with the following set up under volumes/AppDaemon/conf/apps/app.yaml



#hello_world:
#  module: hello
#  class: HelloWorld

Luz_Mesa_Comedor_controller_IKEA_E1810:
  module: controllerx
  class: E1810Controller
  controller: controller_ikea
  integration: deconz
  light: light.mesa_comedor

@xaviml do you have an idea about it?

Thanks @sreknob again for your help and time! I’m everytime closer beacuse of your great help!
Thanks a lot again!

@Carlos_Luis - does your appdaemon log show your app Luz_Mesa_Comedor_controller_IKEA_E1810 being initialized?

Hey, now that I’ve learned about it and tried it – it looks like the http interface has a wealth of information that might be useful while troubleshooting. Add it to your config and see if it gives any clues.

http:
  url: http://3.0.0.232:5050
admin:

I think Luz_Mesa_Comedor_controller_IKEA_E1810 has been initailized. But I’m not completly sure. How can I check that and if not inizalize it?

By the way: why do we need this? DASH_URL: "http://3.0.0.232:5050" ??
If I try to copy and paste the URL http://3.0.0.232:5050 on my web browser nothing happens:

Thanks again @sreknob!

That’s because you don’t have any dashboards configured as you’ve commented out the helloworld app.
Turn on the admin interface and you will get it at that url - http://3.0.0.232:5050
To do that, add this to the bottom of your appdaemon.yaml file and restart appdaemon container

http:
  url: http://3.0.0.232:5050
admin:

Also, I’m not sure that the controller is loaded from your logs. Why is HA losing connection? Are you restarting it? If you controller is loaded you should see it under the Apps heading in the web interface.
You can also check that it’s seeing your HA instance by looking at the Entities section.

Now the admin interface is up and running. thanks a lot!
Unfortunately my IKEA smart button doesn’t work as desired, it seems it’s not inizialized becasue I don’t see it under my HA, wich yes I restarted together with AppDaemon just in case it may help.

Now that you have AppDaemon up and running, did you install ControllerX? if you install it through HACS, you will see it will be placed in /config/appdaemon/apps/contollerx/

If you go to Developer tools > event and start listening for deconz_event do you see anything there when pressing any button? If so, can you share what you see?

Yes! it was installed from the beginning, should I reinstall it again?

luiscarlos@luisnuc:~/dockerdisco2/volumes/ha-data/appdaemon/apps/controllerx$ ls
const.py  controllerx.py  core  devices
luiscarlos@luisnuc:~/dockerdisco2/volumes/ha-data/appdaemon/apps/controllerx$

What is the location of apps.yaml?