controllerx
controllerx copied to clipboard
[QUESTION] Help needed debug, Unexpected error running initialize()
Question
Hi, today I found this enty in the logs but the switch is working anyway. Could you tell me why get this error?
Additional information
- AppDaemon version: Current version: 0.9.3 (Changelog)
- ControllerX version: [4.23.0b1]
- HACS version (if installed from there): [ 1.27.2]
- Home Assistant Core version: [ 2022.8.7 ]
AppDaemon app configuration
hall_top_2_remote:
module: controllerx
class: SwitchController
integration: state
controller: binary_sensor.top_2_mutual_shellyi3_remote
previous_state:
"on": "off"
"off": "on"
mapping:
action: toggle
service: script.turn_off_all_lights
Logs
2022-09-12 09:53:44.713008 INFO hall_top_2_remote: 🎮 ControllerX v4.23.0b1
2022-09-12 09:53:44.713705 WARNING hall_top_2_remote: ------------------------------------------------------------
2022-09-12 09:53:44.714326 WARNING hall_top_2_remote: Unexpected error running initialize() for hall_top_2_remote
2022-09-12 09:53:44.714999 WARNING hall_top_2_remote: ------------------------------------------------------------
2022-09-12 09:53:44.716078 WARNING hall_top_2_remote: Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/appdaemon/app_management.py", line 163, in initialize_app
await init()
File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 104, in initialize
await self.init()
File "/config/appdaemon/apps/controllerx/cx_core/type_controller.py", line 54, in init
raise ValueError(
ValueError: SwitchController class needs the `switch` attribute
2022-09-12 09:53:44.716652 WARNING hall_top_2_remote: ------------------------------------------------------------
Hi @jaddel ,
A SwitchController is meant to be used to control a switch, so a "switch" attribute is required. You can either use a "Controller" (instead of "SwitchController"), or add the script entity in the switch attribute:
switch: script.your_script
And remove the service: script.... line.
Regards, Xavi M.
I answer you this morning with the phone and it was difficult to copy and paste. These are the 2 options you have:
- Use
Controllerclass:
hall_top_2_remote:
module: controllerx
class: Controller
integration: state
controller: binary_sensor.top_2_mutual_shellyi3_remote
previous_state:
"on": "off"
"off": "on"
mapping:
"on":
service: script.turn_off_all_lights
"off":
service: script.turn_off_all_lights
- Add
switchattribute and removeservice:
hall_top_2_remote:
module: controllerx
class: SwitchController
integration: state
controller: binary_sensor.top_2_mutual_shellyi3_remote
switch: script.turn_off_all_lights
previous_state:
"on": "off"
"off": "on"
mapping:
"on": "on"
"off": "on"
These second one will call the homeassistant.toggle service with entity_id as script.turn_off_all_lights. Whereas the first one will call the script.turn_off_all_lights service. Both configurations should do the same and no error should be preset in the logs.
Note that no matter if the binary_sensor.top_2_mutual_shellyi3_remote is on or off, it will trigger the script in both configurations. I assumed that is what you wanted.
Regards, Xavi M.
Hello Xaviml,
sorry for coming back this late. Thank you for the as always very detailed and direct solution! It's exactly what I was looking for. I'll close the question. :)