hassio-addons / addon-appdaemon

AppDaemon4 - Home Assistant Community Add-ons
https://addons.community
MIT License
149 stars 46 forks source link

InvalidURL exception since 0.12.0 #251

Closed EddyK69 closed 1 year ago

EddyK69 commented 1 year ago

Problem/Motivation

Since update to 0.12.0, errors in logfile 'InvalidURL Exception'

2023-04-12 17:06:37.120005 INFO HASS: Previous message repeated 1 times
2023-04-12 17:06:37.120438 ERROR HASS: Unexpected error during call_plugin_service()
2023-04-12 17:06:37.121042 ERROR HASS: Service: default.template.render Arguments: {'template': '\ue59a{{state_attr("sun.sun", "next_setting")|as_timestamp|timestamp_custom("%H:%M")}}'}
2023-04-12 17:06:37.121357 ERROR HASS: ------------------------------------------------------------
2023-04-12 17:06:37.122169 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-12 17:06:37.122447 ERROR HASS: ------------------------------------------------------------

Expected behavior

Rendering the given template without errors: {'template': '\ue59a{{state_attr("sun.sun", "next_setting")|as_timestamp|timestamp_custom("%H:%M")}}'} Rollback to 0.11.0 fixed the issue, so I should expect it is introduced by 0.12.0

Actual behavior

Rendering not working, see errorlog above

Steps to reproduce

(How can someone else make/see it happen)

Proposed changes

(If you have a proposed change, workaround or fix, describe the rationale behind it)

frenck commented 1 year ago

duplicate of #250

joBr99 commented 1 year ago

You can configure the following command in the appdaemon addon settings, until there is a fixed version of appdaemon released.

sed -i 's:"/api/template":f"{self.ha_url}/api/template":g' /usr/lib/python3.10/site-packages/appdaemon/plugins/hass/hassplugin.py

image

frenck commented 1 year ago

That is modifying signed sources and thus not recommend or supported. It may cause issues and even may cause HA to consider your whole system as unsuported dur to source modifications.

If this upstream bug causes an issue for your use case, please downgrade to the previous version using the backup that is created on upgrading the addon.

../Frenck