一个基于 React 的智能家居控制面板,基于 Home Assistant Websocket api 。
项目使用外部配置文件方式,可以在不重新构建的情况下修改配置。
复制示例配置文件:
# 克隆项目
git clone https://github.com/mrtian2016/hass-panel.git
cd hass-panel
cp public/config/userConfig.json.example public/config/userConfig.json
根据您的 Home Assistant 环境编辑 userConfig.json
配置文件包含以下主要部分(参考CONFIG.md):
{
"weather": ["weather.your_weather_entity"]
}
{
"lights": {
"living_room": {
"entity_id": "light.your_light_entity",
"name": "客厅灯",
"room": "living_room"
}
}
}
{
"sensors": [
{
"id": "LIVING_ROOM",
"name": "客厅",
"sensors": {
"temperature": {
"entity_id": "sensor.temperature_entity",
"name": "温度",
"icon": "mdiThermometer"
},
"humidity": {
"entity_id": "sensor.humidity_entity",
"name": "湿度",
"icon": "mdiWaterPercent"
}
}
}
]
}
{
"climates": [
{
"entity_id": "climate.ac_entity",
"name": "客厅空调",
"room": "living_room",
"features": {
"eco": {
"entity_id": "switch.ac_eco_mode",
"name": "节能",
"icon": "mdiLeaf",
"disableWhen": {
"state": "off"
}
}
}
}
]
}
{
"curtains": [
{
"entity_id": "cover.curtain_entity",
"name": "客厅窗帘",
"room": "living_room"
}
]
}
{
"scripts": [
{
"name": "离家模式",
"entity_id": "script.away_mode",
"icon": "log-out"
}
]
}
# 修改 docker-compose.yml 中的 REACT_APP_HASS_URL 为你的 Home Assistant 实例地址, 然后启动
docker-compose up -d
# 或者
docker run \
--name hass-panel \
--restart unless-stopped \
-p 5123:80 \
-e REACT_APP_HASS_URL=your-hass-instance:8123 \
-v "$(pwd)/public/media:/usr/share/nginx/html/static/media" \
-v "$(pwd)/public/config/userConfig.json:/usr/share/nginx/html/config/userConfig.json" \
-d \
ghcr.io/mrtian2016/hass-panel:latest
entity_id
必须与您的 Home Assistant 中的实体 ID 保持一致配置不生效
设备显示离线
图标不显示
# 安装依赖
npm install
# 启动开发服务器
npm start
# 构建生产版本
npm run build
# 运行测试
npm test
欢迎提交 Pull Request 和 Issue !