Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] AppDaemon 4.4.X broke templates #810

Closed
mogmix opened this issue Apr 15, 2023 · 7 comments
Closed

[BUG] AppDaemon 4.4.X broke templates #810

mogmix opened this issue Apr 15, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@mogmix
Copy link

mogmix commented Apr 15, 2023

Bug report

Description

Update of AppDaemon 4.2.2 to 4.4.X (they skipped 4.3.X) broke templates. I am using ControllerX 4.25.0.

The following snippet of the appdaemon/apps/apps.yaml file used to render and work, but now throws errors: scene.living_room_{{ states('input_select.living_room_light_state') }}.

AppDaemon Logs

2023-04-15 20:00:29.734254 INFO livingroom_controller: 🎮 Button event triggered: `arrow_right_click`
2023-04-15 20:00:29.738564 INFO livingroom_controller: 🏃 Running `Service (input_select.select_next)` now
2023-04-15 20:00:29.742079 INFO livingroom_controller: 
🤖 Service: input_select.select_next
  - entity_id: input_select.living_room_light_state
2023-04-15 20:00:29.746931 INFO livingroom_controller: 🏃 Running `Scene (scene.living_room_{{ states('input_select.living_room_light_state') }})` now
2023-04-15 20:00:29.749177 INFO livingroom_controller: 
🤖 Service: template.render
  - template: scene.living_room_{{ states('input_select.living_room_light_state') }}
  - return_result: True
2023-04-15 20:00:29.754605 ERROR HASS: ------------------------------------------------------------
2023-04-15 20:00:29.755151 ERROR HASS: Unexpected error during call_plugin_service()
2023-04-15 20:00:29.755683 ERROR HASS: Service: default.template.render Arguments: {'template': "scene.living_room_{{ states('input_select.living_room_light_state') }}"}
2023-04-15 20:00:29.756173 ERROR HASS: ------------------------------------------------------------
2023-04-15 20:00:29.756826 ERROR HASS: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/appdaemon/plugins/hass/hassplugin.py", line 556, in call_plugin_service
    r = await self.session.post(api_url, json=data)
  File "/usr/lib/python3.10/site-packages/aiohttp/client.py", line 508, in _request
    req = self._request_class(
  File "/usr/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 305, in __init__
    self.update_host(url)
  File "/usr/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 364, in update_host
    raise InvalidURL(url)
aiohttp.client_exceptions.InvalidURL: /api/template
2023-04-15 20:00:29.757306 ERROR HASS: ------------------------------------------------------------
2023-04-15 20:00:29.761435 WARNING livingroom_controller: ------------------------------------------------------------
2023-04-15 20:00:29.761923 WARNING livingroom_controller: Unexpected error in worker for App livingroom_controller:
2023-04-15 20:00:29.762546 WARNING livingroom_controller: Worker Ags: {'id': 'a2a0bf61895f4fc892d23e407727aa73', 'name': 'livingroom_controller', 'objectid': '9d08b32dd00a4141bf5e8e63ff18c67d', 'type': 'state', 'function': <bound method Z2MIntegration.state_callback of <cx_core.integration.z2m.Z2MIntegration object at 0x7f895ca2d060>>, 'attribute': 'state', 'entity': 'sensor.living_room_controller_action', 'new_state': 'arrow_right_click', 'old_state': '', 'pin_app': True, 'pin_thread': 1, 'kwargs': {'__thread_id': 'MainThread'}}
2023-04-15 20:00:29.763102 WARNING livingroom_controller: ------------------------------------------------------------
2023-04-15 20:00:29.763962 WARNING livingroom_controller: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/appdaemon/threading.py", line 908, in async_worker
    await funcref(
  File "/config/appdaemon/apps/controllerx/cx_core/integration/z2m.py", line 71, in state_callback
    await self.controller.handle_action(new, previous_state=old)
  File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 404, in handle_action
    await self.call_action(action_key, extra=extra)
  File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 478, in call_action
    await self.action_timer_callback({"action_key": action_key, "extra": extra})
  File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 516, in action_timer_callback
    await task
  File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 532, in call_action_types
    await action_type.run(extra=extra)
  File "/config/appdaemon/apps/controllerx/cx_core/action_type/scene_action_type.py", line 14, in run
    await self.controller.call_service("scene/turn_on", entity_id=self.scene)
  File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 357, in call_service
    attributes = await self.render_attributes(attributes)
  File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 345, in render_attributes
    new_value = await self.render_value(value)
  File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 338, in render_value
    return await self._render_template(value)
  File "/config/appdaemon/apps/controllerx/cx_core/controller.py", line 322, in _render_template
    raise ValueError(f"Template {template} returned None")
ValueError: Template scene.living_room_{{ states('input_select.living_room_light_state') }} returned None
2023-04-15 20:00:29.764518 WARNING livingroom_controller: ------------------------------------------------------------

I suspect this is related:

ControllerX. Bring full functionality to light and media player controllers - #1415 by mama_mia - AppDaemon - Home Assistant Community

AppDaemon Changelog is inconclusive:

https://appdaemon.readthedocs.io/en/latest/HISTORY.html#id3

@mogmix mogmix added the bug Something isn't working label Apr 15, 2023
xaviml added a commit that referenced this issue Apr 15, 2023
@xaviml
Copy link
Owner

xaviml commented Apr 15, 2023

Hi @mogmix,

You are correct, this seems to be an issue with AppDaemon, so there is not much I can do to accelerate the AppDaemon release with the fix (which is already in their dev branch).

However, I created PR #811 with a temporary fix from ControllerX side. I will remove related code once AppDaemon officially releases their fix.

Regards,
Xavi M.

@mogmix
Copy link
Author

mogmix commented Apr 15, 2023

Hi Xavi, thanks a lot for your effort! I was not sure, if its an inherent problem with AppDaemon, or if controllerX needs to adapt to sth.

Best, mogmix

@xaviml
Copy link
Owner

xaviml commented Apr 15, 2023

Hi @mogmix ,

Fix is now deployed in HACS: ControllerX v4.26.0.

I was not sure, if its an inherent problem with AppDaemon, or if controllerX needs to adapt to sth.

The problem is in AppDaemon, but I have added a patch to mitigate the problem.

Regards,
Xavi M.

@xaviml
Copy link
Owner

xaviml commented Apr 15, 2023

Hi @mogmix ,

I am having problems to use the patch with the AppDaemon addon, I will need to keep looking for a better solution.

Regards,
Xavi M.

@xaviml
Copy link
Owner

xaviml commented Apr 15, 2023

Hi again,

I just release ControllerX v4.26.1 with a fix for AppDaemon addon.

Let me know if it works for you.

Regards,
Xavi M.

@mogmix
Copy link
Author

mogmix commented Apr 15, 2023

Hi Xavi, the temp fix in v4.26.1 works. Great job! 👍

And thank you!

@xaviml
Copy link
Owner

xaviml commented Apr 19, 2023

ControllerX v4.26.2 should behave as before with AppDaemon 4.4.2 patch.

Closing this issue.

@xaviml xaviml closed this as completed Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants