找回密码
 立即注册

微信扫码登录

搜索
查看: 1162|回复: 2

[经验分享] 小米射频发射器的逆天操作逻辑

[复制链接]

0

主题

18

回帖

409

积分

中级会员

积分
409
金钱
391
HASS币
0
发表于 2025-5-9 17:53:31 | 显示全部楼层
本帖最后由 hugeng 于 2025-5-9 22:27 编辑
amisher 发表于 2025-4-2 11:25
请问报错:未找到动作 script.xiaomi_close_cover 所使用的动作 cover.close_cover,脚本应该写 config 还 ...

我测试了没有问题。
请参考我的代码,首先要弄清楚自己的三个键:上升、下降、停止的ID。
放下幕布,我这边测试是放22秒后停止,不然幕布会太靠下了,大家可以自行调整。

/homeassistant/configuration.yaml 中增加一个窗帘实体

cover:
  - platform: template
    covers:
      ci_wo_mu_bu:  # 这是你的百叶窗实体名称
        device_class: garage
        friendly_name: "次卧幕布"
        open_cover:
          service: script.close_screen # 上升帘子的脚本
        close_cover:
          service: script.open_screen # 放下帘子的脚本
        stop_cover:
          service: script.stop_screen # 暂停动作的脚本


/homeassistant/scripts.yaml 增加三个脚本

stop_screen:
  alias: stop_screen
  sequence:
  - action: select.select_option
    metadata: {}
    data:
      option: Unset
    target:
      entity_id: select.wfxx_cn_547662879_ycmkq_keyfour_sta_p_3_5
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 200
  - action: select.select_option
    metadata: {}
    data:
      option: Set
    target:
      entity_id: select.wfxx_cn_547662879_ycmkq_keyfour_sta_p_3_5
  description: 停止幕布
  icon: mdi:pause
open_screen:
  alias: open_screen
  sequence:
  - action: select.select_option
    metadata: {}
    data:
      option: Unset
    target:
      entity_id: select.wfxx_cn_547662879_ycmkq_keyone_sta_p_3_2
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 200
  - action: select.select_option
    metadata: {}
    data:
      option: Set
    target:
      entity_id: select.wfxx_cn_547662879_ycmkq_keyone_sta_p_3_2
  - delay:
      hours: 0
      minutes: 0
      seconds: 22
      milliseconds: 0
  - action: script.stop_screen
    metadata: {}
    data: {}
  description: 放下幕布
  icon: mdi:arrow-down
close_screen:
  alias: close_screen
  sequence:
  - action: select.select_option
    metadata: {}
    data:
      option: Unset
    target:
      entity_id: select.wfxx_cn_547662879_ycmkq_keytwo_sta_p_3_3
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 200
  - action: select.select_option
    metadata: {}
    data:
      option: Set
    target:
      entity_id: select.wfxx_cn_547662879_ycmkq_keytwo_sta_p_3_3
  description: 收起幕布
  icon: mdi:arrow-up




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-8-11 12:25 , Processed in 0.135829 second(s), 12 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表