『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 703|回复: 1

[技术探讨] configuration文件中两个开关就报错的问题

[复制链接]

1

主题

15

帖子

169

积分

注册会员

Rank: 2

积分
169
金钱
154
HASS币
0
发表于 2023-4-3 23:30:01 | 显示全部楼层 |阅读模式
本帖最后由 q3213092 于 2023-4-3 23:31 编辑

请教各位大佬,纯小白,论坛抄了两个开关。单独用都好用,但是都放到configurantion中,就报错,求助。

switch:
#远程唤醒家里PC电脑开关
  - platform: wake_on_lan
    name: "台式电脑"
    mac: "xxxxxx"
    host: xxxxx

    turn_off:
       service: shell_command.turn_off_pc


shell_command:
    turn_off_pc: 'curl -X GET http://xxxxxxxxxx:5001/?action=System.sleep'


#Apple TV的开关
  - platform: template
    switches:
      appletv:
        unique_id: my_unique_id
        friendly_name: "Apple Tv"
        value_template: "{{ is_state('media_player.wo_shi', ['playing','idle']) }}"
        turn_on:
          service: remote.send_command
          data:
            command: wakeup
          target:
            entity_id: remote.wo_shi
        turn_off:
          service: media_player.turn_off
          target:
            entity_id: media_player.wo_shi
          data: {}
提示配置无效:

Error loading /config/configuration.yaml: while parsing a block mappingin "/config/configuration.yaml", line 3, column 1expected <block end>, but found '<block sequence start>'in "/config/configuration.yaml", line 35, column 3



回复

使用道具 举报

29

主题

932

帖子

4192

积分

论坛元老

Rank: 8Rank: 8

积分
4192
金钱
3250
HASS币
70
发表于 2023-4-4 05:55:27 | 显示全部楼层
本帖最后由 relliky 于 2023-4-4 06:00 编辑

shell_command:
    turn_off_pc: 'curl -X GET http://xxxxxxxxxx:5001/?action=System.sleep'

#Apple TV的开关
  - platform: template
    switches:
      appletv:


这里是错的,shell_command不能作为它的种类
见官方文档https://www.home-assistant.io/integrations/switch.template/

调换一下就好了


switch:
#远程唤醒家里PC电脑开关
  - platform: wake_on_lan
    name: "台式电脑"
    mac: "xxxxxx"
    host: xxxxx

    turn_off:
       service: shell_command.turn_off_pc

#Apple TV的开关
  - platform: template
    switches:
      appletv:
        unique_id: my_unique_id
        friendly_name: "Apple Tv"
        value_template: "{{ is_state('media_player.wo_shi', ['playing','idle']) }}"
        turn_on:
          service: remote.send_command
          data:
            command: wakeup
          target:
            entity_id: remote.wo_shi
        turn_off:
          service: media_player.turn_off
          target:
            entity_id: media_player.wo_shi
          data: {}

shell_command:
    turn_off_pc: 'curl -X GET http://xxxxxxxxxx:5001/?action=System.sleep'



我家全屋智能的HA设置 https://github.com/relliky/Tais_Home_Assistant_Config
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-2 07:49 , Processed in 0.720628 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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