本帖最后由 riyue0000 于 2019-9-21 22:25 编辑
试过多种方法都不对,请大神们指导啊
第一种 configuration.yaml 中 switch:!include_dir_list switchs
/switchs/shufangTC1.yaml 内容如下
platform: mqtt name: 'tc1_1' state_topic: 'homeassistant/switch/d0bae46412c1/plug_0/state' command_topic: 'device/ztc1/set' payload_on: '{"mac":"d0bae46412c1","plug_0":{"on":1}}' payload_off: '{"mac":"d0bae46412c1","plug_0":{"on":0}}' platform: mqtt name: 'tc1_2' state_topic: 'homeassistant/switch/d0bae46412c1/plug_1/state' command_topic: 'device/ztc1/set' payload_on: '{"mac":"d0bae46412c1","plug_1":{"on":1}}' payload_off: '{"mac":"d0bae46412c1","plug_1":{"on":0}}'
报错 ERROR (SyncWorker_0) [homeassistant.util.yaml] YAML file /config/switchs/shufangTC1.yaml contains duplicate key "platform". Check lines 0 and 6. 2019-09-21 14:04:20 ERROR (SyncWorker_0) [homeassistant.util.yaml] YAML file /config/switchs/shufangTC1.yaml contains duplicate key "name". Check lines 1 and 7
第二种 configuration.yaml 中 switch:!include_dir_list switchs
/switchs/shufangTC1-2.yaml内容如下
switch: - platform: mqtt name: 'tc1_1' state_topic: 'homeassistant/switch/MAC/plug_0/state' command_topic: 'device/ztc1/set' payload_on: '{"mac":"MAC","plug_0":{"on":1}}' payload_off: '{"mac":"MAC","plug_0":{"on":0}}' - platform: mqtt name: 'tc1_2' state_topic: 'homeassistant/switch/MAC/plug_1/state' command_topic: 'device/ztc1/set' payload_on: '{"mac":"MAC","plug_1":{"on":1}}' payload_off: '{"mac":"MAC","plug_1":{"on":0}}'
报错ERROR (MainThread) [homeassistant.config] Invalid config for [switch]: required key not provided @ data['platform']. Got None. (See /config/switchs/shufangTC1-2.yaml, line 1). Please check the docs at https://home-assistant.io/components/switch/
第三种 configuration.yaml 中 switch:!include_dir_list switchs
/switchs/ketingTC1.yaml内容如下
- platform: mqtt name: 'ketingtc1_1' state_topic: 'homeassistant/switch/d0bae46447c4/plug_0/state' command_topic: 'device/ztc1/set' payload_on: '{"mac":"d0bae46447c4","plug_0":{"on":1}}' payload_off: '{"mac":"d0bae46447c4","plug_0":{"on":0}}'
- platform: mqtt name: 'ketingtc1_2' state_topic: 'homeassistant/switch/d0bae46447c4/plug_1/state' command_topic: 'device/ztc1/set' payload_on: '{"mac":"d0bae46447c4","plug_1":{"on":1}}' payload_off: '{"mac":"d0bae46447c4","plug_1":{"on":0}}'
报错ERROR (MainThread) [homeassistant.config] Invalid config for [switch]: expected a dictionary. Got [OrderedDict([('platform', 'mqtt'), ('name', 'ketingtc1_1'), ('state_topic', 'homeassistant/switch/d0bae46447c4/plug_0/state'), ('command_topic', 'device/ztc1/set'), ('payload_on', '{"mac":"d0bae46447c4","plug_0":{"on":1}}'), ('payload_off', '{"mac":"d0bae46447c4","plug_0":{"on":0}}')]), OrderedDict([('platform', 'mqtt'), ('name', 'ketingtc1_2'), ('state_topic', 'homeassistant/switch/d0bae46447c4/plug_1/state'), ('command_topic', 'device/ztc1/set'), ('payload_on', '{"mac":"d0bae46447c4","plug.... (See /config/switchs/ketingTC1.yaml, line 0). Please check the docs at https://home-assistant.io/components/switch/
到底应该如何填写? 求大神教导
|