appdaemon icon indicating copy to clipboard operation
appdaemon copied to clipboard

render_template broken with AppDaemon 4.4

Open droans opened this issue 3 years ago • 27 comments

What happened?

render_template is no longer working in the latest version.

Version

4.4.2

Installation type

Docker container

Relevant log output

ERROR HASS: Unexpected error during call_plugin_service()
ERROR HASS: Service: default.template.render Arguments: {'template': "{{ states('sun.sun') }}"}
ERROR HASS: ------------------------------------------------------------
ERROR HASS: Traceback (most recent call last):
  File "/usr/local/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/local/lib/python3.10/site-packages/aiohttp/client.py", line 508, in _request
    req = self._request_class(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 305, in __init__
    self.update_host(url)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 364, in update_host
    raise InvalidURL(url)
aiohttp.client_exceptions.InvalidURL: /api/template

Relevant code in the app or config file that caused the issue

class TestApp(AppBase):
    def initialize(self):

        template = "{{ states('sun.sun') }}"
        x = self.render_template(template)
        self.log(x)

Anything else?

No response

droans avatar Apr 11 '23 12:04 droans

just wanted to open the exact same issue :) with the 0.12.0 version of the HA Addon this now also hit HA OS Users

joBr99 avatar Apr 11 '23 16:04 joBr99

Thanks for reporting, I’ll take a look.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Johannes @.> Sent: Tuesday, April 11, 2023 12:36:38 PM To: AppDaemon/appdaemon @.> Cc: Subscribed @.***> Subject: Re: [AppDaemon/appdaemon] render_template broken with AppDaemon 4.4 (Issue #1747)

just wanted to open the exact same issue :) with the 0.12.0 version of the HA Addon this now also hit HA OS Users

— Reply to this email directly, view it on GitHubhttps://github.com/AppDaemon/appdaemon/issues/1747#issuecomment-1503742252, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLE7JFLRGMKFJF7JJPNQI3XAWCBNANCNFSM6AAAAAAW2GW5CQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

acockburn avatar Apr 12 '23 00:04 acockburn

I created a PR that hopefully resolves this issue.

Justihar avatar Apr 12 '23 23:04 Justihar

I created a PR that hopefully resolves this issue.

when will this come out or can it already be installed on home assistant?

jrspowers avatar Apr 13 '23 21:04 jrspowers

It is currently available in dev but I don't know when a release will be pushed out.

Justihar avatar Apr 13 '23 21:04 Justihar

It is currently available in dev but I don't know when a release will be pushed out.

can't go into dev mode ? or is that not possible?

jrspowers avatar Apr 13 '23 21:04 jrspowers

Just revert to the previous version ...

joBr99 avatar Apr 13 '23 21:04 joBr99

Just revert to the previous version ...

If only it were that easy it's not like choosing the previous version reinstalling just like on hacs this one has to be backed up that won't work for me I've been messing around today unfortunately otherwise I've done it a long time ago

jrspowers avatar Apr 13 '23 21:04 jrspowers

Thanks @joBr99, restoring previous AppDaemon backup has worked and nspanel-lovelace output now displays as expected.

brett-todd avatar Apr 13 '23 22:04 brett-todd

Thanks @joBr99, restoring previous AppDaemon backup has worked and nspanel-lovelace output now displays as expected.

yes I wanted to do that too but my backup says very long backup does not exist very unfortunate so I can't go back so wait for a new update

jrspowers avatar Apr 13 '23 22:04 jrspowers

@jrspowers You might be able to workaround by editing your local version of hassplugin.py and restarting the daemon with the following fix merged to dev:

image

brett-todd avatar Apr 13 '23 22:04 brett-todd

@jrspowers You might be able to workaround by editing your local version of hassplugin.py and restarting the daemon with the following fix merged to dev:

image

hello so if i understand correctly i need to put what in green & remove red & then restart appdaemon & then what about dev mode ? thanks

jrspowers avatar Apr 13 '23 22:04 jrspowers

hello so if i understand correctly i need to put what in green & remove red & then restart appdaemon & then what about dev mode ? thanks

Hi, I'm in the same situation so here is my hotfix:

  1. login to your home assistant vm ssh -p22222 root@<IP>
  2. After login grep the id of the appdaemon docker instance docker ps | grep appdaemon | awk '{ print $1}'
  3. Use the id to start a shell into this appdaemon docker instance docker exec -ti <docker-id> bash
  4. Inside the docker instance find the relevant file find / -iname "hassplugin.py"
  5. Edit the file with vi as shown here #1750 commit
  6. After saving the find the appdaemon process id and kill it kill $(ps aux | grep /usr/bin/appdaemon | grep -v grep | awk '{ print $1 }')
  7. Now the fixed version of appdaemon should be active and you can leave the docker instance via Ctrl-D

xiconfjs avatar Apr 13 '23 23:04 xiconfjs

Yes, don't worry about "dev" comment as just referring to this fix being pushed into the AppDaemon dev branch. This manual local adjustment will get overwritten when next version of AppDaemon is released.

Please see @xiconfjs much more detailed explanation above

brett-todd avatar Apr 13 '23 23:04 brett-todd

Hi, I'm in the same situation so here is my hotfix:

login to your home assistant vm ssh -p22222 root@ After login grep the id of the appdaemon docker instance docker ps | grep appdaemon | awk '{ print $1}' Use the id to start a shell into this appdaemon docker instance docker exec -ti bash Inside the docker instance find the relevant file find / -iname "hassplugin.py" Edit the file with vi as shown here #1750 commit After saving the find the appdaemon process id and kill it kill $(ps aux | grep /usr/bin/appdaemon | grep -v grep | awk '{ print $1 }') Now the fixed version of appdaemon should be active and you can leave the docker instance via Ctrl-D

everything first thanks for this nice explanation but I have a few questions 1 I don't have it running in docker but in ha itself 2 who log in to ssh via login & password that I always use to mean ssh or the ones you put here?
3 where can I find that ID? thanks in advance!

jrspowers avatar Apr 13 '23 23:04 jrspowers

everything first thanks for this nice explanation but I have a few questions 1 I don't have it running in docker but in ha itself

perhaps I'm mistaken, but usually all addons are running in separated docker containers with running inside the ha vm

2 who log in to ssh via login & password that I always use to mean ssh or the ones you put here?

for accessing the home assistant vm via ssh (and not the ssh addon container) follow this guide

3 where can I find that ID? thanks in advance!

the "docker-id" can be found with the command I posted before and here again: docker ps | grep appdaemon | awk '{ print $1}'

If you have further questions, it would be better to discuss this outside of this issue.

xiconfjs avatar Apr 13 '23 23:04 xiconfjs

everything first thanks for this nice explanation but I have a few questions

1 I don't have it running in docker but in ha itself

perhaps I'm mistaken, but usually all addons are running in separated docker containers with running inside the ha vm

2 who log in to ssh via login & password that I always use to mean ssh or the ones you put here?

for accessing the home assistant vm via ssh (and not the ssh addon container) follow this guide

3 where can I find that ID? thanks in advance!

the "docker-id" can be found with the command I posted before and here again:

docker ps | grep appdaemon | awk '{ print $1}'

If you have further questions, it would be better to discuss this outside of this issue.

okay i understand the benefit how can i contact you i think discord ? my name jarne#4016

jrspowers avatar Apr 13 '23 23:04 jrspowers

1 I don't have it running in docker but in ha itself

I think you are in the same boat as I am. My understanding is that if you are using HAOS, you can't access the individual addon docker containers.

masterfish1 avatar Apr 14 '23 07:04 masterfish1

I think you are in the same boat as I am. My understanding is that if you are using HAOS, you can't access the individual addon docker containers.

this could help: https://community.home-assistant.io/t/add-on-hassos-ssh-port-22222-configurator/264109

xiconfjs avatar Apr 14 '23 07:04 xiconfjs

this could help:

That did indeed help (after a bit of Googling on how to use vi and a large amount of PEBCAK). However, after setting up that addon, I wonder if it is needed as I still had to turn off Protection Mode on the HA SSH plugin. Perhaps turning off Protection Mode on its own would be sufficient.

Anyway, many thanks for offering a solution.

masterfish1 avatar Apr 14 '23 08:04 masterfish1