Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

nonebot-plugin-homeassistant

通过现有 nonebot_plugin_rhythmnest_billing 的实时入店名单,对 Home Assistant 实体控制进行分级授权:

  • 当前已入店用户和管理员可以开启白名单内的实体、查看状态;
  • 只有管理员可以关闭实体;
  • 当前已入店用户只能在配置温区内调节 climate 实体;
  • 管理员不受访客温区限制,但仍受空调自身 min_temp / max_temp 限制。

管理员身份完全由 nonebot_plugin_rhythmnest_billing.is_administrator() 判断,也就是通过 /addadmin 添加的计费系统管理员。插件不维护自己的 管理员列表。

配置

带注释的完整字段说明见 .example.env.json5。该文件 仅作为配置模板,NoneBot 不会自动读取它;实际运行配置仍需写入 .env.prod 的 HOMEASSISTANT 环境变量。复制时需要移除 JSON5 注释和 尾随逗号,确保环境变量的值是标准 JSON。

在 .env.prod 中加入(请换成真实地址、令牌和实体 ID):

HOMEASSISTANT='{
  "base_url": "http://127.0.0.1:8123",
  "token": "Home Assistant long-lived access token",
  "entities": {
    "wm": "switch.washing_machine",
    "ac": "climate.shop",
    "light": "light.shop"
  },
  "guest_temperature_min": 24,
  "guest_temperature_max": 28,
  "request_timeout_seconds": 10,
  "verify_ssl": true
}'

entities 是唯一的实体白名单,键是命令使用的短名称,值是 Home Assistant 实体 ID。命令只接受映射左侧的名称,不接受完整实体 ID。 不要把长期访问令牌提交到版本库。

命令

/entities
/on wm
/off wm
/ac ac 26
/hastatus ac

/entities 会列出可用的实体短名称,普通用户必须处于入店状态。输出按 “可开关实体”和“可调节温度实体”分组,其中空调实体也会出现在可开关 实体中。直接发送不带参数的 /on、/off 或 /ac,效果与 /entities 相同;不带参数的 /hastatus 会并发查询并返回全部白名单实体的状态, 单个实体查询失败不会影响其他结果。/ac 只提供了部分参数时会提示完整 格式。

也支持中文命令别名:可控实体、开启实体、关闭实体、空调温度、 实体状态。

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages