Where is hass check_config?

I’m trying to debug a config using secrets.yaml. According to this page, I can run

hass --script check_config --secrets

Where is that command supposed to be run? I’m running Home Assistant OS 11.2. I connect with ssh root@homeassistant and there is no hass command. There is a command called ha but it doesn’t work with that same syntax.

1 Like

You can only run that if you have a core install.

Plus you must activate the Python virtual env HA is installed to.

Thank you. I forgot “core” is an installation method. I usually think of core as being the name of the main application, as in github.com/home-assistant/core. I got it figured out now.

What about HA OS?

No.

1 Like

:frowning:

Do you happen to know any other way to check YAML config (as in WebUI -> Developer Tools -> Yaml -> Check configuration) in CLI / over SSH?

ha core check

Unfortunately, it’s not…

Wow. That’s a bug. The CLI check is supposed to be more comprehensive than the GUI version.

1 Like

It seems the hass check_config is setup to run within the HA Core environment, so if you are running HAOS, if you can get into the homeassistant container, you can still run the hass check_config.

2 Likes

I am.

I’m a Docker noob (unless it’s LXC or something else… then I’m still noob :D).

I don’t know how to get into the “homeassistant container”…

If you have a console display/keyboard with direct access to HAOS linux kernel shell,
or if you have ssh -p22222 to HA setup which also give you access to HAOS linux kernel shell,
or if you have “Advanced SSH & Web Terminal” AddOn with protection turned off,
then you can enter the command: docker exec -it homeassistant /bin/bash

1 Like

Already tried docker:

➜  ~ ssh [email protected]

       ▄██▄           _   _                                    
     ▄██████▄        | | | | ___  _ __ ___   ___               
   ▄████▀▀████▄      | |_| |/ _ \| '_ ` _ \ / _ \              
 ▄█████    █████▄    |  _  | (_) | | | | | |  __/              
▄██████▄  ▄██████▄   |_| |_|\___/|_| |_| |_|\___|          _   
████████  ██▀  ▀██      / \   ___ ___(_)___| |_ __ _ _ __ | |_ 
███▀▀███  ██   ▄██     / _ \ / __/ __| / __| __/ _` | '_ \| __|
██    ██  ▀ ▄█████    / ___ \\__ \__ \ \__ \ || (_| | | | | |_ 
███▄▄ ▀█  ▄███████   /_/   \_\___/___/_|___/\__\__,_|_| |_|\__|
▀█████▄   ███████▀

Welcome to the Home Assistant command line.

System information
  IPv4 addresses for enp0s18: 192.168.1.204/24
  IPv6 addresses for enp0s18: fd04:fce0:1138::b20/128, fd04:fce0:1138:0:e117:c7c9:7c86:417c/64, fe80::e04b:8b69:13a6:5d8e/64

  OS Version:               Home Assistant OS 12.1
  Home Assistant Core:      2024.2.5

  Home Assistant URL:       http://homeassistant.local:8123
  Observer URL:             http://homeassistant.local:4357
[core-ssh ~]$ docker
-bash: docker: command not found
[core-ssh ~]$ docker exec -it homeassistant /bin/bash
-bash: docker: command not found
[core-ssh ~]$ 

That particular way of using ssh gets you into a “SSH” AddOn container, which differs from the HA Core container.

1 Like

I installed the “advanced” ssh addon and turned off “protection” → it works <3


       ▄██▄           _   _                                    
     ▄██████▄        | | | | ___  _ __ ___   ___               
   ▄████▀▀████▄      | |_| |/ _ \| '_ ` _ \ / _ \              
 ▄█████    █████▄    |  _  | (_) | | | | | |  __/              
▄██████▄  ▄██████▄   |_| |_|\___/|_| |_| |_|\___|          _   
████████  ██▀  ▀██      / \   ___ ___(_)___| |_ __ _ _ __ | |_ 
███▀▀███  ██   ▄██     / _ \ / __/ __| / __| __/ _` | '_ \| __|
██    ██  ▀ ▄█████    / ___ \\__ \__ \ \__ \ || (_| | | | | |_ 
███▄▄ ▀█  ▄███████   /_/   \_\___/___/_|___/\__\__,_|_| |_|\__|
▀█████▄   ███████▀

Welcome to the Home Assistant command line.

System information
  IPv4 addresses for enp0s18: 192.168.1.204/24
  IPv6 addresses for enp0s18: fd04:fce0:1138::b20/128, fd04:fce0:1138:0:e117:c7c9:7c86:417c/64, fe80::e04b:8b69:13a6:5d8e/64

  OS Version:               Home Assistant OS 12.1
  Home Assistant Core:      2024.2.5

  Home Assistant URL:       http://homeassistant.local:8123
  Observer URL:             http://homeassistant.local:4357
➜  ~ docker exec -it homeassistant /bin/bash
homeassistant:/config# time hass --script check_config -c /config
Testing configuration at /config
WARNING:homeassistant.components.device_tracker:SOURCE_TYPE_ROUTER was used from iphonedetect, this is a deprecated constant which will be removed in HA Core 2025.1. Use SourceType.ROUTER instead, please create a bug report at https://github.com/mudape/iphonedetect/issues
WARNING:homeassistant.components.device_tracker:SOURCE_TYPE_ROUTER was used from iphonedetect, this is a deprecated constant which will be removed in HA Core 2025.1. Use SourceType.ROUTER instead, please create a bug report at https://github.com/mudape/iphonedetect/issues
INFO:zigpy.serial:Using pyserial-asyncio-fast in place of pyserial-asyncio
Incorrect config
  General Warnings: 
    - Integration error: ddd - Integration 'ddd' not found.

Successful config (partial)
  General Warnings:

real    0m19.106s
user    0m16.959s
sys     0m2.067s
homeassistant:/config# 

The problem with this setup is:

  1. I’m a bit scared to have this addon and protections off → I don’t really know what are the exact risks I’m taking here, how should I configure this setup to keep me safe.
  2. The hass --script check_config command finally works, it outputs the same info as the WebUI check (actually: even more info) → but it’s still slow (~20 seconds), while the WebUI is instant (~400 ms).

Since I want this check to be done with every file save I do in my IDE, 20 seconds is too long → I can cmd+tab to a web browser and click the button myself faster…

So… I won’t be using it, but thanks! I need to keep looking for a better solution :slight_smile:


EDIT: I’ve found a better solution.

I’ve created a long-living authentication token → and I’m just using the same API as the WebUI is → to do the check:

➜  ~ time curl -k  -L -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer THE_TOKEN' 'http://homeassistant.local:8123/api/config/core/check_config'

{"result":"valid","errors":null,"warnings":"Integration error: ddd - Integration 'ddd' not found."}
curl -k -L -X POST -H 'Content-Type: application/json' -H    
0.01s user 0.01s system 4% cpu 0.541 total

Thanks again!