home-assistant-ecosystem / home-assistant-cli

:computer: Command-line tool for Home Assistant
Other
428 stars 63 forks source link

zeroconf error #383

Open kurtjy opened 2 years ago

kurtjy commented 2 years ago

Hi, currently not able to get this working. I had to downgrade click as well, after that I still get this error:


hass-cli info
/home/kurt/.local/lib/python3.9/site-packages/zeroconf/_services/browser.py:168: FutureWarning: <homeassistant_cli.config._ZeroconfListener object at 0x7f52920d7310> has no update_service method. Provide one (it can be empty if you don't care about the updates), it'll become mandatory.
  warnings.warn(
Trying to locate Home Assistant on local network...
Trying to locate Home Assistant on local network...
Trying to locate Home Assistant on local network...
Found and using https://1nkav000<redacted>0000e78u.ui.nabu.casa as server
error: HTTPError: 404 Client Error: Not Found for url: https://1nkav0000000000000000078u.ui.nabu.casa/api/discovery_info
Run with -x to see full exception information

I have updated HA to latest version.

I'm not sure why cli is trying to use my nabucasa url. Is that the setup? the cert on my HA are self signed, but I can get further with --insecure switch

hass-cli -x --insecure info
/home/kurt/.local/lib/python3.9/site-packages/zeroconf/_services/browser.py:168: FutureWarning: <homeassistant_cli.config._ZeroconfListener object at 0x7fbe2923de50> has no update_service method. Provide one (it can be empty if you don't care about the updates), it'll become mandatory.
  warnings.warn(
Trying to locate Home Assistant on local network...
Trying to locate Home Assistant on local network...
Trying to locate Home Assistant on local network...
Found and using https://1nka0000000000000000ee78u.ui.nabu.casa as server
404 Client Error: Not Found for url: https://1nka0000000000000000078u.ui.nabu.casa/api/discovery_info
Traceback (most recent call last):
  File "/home/kurt/.local/lib/python3.9/site-packages/homeassistant_cli/cli.py", line 40, in run
    result = cli.main(standalone_mode=False)
  File "/home/kurt/.local/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/kurt/.local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/kurt/.local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/kurt/.local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/kurt/.local/lib/python3.9/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/kurt/.local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/kurt/.local/lib/python3.9/site-packages/homeassistant_cli/plugins/info.py", line 28, in cli
    [api.get_info(ctx)],
  File "/home/kurt/.local/lib/python3.9/site-packages/homeassistant_cli/remote.py", line 316, in get_info
    req.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://1nka0000000000000000ee78u.ui.nabu.casa/api/discovery_info

Kind Regards,

EDIT: After reading a bit further, I noticed I had zeroconf disabled in configuration.yaml, but even after re-enable + reboot no avail..

ewmiter commented 2 years ago

I'm having a similar issue but i am running it locally and have a xfce4-panel running a script hass-cli service call scene.turn_on --arguments entity_id=scene.test I also downgraded click the CLI tool works perfectly from a terminal and from running the bash script Werd

Edit: I found the solution for my problem. all i needed to do is define HASS_SERVER and HASS_TOKEN Individually in each script.

fabaff commented 1 year ago

At first glance I would say, that there is a possible mixup of the URLs. As MDNS is used to get the details, something like the command below could give you some insight about what is published by your Home Assistant instance:

$ avahi-browse -art
= wlp2s1 IPv4 Home                                          _home-assistant._tcp local
   hostname = [38e..70.local]
   address = [fe80::fabc:722d:74f:1b5e]
   port = [8123]
   txt = ["requires_api_password=True" "base_url=http://192.168.1.20:8123" "internal_url=http://192.168.1.20:8123" "external_url=" "version=2022.9.7" "uuid=38e...0" "location_name=Home"]
[...]