dream/ 十二月 19, 2018/ home assistant/ 0评论

1. 核心配置文件configuration.yaml

homeassistant:
  #home assistant名称
  name: dts_home_test
  #经纬度
  latitude: 36
  longitude: 120
  #海拔高度
  elevation: 0
  #单位系统 公制/英制 metric/imperial
  unit_system: metric
  #时区
  time_zone: Asia/Shanghai
  #风格化
  customize: !include customize.yaml

#introduction:

#开启前端
frontend:

#开启前端配置UI
config:

# 检查更新
# 注意:该组件会发送信息给home assistant的开发者以提供支持
# 详见 https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # 允许home assistant开发者查看使用了哪些组件
  # include_used_components: true

# 自动发现设备
discovery:

#语音助手
#conversation:
#  intents:
#    TurnOnDevice:
#      - 打开{item}
#      - 开{item}
#      - 把{item}打开
#intent_script:
#      TurnOnDevice:
#        speech:
#          text: 已打开{{ item }}
#        action:
#          service: homeassistant.turn_on
#          data_template: 
#            entity_id: > 
#                    {% if item=="台灯" %} 
#                    light.lamp 

# 历史记录
history:

# 日志
logbook:

# 地图
map:

# 组件sun
#参考 https://www.home-assistant.io/components/sun/
sun:

#通过 home bridge 接入homekit
homekit:

#前端使用SSL。url,ssl证书和密钥文件设置
http:
  base_url: ********.duckdns.org
  ssl_certificate: /home/homeassistant/dehydrated/certs/**********/fullchain.pem
  ssl_key: /home/homeassistant/dehydrated/certs/**********/privkey.pem

#mqtt服务器配置,使用外部服务器 localhost:1883
mqtt:
  broker: 127.0.0.1
  port: 1883
  client_id: home-assistant
  keepalive: 60
  #mqtt 服务器用户名密码
  username: homeassistant
  password: ********
  #可被发现?
  discovery: true
  #是否启用ssl
  tls_insecure: false
  
# 传感器
sensor:
  # yr 天气
  - platform: yr
    name: Weather
    forecast: 24           #未来24小时天气,可有手工按需修改
    monitored_conditions:
      - temperature        #气温
      - precipitation      #雨量
      - windSpeed          #风速
      - pressure           #气压
      - windDirection      #风向
      - humidity           #湿度
  # mqtt测试传感器
  - platform: mqtt
    name: sensot_test
    qos: 0
    unit_of_measurement: 秒
    expire_after: 2     #两秒数据过期
    #不作上线检测
    #availability_topic: "homeassistant/sensor_test/online"
    #payload_available: "online"
    #payload_not_available: "offline"
    state_topic: "homeassistant/sensor_test/data"
    optimistic: false
    retain: true
  #CPU温度
  - platform: command_line
    name: CPU_temperature
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "℃"
    value_template: '{{ value | multiply(0.001) | round(1) }}'
    scan_interval: 1000
  #系统信息检测
  #参考 https://www.home-assistant.io/components/sensor.systemmonitor/
  - platform: systemmonitor
    resources:
      - type: processor_use
      - type: disk_free
        arg: /
      - type: disk_use_percent
        arg: /
      - type: memory_free
      - type: memory_use_percent
      - type: swap_free
      - type: swap_use_percent
      - type: network_in
        arg: wlan0
      - type: network_out
        arg: wlan0
      - type: last_boot

#二元传感器
binary_sensor:
  #树莓派GPIO6
  - platform: rpi_gpio
    ports:
      6: rpi_GPIO6
    bouncetime: 50      #去抖动时间 default:50 ms
    invert_logic: false #反转电平逻辑 true/false  default:fasle(Active high)
    pull_mod: UP        #上拉下拉 UP/DOWN default:UP

#灯      
light:
  #mqtt测试灯
  - platform: mqtt
    state_topic: "light/l1"
    command_topic: "light/l1/set"
    qos: 0
    payload_on: "ON"
    payload_off: "OFF"
    optimistic: true
    retain: true

#开关
switch:
  #树莓派GPIO5
  - platform: rpi_gpio
    ports:
        5: rpi_GPIO5
    invert_logic: false #反转电平逻辑 true/false  default:fasle(Active high)
  #mqtt测试开关
  - platform: mqtt
    name: bedroom_switch
    state_topic: "home/bedroom/switch1"
    command_topic: "home/bedroom/switch1/set"
    #availability_topic: "home/bedroom/switch1/available"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: true
    qos: 0
    retain: true

# 文本转语音
tts:
  #百度云服务
  - platform: baidu
    app_id: *********
    api_key: *****************
    secret_key: ******************
    #语速
    speed: 5
    #音调
    pitch: 5
    #音量
    volume: 5
    #发音人,0为女声,1为男声,3为情感合成度逍遥,4为度丫丫
    person: 0

# Cloud
cloud:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

2. 分组配置文件

weather:
  name: 天气
  view: no
  entities:
    - sensor.weather_temperature
    - sensor.weather_humidity
    - sensor.weather_precipitation
    - sensor.weather_pressure
    - sensor.weather_wind_direction
    - sensor.weather_wind_speed
    - sun.sun
raspberrypi:
  name: 树莓派信息
  view: no
  entities:
    - sensor.CPU_temperature
    - sensor.processor_use
    - sensor.disk_free_
    - sensor.disk_use_percent_
    - sensor.memory_free
    - sensor.memory_use_percent
    - sensor.swap_free
    - sensor.swap_use_percent
    - sensor.network_in_wlan0
    - sensor.network_out_wlan0
    - sensor.last_boot
gpio_rpi:
  name: 树莓派GPIO
  view: no
  entities:
    - binary_sensor.rpi_GPIO6
    - switch.rpi_GPIO5
mqtt_device:
  name: MQTT设备
  view: no
  entities:
    - sensor.sensot_test
    - switch.bedroom_switch

3. 个性化配置文件

sun.sun:
  friendly_name: 太阳
sensor.yr_symbol:
  friendly_name: yr天气
sensor.weather_humidity:
  friendly_name: 湿度
  icon: mdi:water-percent
sensor.weather_precipitation:
  friendly_name: 降水量
  icon: mdi:weather-rainy
sensor.weather_pressure:
  friendly_name: 气压
  icon: mdi:debug-step-over
sensor.weather_temperature:
  friendly_name: 气温
sensor.weather_wind_direction:
  friendly_name: 风向
  icon: mdi:apple-safari
sensor.weather_wind_speed:
  friendly_name: 风速
  icon: mdi:speedometer
group.all_devices: {}
sensor.sensot_test:
  friendly_name: 测试传感器(运行时间)
  icon: mdi:clock
sensor.cpu_temperature:
  friendly_name: CPU 温度
  icon: mdi:thermometer
sensor.disk_free_:
  friendly_name: 剩余硬盘空间(根目录)
sensor.disk_use_percent_:
  friendly_name: 硬盘使用率(根目录)
sensor.last_boot:
  friendly_name: 上次启动时间
sensor.memory_free:
  friendly_name: 剩余内存
sensor.memory_use_percent:
  friendly_name: 内存使用率
sensor.network_in_wlan0:
  friendly_name: 接受数据(wlan0)
sensor.network_out_wlan0:
  friendly_name: 发送数据(wlan0)
sensor.processor_use:
  friendly_name: 处理器使用率
sensor.swap_free:
  friendly_name: 剩余交换空间
sensor.swap_use_percent:
  friendly_name: 交换空间使用率
switch.bedroom_switch:
  friendly_name: 卧室开关

效果图

参考链接和资源链接:

像素图标

home assistant文档组件分组

home assistant组件system monitor

点击数:272

Share this Post

说点什么

avatar
300
  订阅  
提醒