专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题轩辕镜像免费版
其他
关于我们网站地图
热门搜索:
home-assistant-cli

homeassistant/home-assistant-cli

Home Assistant 智能家居平台

The Home Assistant command line interface.

9 次收藏下载次数: 0状态:社区镜像维护者:Home Assistant 智能家居平台仓库类型:镜像最近更新:6 年前
轩辕镜像,不浪费每一次拉取。点击查看
镜像简介
标签下载
镜像标签列表与下载命令
轩辕镜像,不浪费每一次拉取。点击查看

Home Assistant Command-line Interface (hass-cli)

|Coverage| |Chat Status| |License| |PyPI|

The Home Assistant Command-line interface (hass-cli) allows one to work with a local or a remote Home Assistant <https://home-assistant.io>_ Core or Home Assistant (former Hass.io) instance directly from the command-line.

.. image:: [] :alt: hass-cli screencast :target: []

Installation

To use latest release:

.. code:: bash

$ pip install homeassistant-cli

To use latest pre-release from dev branch:

.. code:: bash

$ pip install git+https://github.com/home-assistant/home-assistant-cli@dev

The developers of hass-cli usually provide up-to-date packages <https://src.fedoraproject.org/rpms/home-assistant-cli>_ for recent Fedora and EPEL releases. Use dnf for the installation:

.. code:: bash

$ sudo dnf -y install home-assistant-cli

The community is providing support for macOS through homebew <https://formulae.brew.sh/formula/homeassistant-cli#default>.

.. code:: bash

$ brew install homeassistant-cli

Keep in mind that the available releases in the distribution could be out-dated.

Docker

If you do not have a Python setup you can try use hass-cli via a container using Docker.

.. code:: bash

$ docker run homeassistant/home-assistant-cli

To make auto-completion and access environment work like other scripts you'll need to create a script file to execute.

.. code:: bash

$ curl https://raw.githubusercontent.com/home-assistant/home-assistant-cli/master/docker-hass-cli > hass-cli $ chmod +x hass-cli

Now put the hass-cli script into your path and you can use it like if you had installed it via command line as long as you don't need file system access (like for hass-cli template).

Setup

To get started you'll need to have or generate a long lasting token format on your Home Assistant profile page (i.e. https://localhost:8123/profile).

Then you can use --server and --token parameter on each call or as is recommended setup HASS_SERVER and HASS_TOKEN environment variables.

.. code:: bash

$ export HASS_SERVER=[***]
$ export HASS_TOKEN=<secret>

Once that is enabled and you are using either zsh or bash run the following to enable autocompletion for hass-cli commands.

.. code:: bash

$ source <(hass-cli completion zsh)

Usage

Note: Below is listed some of the features, make sure to use --help and autocompletion to learn more of the features as they become available.

Most commands returns a table version of what the Home Assistant API returns. For example to get basic info about your Home Assistant server you use info:

.. code:: bash

$ hass-cli info BASE_URL LOCATION REQUIRES_API_PASWORD VERSION [***] Fort of Solitude False 0.86.2

If you prefer yaml you can use --output=yaml:

.. code:: bash

$ hass-cli --output yaml info
  base_url: [***]
  location_name: Wayne Manor
  requires_api_password: false
  version: 0.86.2

To get list of states you use state list:

.. code:: bash

$ hass-cli state list
ENTITY                                                     DESCRIPTION                                     STATE
zone.school                                                School                                          zoning
zone.home                                                  Andersens                                       zoning
sun.sun                                                    Sun                                             below_horizon
camera.babymonitor                                         babymonitor                                     idle
timer.timer_office_lights                                                                                  idle
timer.timer_small_bathroom                                                                                 idle
[...]

You can use --no-headers to suppress the header.

--table-format let you select which table format you want. Default is simple but you can use any of the formats supported by [***] plain, simple, github, grid, fancy_grid, pipe, orgtbl, rst, mediawiki, html, latex, latex_raw, latex_booktabs or tsv

Finally, you can also via --columns control which data you want shown. Each column has a name and a jsonpath. The default setup for entities are:

--columns=ENTITY=entity_id,DESCRIPTION=attributes.friendly_name,STATE=state,CHANGED=last_changed

If you for example just wanted the name and all attributes you could do:

.. code:: bash

$ hass-cli --columns=ENTITY="entity_id,ATTRIBUTES=attributes[*]" state list zone ENTITY ATTRIBUTES zone.school {'friendly_name': 'School', 'hidden': True, 'icon': 'mdi:school', 'latitude': 7.011023, 'longitude': 16.858151, 'radius': 50.0} zone.unnamed_zone {'friendly_name': 'Unnamed zone', 'hidden': True, 'icon': 'mdi:home', 'latitude': 37.006476, 'longitude': 2.861699, 'radius': 50.0} zone.home {'friendly_name': 'Andersens', 'hidden': True, 'icon': 'mdi:home', 'latitude': 27.006476, 'longitude': 7.861699, 'radius': 100}

You can get more details about a state by using yaml or json output format. In this example we use the shorthand of output: -o:

.. code:: bash

$ hass-cli -o yaml state get light.guestroom_light                                                                                                                                                                       ◼
attributes:
  friendly_name: Guestroom Light
  supported_features: 61
context:
  id: 84d52fe306ec4895948b546b492702a4
  user_id: null
entity_id: light.guestroom_light
last_changed: '2018-12-10T18:33:51.883238+00:00'
last_updated: '2018-12-10T18:33:51.883238+00:00'
state: 'off'

You can edit state via an editor:

.. code:: bash

$ hass-cli state edit light.guestroom_light

This will open the current state in your favorite editor and any changes you save will be used for an update.

You can also explicitly create/edit via the --json flag:

.. code:: bash

$ hass-cli state edit sensor.test --json='{ "state":"off"}'

List possible services with or without a regular expression filter:

.. code:: bash

$ hass-cli service list 'home.*toggle'
  DOMAIN         SERVICE    DESCRIPTION
  homeassistant  toggle     Generic service to toggle devices on/off...

For more details the YAML format is useful:

.. code:: bash

$ hass-cli -o yaml service list homeassistant.toggle
homeassistant:
  services:
    toggle:
      description: Generic service to toggle devices on/off under any domain. Same
        usage as the light.turn_on, switch.turn_on, etc. services.
      fields:
        entity_id:
          description: The entity_id of the device to toggle on/off.
          example: light.living_room

You can get history about one or more entities, here getting state changes for the last 50 minutes:

.. code:: bash

$ hass-cli state history --since 50m light.kitchen_light_1 binary_sensor.presence_kitchen ENTITY DESCRIPTION STATE CHANGED binary_sensor.presence_kitchen Kitchen Motion off 2019-01-27T23:19:55.322474+00:00 binary_sensor.presence_kitchen Kitchen Motion on 2019-01-27T23:21:44.015071+00:00 binary_sensor.presence_kitchen Kitchen Motion off 2019-01-27T23:22:02.330566+00:00 light.kitchen_light_1 Kitchen Light 1 on 2019-01-27T23:19:55.322474+00:00 light.kitchen_light_1 Kitchen Light 1 off 2019-01-27T23:36:45.254266+00:00

The data is sorted by default as Home Assistant returns it, thus for history it is useful to sort by a property:

.. code:: bash

$ hass-cli --sort-by last_changed state history --since 50m light.kitchen_light_1 binary_sensor.presence_kitchen ENTITY DESCRIPTION STATE CHANGED binary_sensor.presence_kitchen Kitchen Motion off 2019-01-27T23:18:00.717611+00:00 light.kitchen_light_1 Kitchen Light 1 on 2019-01-27T23:18:00.717611+00:00 binary_sensor.presence_kitchen Kitchen Motion on 2019-01-27T23:18:12.***+00:00 binary_sensor.presence_kitchen Kitchen Motion off 2019-01-27T23:18:30.417064+00:00 light.kitchen_light_1 Kitchen Light 1 off 2019-01-27T23:36:45.254266+00:00

Note: the --sort-by argument is referring to the attribute in the underlying json/yaml NOT the column name. The advantage for this is that it can be used for sorting on any property even if not included in the default output.

Areas and Device Registry

Since v0.87 of Home Assistant there is a notion of Areas in the Device registry. hass-cli lets you list devices and areas and assign areas to devices.

Listing devices and areas works similar to list Entities.

.. code:: bash

$ hass-cli device list ID NAME MODEL MANUFACTURER AREA a3852c3c3ebd47d3acac***ca6f8b Basement stairs motion SML001 Philips c6c962b892064a218e968fcaee7950c8 880a944e74db4bb48ea3db6dd24af357 Basement Light 2 TRADFRI bulb GU10 WS 400lm IKEA of Sweden c6c962b892064a218e968fcaee7950c8 657c3cc908594479aab819ff80d0c710 Office Hue white lamp Philips None [...]

$ hass-cli area list ID NAME 295afc88012341ecb897cd12d3fbc6b4 Bathroom 9e08d89203804d5db995c3d0d5dbd91b Winter Garden 8816ee92b7b84f54bbb30a68b877e739 Office [...]

You can create and delete areas:

.. code:: bash

$ hass-cli area delete "Old Shed"

  • id: 1 type: result success: true result: success

$ hass-cli area create "New Shed"

  • id: 1 type: result success: true result: area_id: cdd09a80f03a4cc59d2943053c0414c0 name: New Shed

You can assign area to a specific device. Here the Kitchen area gets assigned to device named "Cupboard Light".

.. code:: bash

$ hass-cli device assign Kitchen "Cupboard Light"

Besides assigning individual devices you can assign in bulk:

.. code:: bash

$ hass-cli device assign Kitchen --match "Kitchen Light"

The above line will assign Kitchen area to all devices with substring "Kitchen Light".

You can also combine individual and matched devices in one line:

.. code:: bash

$ hass-cli device assign Kitchen --match "Kitchen Light" eab9930f8652408882cc8cb604651c60 Cupboard

Above will assign area named "Kitchen" to all devices having substring "Kitchen Light" and to specific area with id "eab9930..." or named "Cupboard".

Events

You can subscribe and watch all or a specific event type using event watch.

.. code:: bash

$ hass-cli event watch

This will watch for all event types, you can limit to a specific event type by specifying it as an argument:

.. code:: bash

$ hass-cli event watch deconz_event

Home Assistant (former Hass.io)

If you are using Home Assistant (former Hass.io) there are commands available for you to interact with Home Assistant services/systems. This includes the underlying services like the supervisor.

Check the Supervisor release you are running:

.. code:: bash

$ hass-cli ha supervisor info result: ok data: version: '217' version_latest: '217' channel: stable [...]

Check the Core release you are using at the moment:

.. code:: bash

$ hass-cli ha core info result: ok data: version: 0.108.2 version_latest: 0.108.3 [...]

Update Core to the latest available release:

.. code:: bash

$ hass-cli ha core update

Other

You can call services:

.. code:: bash

$ hass-cli service call deconz.device_refresh

With arguments:

.. code:: bash

$ hass-cli service call homeassistant.toggle --arguments entity_id=light.office_light

Open a map for your Home Assistant location:

.. code:: bash

$ hass-cli map

Render templates server side:

.. code:: bash

$ hass-cli template motionlight.yaml.j2 motiondata.yaml

Render templates client (local) side:

.. code:: bash

$ hass-cli template --local lovelace-template.yaml

Auto-completion ###############

As described above you can use source <(hass-cli completion zsh) to quickly and easy enable auto completion. If you do it from your .bashrc or .zshrc it's recommend to use the form below as that does not trigger a run of hass-cli itself.

For zsh:

.. code:: bash

eval "$(_HASS_CLI_COMPLETE=source_zsh hass-cli)"

For bash:

.. code:: bash

eval "$(_HASS_CLI_COMPLETE=source hass-cli)"

Once enabled there is autocompletion for commands and for certain attributes like entities:

.. code:: bash

$ hass-cli state get light. ⏎ ✱ ◼ light.kitchen_light_5 light.office_light light.basement_light_4 light.basement_light_9 light.dinner_table_light_4 light.winter_garden_light_2 light.kitchen_light_2 light.kitchen_table_light_1 light.hallroom_light_2 light.basement_light_5 light.basement_light_10 light.dinner_table_wall_light light.winter_garden_light_4 light.kitchen_table_light_2 light.kitchen_light_1 light.hallroom_light_1 light.basement_light_6 light.small_bathroom_light light.dinner_table_light_5 light.winter_garden_light_3 light.kitchen_light_4 [...]

Note: For this to work you'll need to have setup the following environment variables if your Home Assistant installation is secured and not running on localhost:8123:

.. code:: bash

export HASS_SERVER=[***] export HASS_TOKEN=eyJ0eXAiO-----------------------ed8mj0NP8

Help

.. code:: bash

$ hass-cli
Usage: hass-cli [OPTIONS] COMMAND [ARGS]...

  Command line interface for Home Assistant.

Options:
  -l, --loglevel LVL              Either CRITICAL, ERROR, WARNING, INFO or
                                  DEBUG
  --version                       Show the version and exit.
  -s, --server TEXT               The server URL or `auto` for automatic
                                  detection. Can also be set with the
                                  environment variable HASS_SERVER.  [default:
                                  auto]
  --token TEXT                    The Bearer token for Home Assistant
                                  instance. Can also be set with the
                                  environment variable HASS_TOKEN.
  --password TEXT                 The API password for Home Assistant
                                  instance. Can also be set with the
                                  environment variable HASS_PASSWORD.
  --timeout INTEGER               Timeout for network operations.  [default:
                                  5]
  -o, --output [json|yaml|table|auto]
                                  Output format.  [default: auto]
  -v, --verbose                   Enables verbose mode.
  -x                              Print backtraces when exception occurs.
  --cert TEXT                     Path to client certificate file (.pem) to
                                  use when connecting.
  --insecure                      Ignore SSL Certificates. Allow to connect to
                                  servers with self-signed certificates. Be
                                  careful!
  --debug                         Enables debug mode.
  --columns TEXT                  Custom columns key=value list. Example:
                                  ENTITY=entity_id,
                                  NAME=attributes.friendly_name
  --no-headers                    When printing tables don't use headers
                                  (default: print headers)
  --table-format TEXT             Which table format to use.
  --sort-by TEXT                  Sort table by the jsonpath expression.
                                  Example: last_changed
  --version                       Show the version and exit.
  --help                          Show this message and exit.

Commands:
  area        Get info and operate on areas from Home Assistant...
  completion  Output shell completion code for the specified shell (bash or...
  config      Get configuration from a Home Assistant instance.
  device      Get info and operate on devices from Home Assistant...
  discover    Discovery for the local network.
  entity      Get info on entities from Home Assistant.
  event       Interact with events.
  ha          Home Assistant (former Hass.io) commands.
  info        Get basic info from Home Assistant.
  map         Show the location of the config or an entity on a map.
  raw         Call the raw API (advanced).
  service     Call and work with services.
  state       Get info on entity state from Home Assistant.
  system      System details and operations for Home Assistant.
  template    Render templates on server or locally.

Clone the git repository and

.. code:: bash

$ pip3 install --editable .

Development ###########

Developing is (re)using as much as possible from Home Assistant development setup.

Recommended way to develop is to use virtual environment to ensure isolation from rest of your system using the following steps:

Clone the git repository and do the following:

.. code:: bash

$ python3 -m venv .
$ source bin/activate
$ script/setup

after this you should be able to edit the source code and running hass-cli directly:

.. code:: bash

$ hass-cli

.. |Chat Status| image:: [] :target: [] .. |License| image:: [] :target: https://github.com/home-assistant/home-assistant-cli/blob/master/LICENSE :alt: License .. |PyPI| image:: [] :target: [] :alt: PyPI release .. |Coverage| image:: [] :target: [] :alt: Coveralls .. |Docker| image:: [] :target: https://hub.docker.com/r/homeassistant/home-assistant-cli :alt: Docker

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 home-assistant-cli 镜像标签

docker pull docker.xuanyuan.run/homeassistant/home-assistant-cli:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull homeassistant/home-assistant-cli:<标签>

更多 home-assistant-cli 镜像推荐

redislabs/re-call-home-client logo

redislabs/re-call-home-client

redislabs
暂无描述
100万+ 次下载
1 天前更新
linuxserver/homeassistant logo

linuxserver/homeassistant

LinuxServer.io 社区镜像
LinuxServer提供的Home Assistant Docker镜像,是一款功能强大的家庭自动化平台,可集中管理智能家居设备,支持数百种设备协议与品牌,通过可视化界面与自动化规则实现场景联动。该镜像基于轻量级架构构建,集成完善的社区插件生态,支持数据持久化与安全更新,帮助用户轻松搭建个性化智能家庭系统,简化部署流程并降低维护成本,打造高效、智能的现代生活体验。
266 次收藏100万+ 次下载
3 天前更新
homebrew/brew logo

homebrew/brew

homebrew
包含Homebrew开源包管理器的默认Ubuntu Docker镜像。
23 次收藏50万+ 次下载
6 个月前更新
vmware/folding-at-home logo

vmware/folding-at-home

vmware
VMware容器化Folding@Home客户端镜像,用于便捷部署和运行分布式蛋白质折叠研究计算任务,支持参与Folding@Home项目的科学计算。
1万+ 次下载
5 年前更新
homebrew/ubuntu20.04 logo

homebrew/ubuntu20.04

homebrew
包含Homebrew开源包管理器的Ubuntu 20.04 Docker镜像。
10 次收藏5万+ 次下载
6 个月前更新
homebrew/ubuntu22.04 logo

homebrew/ubuntu22.04

homebrew
这是一个基于Ubuntu 22.04操作系统的Docker镜像,其中集成了Homebrew这款开源包管理器,旨在为用户提供便捷的容器化环境,以便在Docker中高效使用Homebrew进行软件包的安装、管理与依赖维护,适用于各类开发、测试及部署场景,兼具Ubuntu 22.04的稳定性与Homebrew开源生态的丰富功能。
6 次收藏1万+ 次下载
6 个月前更新

查看更多 home-assistant-cli 相关镜像

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

Harbor 镜像源配置

Harbor Proxy Repository 对接专属域名

Portainer 镜像源配置

Portainer Registries 加速拉取

Nexus 镜像源配置

Nexus3 Docker Proxy 内网缓存

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

配置了专属域名后,docker search 为什么会报错?

docker search 限制

Docker Hub 上有的镜像,为什么在轩辕镜像网站搜不到?

站内搜不到镜像

机器不能直连外网时,怎么用 docker save / load 迁镜像?

离线 save/load

docker pull 拉插件报错(plugin v1+json)怎么办?

插件要用 plugin install

WSL 里 Docker 拉镜像特别慢,怎么排查和优化?

WSL 拉取慢

轩辕镜像安全吗?如何用 digest 校验镜像没被篡改?

安全与 digest

第一次用轩辕镜像拉 Docker 镜像,要怎么登录和配置?

新手拉取配置

轩辕镜像合规吗?轩辕镜像的合规是怎么做的?

镜像合规机制

轩辕镜像支持 docker push 上传本地镜像吗?

不支持 push

错误码与失败问题

docker pull 提示 manifest unknown 怎么办?

manifest unknown

docker pull 提示 no matching manifest 怎么办?

no matching manifest(架构)

镜像已拉取完成,却提示 invalid tar header 或 failed to register layer 怎么办?

invalid tar header(解压)

Docker pull 时 HTTPS / TLS 证书验证失败怎么办?

TLS 证书失败

Docker pull 时 DNS 解析超时或连不上仓库怎么办?

DNS 超时

docker 无法连接轩辕镜像域名怎么办?

域名连通性排查

Docker 拉取出现 410 Gone 怎么办?

410 Gone 排查

出现 402 或「流量用尽」提示怎么办?

402 与流量用尽

Docker 拉取提示 UNAUTHORIZED(401)怎么办?

401 认证失败

遇到 429 Too Many Requests(请求太频繁)怎么办?

429 限流

docker login 提示 Cannot autolaunch D-Bus,还算登录成功吗?

D-Bus 凭证提示

为什么会出现「单层超过 20GB」或 413,无法加速拉取?

413 与超大单层

账号 / 计费 / 权限

轩辕镜像免费版和专业版有什么区别?

免费版与专业版区别

轩辕镜像支持哪些 Docker 镜像仓库?

支持的镜像仓库

镜像拉取失败还会不会扣流量?

失败是否计费

麒麟 V10 / 统信 UOS 提示 KYSEC 权限不够怎么办?

KYSEC 拦截脚本

如何在轩辕镜像申请开具发票?

申请开票

怎么修改轩辕镜像的网站登录和仓库登录密码?

修改登录密码

如何注销轩辕镜像账户?要注意什么?

注销账户

配置与原理类

写了 registry-mirrors,为什么还是走官方或仍然报错?

mirrors 不生效

怎么用 docker tag 去掉镜像名里的轩辕域名前缀?

去掉域名前缀

如何拉取指定 CPU 架构的镜像(如 ARM64、AMD64)?

指定架构拉取

用轩辕镜像拉镜像时快时慢,常见原因有哪些?

拉取速度原因

为什么拉取镜像的 :latest 标签,拿到的往往不是「最新」镜像?

latest 与「最新」

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
Home Assistant 智能家居平台
...
homeassistant/home-assistant-cli
博客Docker 镜像公告与技术博客
热门查看热门 Docker 镜像推荐
安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单。官方公众号:源码跳动。官方技术交流群:51517718。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单。官方公众号:源码跳动。官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
商务合作:点击复制邮箱
©2024-2026 源码跳动
商务合作:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.