2024年11月15日星期五 上午12:35:19

Beginner’s Guide to Home Assistant Core Architecture

2 年 前
#15380 引用
Beginner’s Guide to Home Assistant  Core  Architecture

Quick Start to Home Assistant remote access for Home Assistant Core users

https://developers.home-assistant.io/docs/architecture_index


https://deepzz.com/post/homeassistant-introduce.html
0
2 年 前
#15381 引用
Architecture

The operating system provides the bare minimal Linux environment to run Supervisor and Core.
The Supervisor manages the operating system.
The Core interacts with the user, the supervisor and IoT devices & services.home automation platform






0
2 年 前
#15382 引用
Home Assistant Core Architecture

The Home Assistant Core consists of four main parts. On top of this it includes many helper classes to deal with common scenarios, like providing an entity or dealing with locations.

Event Bus: facilitates the firing and listening of events -- the beating heart of Home Assistant.
State Machine: keeps track of the states of things and fires a state_changed event when a state has been changed.
Service Registry: listens on the event bus for call_service events and allows other code to register services.
Timer: sends a time_changed event every 1 second on the event bus.





0
2 年 前
#15383 引用

Home Assistant由两部分的逻辑组成,内核(Home Assistant core)和组件(component)

Home Assistant core内核的基础工作机制是状态、事件、服务三个概念。

Home Assistant core内核并不与外部世界直接互动,而是通过组件连接外部世界;

比如,light.hue组件负责与飞利浦HUE智能灯的互动(感知与设置其当前状态)。
比如,camera.mjpeg组件负责获得摄像头的标准MJPEG视频流。
比如,sensor.yr组件负责与yr.no云服务通讯,获得天气信息。
比如,http组件负责对外提供的http协议服务。
比如,frontend组件,在http组件的基础上,负责与浏览器的交互。
比如,ifttt组件,负责与INTERNET上另一个大脑(IFTTT)的通讯与互动。




组件与组件之间会有相互的交互,通过hass内核中的状态、事件、服务机制来进行。

HomeAssistant中有一些组件并不与外部世界连接,而仅是获取内部的信息状态,然后运行逻辑规则;
比如,automation组件,在hass内核信息基础上,运行自动化规则逻辑。


Home Assistant core build in integrations



   "matter": {
      "name": "Matter (BETA)",
      "integration_type": "hub",
      "config_flow": true,
      "iot_class": "local_push"
    },
    "mazda": {
      "name": "Mazda Connected Services",
      "integration_type": "hub",
      "config_flow": true,
      "iot_class": "cloud_polling"
    },




https://github.com/home-assistant/core/blob/5651f4a3fe6d8b4fe2cae3453fd07fb4a08d9dbf/homeassistant/generated/integrations.json

0
2 年 前
#15384 引用
Home Assistant core 核心配置文件 configuration.yaml

配置文件决定Home Assistant core加载哪些组件,以及这些组件该如何运行

比如,camera.mjpeg组件的配置信息包含应该连接哪个地址的摄像头抓取视频流。

比如,sensor.yr组件的配置信息包含应该获取哪个地方的什么时间的天气预报。

比如,http组件的配置信息包含对外开放的端口号、访问密码等信息。

比如,automation组件的配置信息包含如何联动的逻辑规则。
0
2 年 前
#16440 引用



0
2 年 前
#16597 引用

Software Requirement

tree -L 3 --dirsfirst


repairs.issue_registry

.Server  software
Raspberry Pi 3B
└── .Debain 11 OS
    │   ├──Python -> Python Version  3.9.2
    │   │   ├──Python virtual environment
    │   │   │   ├── Home Assistant Core 2022.3.0
    │   ├── /home/homeassistant/.homeassistant
    │   │   ├──/.storage  -> /home/homeassistant/.storage
    │   │   │   ├── homekit_controller-entity-map.json
    │   │   │   ├── homekit_controller-entity-map.json
    │   │   │   ├── homekit_controller-entity-map.json
    │   │   │   ├── homekit_controller-entity-map.json
    │   │   │   ├── homekit_controller-entity-map.json
    │   │   │   └── repairs.issue_registry.json
    │   │   ├── /.HA_VERSION   -  2023.9.3
    │   │   ├── /configuration.yaml   -  
    │   │   ├── /automations.yaml   -
    │   │   ├── /scenes.yaml
    │   │   ├── /scripts.yaml
    │   │   ├── /secrets.yaml
    │   │   ├── /.Storage
    │   │   ├── /.Media
    │   │   ├── /tts/
    │   │   ├── /deps/
    │   │   ├── /blueprints/
    │   │   └── /.homeassistant/home-assistant_v2.db  
    │   ├── /srv/homeassistant20221103
    │   └── Python
    │       └── Python virtual environment
    ├── service  -->/etc/systemd/system/[email protected]
    ├── ssh server
    ├── nginx with let’s
    ├── frp
    └── git   /home/homeassistant/.homeassistant/.gitignore

Make Python virtual environment + Home Assistant Core run automatically



1. 目录位置
Home Assistant有两个主要的目录
一个是配置目录,有configuration.yaml(配置文件)、.storage(组件信息存储文件夹)、home-assistant.log(程序运行日志)等;

一个是安装目录,放置有程序核心代码及官方组件代码(components目录)


/etc/systemd/system

http://localhost:4999/boards/topic/1100/home-assistant%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6path#1198
0
2 年 前
#16598 引用
Hardware Requirement


.Server  hardware
光猫
└── .router wifi   - TPlink WTA301
    │   ├── mijia米家吸顶灯
    │   │   ├── yeelink.light.ceiling21    米家客厅吸顶灯 Light by xiaomi miot auto
    │   │   ├── turn_light_off_lounge.yaml
    │   │   ├── turn_light_on_bedroom.yaml
    │   │   └── home-assistant_v2.db
    │   ├── Yeelight wifi吸顶灯
    │   │   ├── yeelink.light.ceiling26    米家客厅吸顶灯 Light by xiaomi miot auto
    │   │   ├── turn_light_off_lounge.yaml
    │   │   ├── turn_light_on_bedroom.yaml
    │   │   └── Yeelight color 1S
    │   ├── broadlink wifi灯泡
    │   └── philips wifi灯泡
    │       └── Yeelight color 1S
    ├── Aqara M1s gateway (zigbee 3.0)
    │   ├── montion sensors
    │   │   ├── Aqara人体传感器E1
    │   │   ├── turn_light_off_lounge.yaml
    │   │   ├── turn_light_on_bedroom.yaml
    │   │   └── home-assistant_v2.db
    │   ├── say_hello.yaml
    │   └── blubs
    │       └── Aqara智能灯泡T1
    ├── 米家中枢网关gateway (ble mesh )
    │   ├── slave gateway(mijia)
    │   │   ├── mijia play pro
    │   │   ├── mijia multi mode gateway 1
    │   │   ├── mijia multi mode gateway 2
    │   │   └──
    │   ├── slave gateway(Yeelight)
    │   │   ├── Yeelight mesh pro
    │   │   ├──
    │   │   ├──
    │   │   └── Yeelight mesh gateway
    │   ├── slave gateway(aqara)
    │   │   ├──
    │   │   ├──
    │   │   ├──
    │   │   └── no
    │   ├──
    │   └── sensors
    │       └── mijia motion sensor2
  ├── Yeelight
    │   ├── yeelight  devices (wifi)
    │   │   ├── yeelight wifi devices
    │   │   ├── mijia multi mode gateway 1
    │   │   ├── mijia multi mode gateway 2
    │   │   └──
    │   ├── yeelight  devices(ble mesh)
    │   │   ├── Yeelight mesh pro
    │   │   ├──
    │   │   ├──
    │   │   └── Yeelight mesh gateway
    │   ├── Yeelight  pro
    │   │   ├──
    │   │   ├──
    │   │   ├──
    │   │   └── no
    │   ├──
    │   └── sensors
    │       └── mijia motion sensor2
    ├── Raspberry Pi 3B  - Home Assistant Core 2022.3.0
    └── .router wifi   - TPlink WTA301
    │   ├── wifi
    │   │   ├── mobile
    │   │   ├──
    │   │   ├──
    │   │   └──
    │   └── line
    │       └── windows 10
    └── git

Make Python virtual environment + Home Assistant Core run automatically




I just bought another 3 orvibo switches from BangGood. ~$22AUD each. I tested the earth pin and it is connected.
0
2 年 前
#16599 引用
Client
mobile for android
└── .android OS
    ├── app
    │   ├── home assistant app
    │   │   ├── turn_light_off_bedroom.yaml
    │   │   ├── turn_light_off_lounge.yaml
    │   │   ├── turn_light_on_bedroom.yaml
    │   │   └── turn_light_on_lounge.yaml
    │   ├── xftp7
    │   └── sensors
    │       └── react.yaml
    ├── community between server
    ├── frp
    └── configuration.yaml (not included)
0
2 年 前
#17589 引用
Events are saved in a local database. Google Graphs is used to draw the graph. Drawing is happening 100% in your browser. No data is transferred to anyone at any time.



https://www.home-assistant.io/integrations/history/
0