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

 找回密码
 立即注册
查看: 10728|回复: 10

[求助] homeassistant发现不了yeelight和sonoff开关,不知道问题出在哪...

[复制链接]

174

主题

634

帖子

3792

积分

论坛元老

Rank: 8Rank: 8

积分
3792
金钱
3153
HASS币
0
发表于 2018-2-3 22:32:49 | 显示全部楼层 |阅读模式
本帖最后由 ptlzx 于 2018-2-3 23:01 编辑

小米的温湿度感应、门窗感应、人体感应、墙开等等都有,就是yeelight灯和sonoff开关发现不了。不知道问题出在哪里?参考帖子:https://bbs.hassbian.com/thread-405-1-1.html

configuration.yaml内容如下:

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 25.4375
  longitude: [url=tel:119.0260]119.0260[/url]
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 40
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: [url=http://en.wikipedia.org/wiki/List_of_tz_database_time_zones]http://en.wikipedia.org/wiki/List_of_tz_database_time_zones[/url]
  time_zone: Asia/Shanghai
  # Customization file
[color=#ff0000]  customize:[/color]
    binary_sensor.motion_sensor_158d00016dc723:
      friendly_name: 人体传感器
      homebridge_name: 人体传感器
#    homebridge_hidden: true
  
    binary_sensor.door_window_sensor_158d0001f4h3c7:
      friendly_name: 大门开关感应
      homebridge_name: 大门开关感应
  
    sensor.temperature_158d000123r52a:
      friendly_name: 温度
      homebridge_name: 温度
  
    sensor.humidity_158d000123r52a:
      friendly_name: 湿度
      homebridge_name: 湿度
  
    binary_sensor.switch_158d0001bf8271:
      friendly_name: 无线开关
      homebridge_name: 无线开关

    binary_sensor.switch_158d0001f42969:
      friendly_name: 门铃
      homebridge_name: 门铃
  
    switch.wall_switch_158d0001f58666:
      friendly_name: 餐厅灯
      homebridge_name: 餐厅灯
  
    light.gateway_light_7811dca474ae:
      friendly_name: 网关灯
      homebridge_name: 网关灯
  
    sensor.illumination_7811dca474ae:
      friendly_name: 光感应器
      homebridge_name: 光感应器
   
[color=#ff0000]xiaomi_aqara:
  gateways:
    - mac: 7811dca47fae
      key: fcj7e9igc8k8nqdl[/color]
      
[color=#ff0000]mqtt:
  broker: 192.168.1.55
  port: 1883
  client_id: home-assistant
  keepalive: 60
  username: pi
  password: [url=tel:1234567890]1234567890[/url]
  discovery: true[/color]
  
[color=#ff0000]switch:  
  - platform: mqtt
    name: "楼梯灯"
    state_topic: "stat/S4/POWER"
    command_topic: "cmnd/S4/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true[/color]

[color=#ff0000]light:
  - platform: yeelight
    devices:
      192.168.1.104:
        name: 主卧床头灯
        transition: 1000
        use_music_mode: True
        save_on_change: False
#      192.168.1.13:
#        name: Front Door[/color]
    
# Show links to resources in log and frontend
introduction:

# Enables the frontend
frontend:

# Enables configuration UI
config:

http:
  # Secrets are defined in the file secrets.yaml
  # api_password: !secret http_password
  # Uncomment this if you are using SSL/TLS, running in Docker container, etc.
  # base_url: example.duckdns.org:8123

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# [url=https://home-assistant.io/blog/2016/10/25/explaining-the-updater/]https://home-assistant.io/blog/2016/10/25/explaining-the-updater/[/url]
updater:
  # Optional, allows Home Assistant developers to focus on popular components.      
  # include_used_components: true

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:
 
# Weather prediction
sensor:
  - platform: yr
    
tts:
  - platform: google
  
group: !include groups.yaml
automation: !include automations.yaml
#xiaomi: !include xiaomi.yaml
script: !include scripts.yaml


回复

使用道具 举报

35

主题

533

帖子

2895

积分

金牌会员

Rank: 6Rank: 6

积分
2895
金钱
2362
HASS币
0
发表于 2018-2-3 23:38:55 | 显示全部楼层
yeelight是否开启了局域网控制协议?
回复

使用道具 举报

174

主题

634

帖子

3792

积分

论坛元老

Rank: 8Rank: 8

积分
3792
金钱
3153
HASS币
0
 楼主| 发表于 2018-2-3 23:54:08 | 显示全部楼层
debitus 发表于 2018-2-3 23:38
yeelight是否开启了局域网控制协议?

开启了,原来没有安装homeassistant前仅使用homebridge时在homekit里正常控制
回复

使用道具 举报

174

主题

634

帖子

3792

积分

论坛元老

Rank: 8Rank: 8

积分
3792
金钱
3153
HASS币
0
 楼主| 发表于 2018-2-4 08:42:56 | 显示全部楼层
debitus 发表于 2018-2-3 23:38
yeelight是否开启了局域网控制协议?

搞清楚了,yeelight和sonoff的name字段值必须和原名一样,不能直接命名成其他的中文名。请问要如何把他们改成容易识别的中文名。再有就是小米无线开关有单击,双击和长按的自动化代码。我找到相应代码范例但不知道添加在哪里,请指教。
#单击
  - alias: single_button
    initial_state: true
    trigger:
      platform: event
      event_type: click
      event_data:
        entity_id: binary_sensor.switch_158d0000d2def2
        click_type: single
    action:
      service: switch.turn_on
      entity_id: switch.left_button
#双击
  - alias: double_button
    initial_state: true
    trigger:
      platform: event
      event_type: click
      event_data:
        entity_id: binary_sensor.switch_158d0000d2def2
        click_type: double
    action:
      service: switch.turn_on
      entity_id: switch.left_button,switch.right_button
#长按
  - alias: hold_button
    initial_state: true
    trigger:
      platform: event
      event_type: click
      event_data:
        entity_id: binary_sensor.switch_158d0000d2def2
        click_type: long_click_press
    action:
      service: switch.turn_off
      entity_id: switch.left_button,switch.right_button

回复

使用道具 举报

2

主题

196

帖子

1357

积分

金牌会员

Rank: 6Rank: 6

积分
1357
金钱
1161
HASS币
0
发表于 2018-2-4 08:47:30 | 显示全部楼层
本帖最后由 bluefire1982 于 2018-2-4 08:51 编辑

yeelight的配置试试把name的中文名字“主卧床头灯”改为英文。配置中直接写中文容易出问题,汉化在customize里写。至于sonoff配置看不出啥问题,信息量太少。
★Raspberry + Raspbian + Home Assistant v0.1
★树莓派 + Raspbian系统 + HomeAssistant
https://github.com/huangqian8/homeassistant
回复

使用道具 举报

2

主题

196

帖子

1357

积分

金牌会员

Rank: 6Rank: 6

积分
1357
金钱
1161
HASS币
0
发表于 2018-2-4 08:52:50 | 显示全部楼层
自动化写在automations.yaml中
★Raspberry + Raspbian + Home Assistant v0.1
★树莓派 + Raspbian系统 + HomeAssistant
https://github.com/huangqian8/homeassistant
回复

使用道具 举报

174

主题

634

帖子

3792

积分

论坛元老

Rank: 8Rank: 8

积分
3792
金钱
3153
HASS币
0
 楼主| 发表于 2018-2-4 09:43:47 | 显示全部楼层
bluefire1982 发表于 2018-2-4 08:52
自动化写在automations.yaml中

万分感激,刚才试了一下双击的代码,出现错误,能否帮忙看看。

automations.yaml内容:
  - alias: double_button
    initial_state: true
    trigger:
      platform: event
      event_type: click
      event_data:
        entity_id: binary_sensor.switch_158d0001bf2271 //这个是小米无线开关有三个动作:点击、双击、长按
        click_type: double
    action:
      service: switch.toggle  //使用切换操作控制sonoff开关
      entity_id: Sonoff_3  //双击要控制的设备是sonoff开关


错误日志:
Testing configuration at /config
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up mqtt
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up introduction
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up http
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain mqtt took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up recorder
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain introduction took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain http took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain recorder took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up system_log
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up api
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up websocket_api
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up history
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain system_log took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain api took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain websocket_api took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain history took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up frontend
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain frontend took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up discovery
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up sun
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up sensor
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up group
2018-02-04 01:37:21 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Entity ID sonoff_3 is an invalid entity id for dictionary value @ data['action'][0]['entity_id']. Got None. (See /config/configuration.yaml, line 155). Please check the docs at https://home-assistant.io/components/automation/
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up xiaomi_aqara
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up map
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up updater
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain discovery took 0.1 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain sun took 0.1 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain sensor took 0.1 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain group took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain xiaomi_aqara took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain map took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain updater took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up tts
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up config
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up logbook
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up conversation
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain tts took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up script
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up light
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setting up automation
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain config took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain logbook took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain conversation took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain script took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain light took 0.0 seconds.
2018-02-04 01:37:21 INFO (MainThread) [homeassistant.setup] Setup of domain automation took 0.0 seconds.
Failed config
  automation:
    - action: [source /config/automations.yaml:21]
        entity_id: Sonoff_3
        service: switch.toggle
      alias: double_button
      initial_state: True
      trigger: [source /config/automations.yaml:15]
        platform: event
        event_data: [source /config/automations.yaml:18]
          click_type: double
          entity_id: binary_sensor.switch_158d0001bf2271
        event_type: click

Successful config (partial)
  automation:
回复

使用道具 举报

35

主题

533

帖子

2895

积分

金牌会员

Rank: 6Rank: 6

积分
2895
金钱
2362
HASS币
0
发表于 2018-2-4 13:08:28 | 显示全部楼层
“entity_id: Sonoff_3 ”entity_id是不是不完整啊?
可以在Developer tools的states界面查看对应的名称。
回复

使用道具 举报

174

主题

634

帖子

3792

积分

论坛元老

Rank: 8Rank: 8

积分
3792
金钱
3153
HASS币
0
 楼主| 发表于 2018-2-4 13:47:56 | 显示全部楼层
debitus 发表于 2018-2-4 13:08
“entity_id: Sonoff_3 ”entity_id是不是不完整啊?
可以在Developer tools的states界面查看对应的名称。 ...

谢谢,是你说的问题,名字改了启动正常了。但是sonoff的service: switch.toggle操作没有反映,甚至换成:service: switch.turn_on也没有反映,但是直接在界面上控制sonoff_4又正常。

- alias: double_button
  initial_state: true
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d0001bf2271
      click_type: double
  action:
    service: switch.toggle
    entity_id: light.sonoff_4
回复

使用道具 举报

2

主题

196

帖子

1357

积分

金牌会员

Rank: 6Rank: 6

积分
1357
金钱
1161
HASS币
0
发表于 2018-2-5 08:17:11 | 显示全部楼层
ptlzx 发表于 2018-2-4 13:47
谢谢,是你说的问题,名字改了启动正常了。但是sonoff的service: switch.toggle操作没有反映,甚至换成:s ...
action:
    service: switch.toggle
    entity_id: light.sonoff_4


这段代码写的有问题啊,你到底控制的是什么,第2行写switch,第3行控制的又是light,不一致啊。你再仔细看看教程里的代码。
★Raspberry + Raspbian + Home Assistant v0.1
★树莓派 + Raspbian系统 + HomeAssistant
https://github.com/huangqian8/homeassistant
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-23 11:59 , Processed in 0.054204 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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