home-assistant-ecosystem/home-assistant-cli

hass-cli not working, please help

Closed this issue · 2 comments

Hi everybody,

I am trying to change my workflow to hass-cli (while it's currently handled by a spaghetticode bash script I made myself).


EDIT / UPDATE

I first had hass-cli installed through pip3 install hass-cli; I uninstalled it and made sure there was no /usr/bin/hass-cli, then cloned this repo and ran pip3 install --editable .. Then there was a fresh hass-cli, which still produces the same errors as described below.


I installed it according to the docs, then exported the correct values:

echo $HASS_TOKEN
<<my-token>>

➜ echo $HASS_SERVER
http://192.168.100.217:8123
➜ hass-cli --version
hass-cli, version 0.9.6

When I run hass-cli info, I get this

➜ hass-cli info
/home/me/.local/lib/python3.10/site-packages/zeroconf/_services/browser.py:179: FutureWarning: <homeassistant_cli.config._ZeroconfListener object at 0x7fe44c9bcb80> 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...
Trying to locate Home Assistant on local network...
^C
critical: Aborted!

Which I then eventually abort.

I also tried hass-cli --server="http://192.168.100.217:8123" --token="<<my-token>>" info, which will return

error: HomeAssistantCliError: Unexpected error retrieving information
Run with -x to see full exception information

and with -x

404 Client Error: Not Found for url: http://192.168.100.217:8123/api/discovery_info
Traceback (most recent call last):
  File "/home/ben/.local/lib/python3.10/site-packages/homeassistant_cli/cli.py", line 40, in run
    result = cli.main(standalone_mode=False)
  File "/home/ben/.local/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/ben/.local/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ben/.local/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ben/.local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/ben/.local/lib/python3.10/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/ben/.local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/ben/.local/lib/python3.10/site-packages/homeassistant_cli/plugins/info.py", line 28, in cli
    [api.get_info(ctx)],
  File "/home/ben/.local/lib/python3.10/site-packages/homeassistant_cli/remote.py", line 329, in get_info
    req.raise_for_status()
  File "/home/ben/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://192.168.100.217:8123/api/discovery_info

I checked, and, indeed, there is no http://192.168.100.217:8123/api/discovery_info; however, the general URL is correct. I mean that I can access http://192.168.100.217:8123 without any problems. There just isn't the /api/discovery_info, for some reason.

This is hass OS, the most current stable version. I have another Home Assistant instance on my home server in a docker container; that one also doesn't have the /api/discovery_info when I try to access that through my browser.

Just to be safe, I just generated a new token, exported it, tested it (echo $HASS_TOKEN will show the newly crated token), and tried to run again. It will give me the same error as above.

I don't know if this matters, but my desktop is on 10.0.0.0/24 while hass OS is on 192.168.100.0/24; however, I can still access the webUI, and even my crappy bash script is able to access it - so why won't hass-cli?

(you might say, just stick to your script then... but that thing is really really bad and I'd prefer your solution, if possible)

What can I do to fix this? Thank you in advance for your help :)

fabaff commented

info will be removed, see #388

The same error will appear when running other commands, for example hass-cli area list or hass-cli system health.

It is not limited to hass-cli info.