- 积分
- 914
- 金钱
- 764
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
高级会员
- 积分
- 914
- 金钱
- 764
- HASS币
- 0
|
发表于 2018-6-26 22:21:15
|
显示全部楼层
本帖最后由 charles0568 于 2018-6-26 23:00 编辑
您好~我照您這樣寫在scripts.yaml 裡 它出現錯誤碼 是不是我語法上有寫錯?
switch:
- platform: template
switches:
Tv_power:
friendly_name: "Tv_power"
value_template: "{{ is_state_attr('switch.blind_toggle', 'sensor_state', 'on') }}"
turn_on:
service: remote.send_command
data:
entity_id: remote.ir_remote
command: Z6VLAA8CAABxAgAAugYAABEJAADeEQAAuSMAAGydAABMewEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFIBAQEBAQEBAQICAgICAgIBAQICAQEBAQICAQECAgICBgNXA1AA==
turn_off:
service: remote.send_command
data:
entity_id: remote.ir_remote
command: Z6VLAA8CAABxAgAAugYAABEJAADeEQAAuSMAAGydAABMewEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFIBAQEBAQEBAQICAgICAgIBAQICAQEBAQICAQECAgICBgNXA1AA==
它出現這樣的錯誤
Invalid config for [script]: expected a dictionary for dictionary value @ data['script']['switch']. Got [OrderedDict([('platform', 'template'), ('switches', OrderedDict([('Tv_power', OrderedDict([('friendly_name', 'Tv_power'), ('value_template', "{{ is_state_attr('switch.blind_toggle', 'sensor_state', 'on') }}"), ('turn_on', OrderedDict([('service', 'remote.send_command'), ('data', OrderedDict([('entity_id', 'remote.ir_remote'), ('command', 'Z6VLAA8CAABxAgAAugYAABEJAADeEQAAuSMAAGydAABMewEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFIBAQEBAQEBAQICAgICAgIBAQICAQEBAQICAQECAgICBgNXA1AA==')]))])), (.... (See /config/configuration.yaml, line 143). Please check the docs at https://home-assistant.io/components/script/
是否我語法有寫錯了???
原來我誤解錯了 是要寫在configutation.yaml裡才對!!! 謝謝你的幫助!!!
剛看了一下 https://www.home-assistant.io/components/switch.template/
switch:
- platform: template
switches:
fanpower:
friendly_name: "fanpower"
value_template: [color=rgb(208, 16, 64)][font=monospace, sans-serif][size=1em]"[/size][/font][/color][color=rgb(208, 16, 64)][font=monospace, sans-serif][size=1em]{{[/size][/font][/color][color=teal][font=monospace, sans-serif][size=1em] [/size][/font][/color][color=rgb(208, 16, 64)][font=monospace, sans-serif][size=1em]is_state_attr('switch.blind_toggle',[/size][/font][/color][color=teal][font=monospace, sans-serif][size=1em] [/size][/font][/color][color=rgb(208, 16, 64)][font=monospace, sans-serif][size=1em]'sensor_state',[/size][/font][/color][color=teal][font=monospace, sans-serif][size=1em] [/size][/font][/color][color=rgb(208, 16, 64)][font=monospace, sans-serif][size=1em]'on')[/size][/font][/color][color=teal][font=monospace, sans-serif][size=1em] [/size][/font][/color][color=rgb(208, 16, 64)][font=monospace, sans-serif][size=1em]}}"[/size][/font][/color]
turn_on:
service: remote.send_command
data:
entity_id: remote.ir_remote
command: Z6VLAA8CAABxAgAAugYAABEJAADeEQAAuSMAAGydAABMewEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFIBAQEBAQEBAQICAgICAgIBAQICAQEBAQICAQECAgICBgNXA1AA==
turn_off:
service: remote.send_command
data:
entity_id: remote.ir_remote
command: Z6VLAA8CAABxAgAAugYAABEJAADeEQAAuSMAAGydAABMewEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFIBAQEBAQEBAQICAgICAgIBAQICAQEBAQICAQECAgICBgNXA1AA==
改成這樣 才沒出錯~~value_template: "{{ is_state('sensor.fanpower.state', 'on') }}" 好像這樣才沒錯誤~ 謝謝大大!!教了我那麼多!!!感謝你!!好感動!!
|
|