This commit is contained in:
Erimus MBA 2020-01-08 00:02:14 +08:00
commit 8fb321f66f
19 changed files with 1474 additions and 0 deletions

1
.HA_VERSION Normal file
View File

@ -0,0 +1 @@
0.103.5

70
.gitignore vendored Normal file
View File

@ -0,0 +1,70 @@
# home assistant root
.homekit.state
.uuid
*.sublime-workspace
home-assistant.log
home-assistant_v2.db
secrets.yaml
deps/
icloud/
# .storage
.storage/*
!.storage/lovelace
# custom_components
custom_components/hacs/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

306
.storage/lovelace Normal file
View File

@ -0,0 +1,306 @@
{
"data": {
"config": {
"custom_header": {
"background": "black",
"chevrons": false,
"compact_mode": true,
"disabled_mode": true,
"editor_warnings": false,
"hidden_tab_redirect": false,
"shadow": false
},
"resources": [
{
"type": "module",
"url": "/community_plugin/mini-graph-card/mini-graph-card-bundle.beta.js"
}
],
"title": "Home 402",
"views": [
{
"badges": [],
"cards": [
{
"cards": [
{
"cards": [
{
"entity": "group.all_switches",
"icon_height": "88px",
"show_name": false,
"tap_action": {
"action": "more-info"
},
"type": "entity-button"
},
{
"entity": "group.all_scripts",
"icon_height": "88px",
"show_name": false,
"tap_action": {
"action": "more-info"
},
"type": "entity-button"
},
{
"entity": "group.all_devices",
"icon_height": "88px",
"show_name": false,
"tap_action": {
"action": "more-info"
},
"type": "entity-button"
}
],
"type": "horizontal-stack"
},
{
"cards": [
{
"entity": "switch.light_2",
"icon_height": "88px",
"show_name": false,
"type": "entity-button"
},
{
"entity": "switch.light_3",
"icon_height": "88px",
"show_name": false,
"type": "entity-button"
},
{
"entity": "switch.light_1",
"icon_height": "88px",
"show_name": false,
"type": "entity-button"
}
],
"type": "horizontal-stack"
},
{
"cards": [
{
"entity": "script.media_previous",
"icon_height": "88px",
"show_name": false,
"tap_action": {
"action": "call-service",
"service": "script.media_previous"
},
"type": "entity-button"
},
{
"entity": "script.media_play_pause",
"icon_height": "88px",
"show_name": false,
"tap_action": {
"action": "call-service",
"service": "script.media_play_pause"
},
"type": "entity-button"
},
{
"entity": "script.media_next",
"icon_height": "88px",
"show_name": false,
"tap_action": {
"action": "call-service",
"service": "script.media_next"
},
"type": "entity-button"
}
],
"type": "horizontal-stack"
},
{
"cards": [
{
"entity": "switch.amplifier_mute",
"icon_height": "88px",
"name": "Mute",
"show_name": false,
"type": "entity-button"
},
{
"entity": "script.amplifier_volume_down_10_times",
"icon_height": "88px",
"name": "Vol--",
"show_name": false,
"tap_action": {
"action": "call-service",
"service": "script.amplifier_volume_down_10_times"
},
"type": "entity-button"
},
{
"entity": "script.amplifier_volume_up_10_times",
"icon_height": "88px",
"name": "Vol++",
"show_name": false,
"tap_action": {
"action": "call-service",
"service": "script.amplifier_volume_up_10_times"
},
"type": "entity-button"
}
],
"type": "horizontal-stack"
},
{
"cards": [
{
"entity": "group.theater",
"icon_height": "88px",
"name": "Amplifier",
"show_name": false,
"tap_action": {
"action": "more-info"
},
"type": "entity-button"
},
{
"entity": "switch.aircon_auto",
"icon_height": "88px",
"show_name": false,
"type": "entity-button"
},
{
"entity": "switch.water_pump",
"icon_height": "88px",
"show_name": false,
"type": "entity-button"
}
],
"type": "horizontal-stack"
}
],
"type": "vertical-stack"
},
{
"cards": [
{
"entities": [
{
"entity": "sensor.waqi_pudong_monitoring_station_shanghai_shang_hai_pu_dong_jian_ce_zhan",
"name": "PD"
},
{
"entity": "sensor.waqi_shanghai_us_consulate_shanghai_shang_hai_shang_hai_mei_guo_zong_ling_shi_guan",
"name": "US"
},
{
"entity": "sensor.waqi_shanghai_shang_hai",
"name": "SH"
}
],
"font_size": 75,
"hours_to_show": 48,
"icon": "mdi:skull",
"line_width": 4,
"name": "Shanghai AQI",
"show": {
"fill": false,
"icon": false,
"legend": false,
"name": false
},
"type": "custom:mini-graph-card"
},
{
"entities": [
{
"entity": "sensor.pudong_temperature",
"name": "PD"
},
{
"entity": "sensor.us_consulate_temperature",
"name": "US"
},
{
"entity": "sensor.shanghai_temperature",
"name": "SH"
}
],
"font_size": 75,
"hours_to_show": 48,
"icon": "mdi:thermometer",
"line_width": 4,
"name": "Last 3d Temp",
"show": {
"fill": false,
"icon": false,
"legend": false,
"name": false
},
"type": "custom:mini-graph-card"
}
],
"type": "horizontal-stack"
},
{
"cards": [
{
"aggregate_func": "max",
"entities": [
{
"entity": "sensor.theater_mode_time",
"show_graph": false
},
{
"entity": "sensor.theater_mode_time_daily"
}
],
"font_size": 75,
"group_by": "date",
"hours_to_show": 168,
"icon": "mdi:movie-open",
"refresh_interval": 0,
"show": {
"graph": "bar",
"icon": false,
"name": false
},
"type": "custom:mini-graph-card",
"unit": "h Theater"
},
{
"aggregate_func": "max",
"entities": [
{
"entity": "sensor.aircon_time",
"show_graph": false
},
{
"color": "#e74c3c",
"entity": "sensor.aircon_time_daily"
}
],
"font_size": 75,
"group_by": "date",
"hours_to_show": 168,
"icon": "mdi:fan",
"refresh_interval": 0,
"show": {
"graph": "bar",
"icon": false,
"name": false
},
"type": "custom:mini-graph-card",
"unit": "h Aircon"
}
],
"type": "horizontal-stack"
}
],
"icon": "mdi:home",
"panel": false,
"path": "default_view",
"title": "Home"
}
]
}
},
"key": "lovelace",
"version": 1
}

88
automations.yaml Normal file
View File

@ -0,0 +1,88 @@
# 这个文件记录的是自动化的相关内容。
# 可以在达到某个条件时,触发一系列的操作。
# 回家时
# 这里用的一个临时方案。我tracking的方式有两种iCloud和ping。
# iCloud只能判断设备的大致范围而ping在手机休眠时有可能离线。
# 所以单独用任何一种都无法获得准确的到家时间。
# 现在先通过iCloud判断是否到了家附近是的话打开一个标记home_return_fuzzy。
# 然后通过ping来触发精确的到家时间点。
# ping默认间隔12秒所以到家进门连上设备+被ping到还是会有一点延迟。
# 旧方案是只用iCloud那就会有点提前。
# 开启即将到家的状态
- id: home_return_fuzzy # 这个id没啥卵用 unique就行
alias: Home Return Fuzzy # 这个名称会以下划线替换空格成为id
description: 判断即将到家
trigger:
- entity_id: device_tracker.erimussiphonexr
event: enter
platform: zone
zone: zone.home
condition: []
action:
- service: input_boolean.turn_on # 状态记录器
entity_id: input_boolean.home_return_fuzzy
# 精确的到家时间
- id: home_return_exact
alias: Home Return Exact # 这个名称会以下划线替换空格成为id
description: 回家时开启电器
trigger:
- entity_id: device_tracker.pingiphonexr
platform: state
from: 'not_home'
to: 'home'
condition:
condition: state
entity_id: input_boolean.home_return_fuzzy
state: 'on'
action:
- service: switch.turn_on # 开功放
entity_id: switch.amplifier_power
- service_template: > # 太阳落山的话开灯
{% if is_state('sun.sun','below_horizon') %}switch.turn_on{% endif %}
entity_id:
- switch.light_2_smart
- switch.light_3_smart
- service: shell_command.say_welcom_back # 欢迎问候
- service: shell_command.send_volume_up # wakeup screen
- delay: 5
- service: shell_command.send_next_track # 播放(远程电脑上已开启的播放器)
- service: input_boolean.turn_off # 状态记录器
entity_id: input_boolean.home_return_fuzzy
# 离家时
- id: home_leave
alias: Home Leave
description: 离家时关闭电器
trigger:
- entity_id: device_tracker.erimussiphonexr
event: leave
platform: zone
zone: zone.home
condition: []
action:
- service: switch.turn_off
entity_id:
- switch.amplifier_power
- switch.water_pump
- switch.aircon_power_off
- group.light
- service: input_boolean.turn_off # 状态记录器
entity_id: input_boolean.home_return_fuzzy
# 监听水泵开启在15分钟后自动发送一次关闭命令。防止忘记关水泵。
- id: auto_turn_off_pump
alias: Auto turn off pump
description: 自动关水泵
trigger:
- entity_id: switch.water_pump
platform: state
from: 'off'
to: 'on'
for: 00:15:00
condition: []
action:
- entity_id: switch.water_pump
service: switch.turn_off

149
configuration.yaml Normal file
View File

@ -0,0 +1,149 @@
homeassistant:
# Name of the location where Home Assistant is running
name: Home 402
# Location required to calculate the time the sun rises and sets
latitude: !secret home_latitude # 关于!secret开头的部分请先读readme。
longitude: !secret home_longitude
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: !secret home_elevation
# metric for Metric, imperial for Imperial
unit_system: metric # 单位(公制)
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: Asia/Shanghai # 时区
# Customization file
customize: !include customize.yaml # 关于!include开头的部分请先读readme。
auth_providers:
- type: trusted_networks
trusted_networks:
- 10.0.0.20/30
- ::1
allow_bypass_login: true
- type: homeassistant
group: !include groups.yaml # 分组
automation: !include automations.yaml # 自动化
script: !include scripts.yaml # 脚本/批处理命令
switch: !include switch.yaml # 开关/含博联遥控器命令码
homekit: !include homekit.yaml # 管理homekit出现的项目
# iOS App 需要的部件
default_config:
mobile_app:
discovery: # Discover some devices automatically
ios: # advanced notifications like actionable notifications and categories
# cloud: # securely connecting to your Home Assistant via Nabu Casa
# Show links to resources in log and frontend
# introduction:
# Enables the frontend
frontend:
themes: !include_dir_merge_named themes # 主题
# Enables configuration UI
config: # 在前端显示配置菜单
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# 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:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
# updater:
# Optional, allows Home Assistant developers to focus on popular components.
# include_used_components: true
# 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:
system_health:
# zone常用来判断到达或离开一个地点
# https://www.home-assistant.io/integrations/zone/
zone:
- name: Home
latitude: !secret home_latitude
longitude: !secret home_longitude
radius: 100
icon: mdi:home
# Track the sun 日出/日落/等
sun:
# Sensors 感应器
# https://www.home-assistant.io/integrations/sensor/
sensor: !include sensor.yaml
# weather: # 天气预报/用不上就先
# - platform: darksky
# api_key: !secret darksky_token
# mode: daily
# Text to speech
# tts: !include tts.yaml
# media_player: !include media_player.yaml
# 故名意思 就是命令行
shell_command: !include shell_command.yaml
# binary_sensor:
# - platform: ping
# host: 10.0.0.22
# count: 2
# scan_interval: 10
# https://www.home-assistant.io/integrations/device_tracker/
device_tracker: # 设备跟踪器
# 使用ping确认手机是否接入局域网
# 在known_devices.yaml添加对应设备可以定义名称等细节
- platform: ping
hosts:
pingiphonexr: 10.0.0.22
# count: 2 # 发包数
# scan_interval: 30
# 使用icloud追踪位置
# 重启后在网页会提示登陆认证,按要求操作即可。
# 成功后会在known_devices.yaml生成icloud包含的设备
- platform: icloud
username: !secret icloud_username
password: !secret icloud_password
account_name: Erimus_iCloud
# max_interval: 3
remote: # 遥控器
- platform: broadlink
host: 10.0.0.30
mac: !secret broadlink_mac
input_boolean:
theater_mode: # 用来记录剧场模式的状态
aircon: # 用来记录空调的状态
home_return_fuzzy: # 用来记录iphone是否即将到家
# 这里重复分组只是为了在homekit自动识别为灯泡否则会识别为开关要手动改图标。
# https://www.home-assistant.io/integrations/homekit/
# 看其中的 Supported Components
light:
- platform: switch
name: Light 1
entity_id: switch.light_1
- platform: switch
name: Light 2
entity_id: switch.light_2
- platform: switch
name: Light 3
entity_id: switch.light_3

82
customize.yaml Normal file
View File

@ -0,0 +1,82 @@
# 这里可以用来自定义一些显示图标和名称统一管理省得写在lovelace里。
# https://www.home-assistant.io/docs/configuration/customizing-devices/
# 图标都是mdi:name的形式
# 在这个网站查询图标名称 https://materialdesignicons.com/
switch.amplifier_power:
icon: 'mdi:speaker'
switch.amplifier_mute:
icon: 'mdi:volume-mute'
switch.amplifier_volume_up:
icon: 'mdi:volume-plus'
switch.amplifier_volume_down:
icon: 'mdi:volume-minus'
switch.projector_power:
icon: 'mdi:projector'
switch.screen:
icon: 'mdi:projector-screen'
switch.screen_pause:
icon: 'mdi:pause'
switch.aircon_heat_30:
icon: 'mdi:fire'
switch.aircon_cool_28:
icon: 'mdi:snowflake'
switch.aircon_power_off:
icon: 'mdi:power-standby'
switch.light:
hidden: true # 隐藏使其不在前端出现
switch.light_1:
icon: 'mdi:wall-sconce-flat'
switch.light_2:
icon: 'mdi:ceiling-light'
switch.light_3:
icon: 'mdi:track-light'
switch.light_all:
icon: 'mdi:home-lightbulb'
switch.water_pump:
icon: 'mdi:water-pump'
script.amplifier_volume_up_10_times:
icon: 'mdi:volume-plus'
script.amplifier_volume_down_10_times:
icon: 'mdi:volume-minus'
script.media_play_pause:
icon: mdi:play-pause
script.media_previous:
icon: mdi:skip-backward
script.media_next:
icon: mdi:skip-forward
automation.home_return:
icon: mdi:location-enter
automation.home_leave:
icon: mdi:location-exit
automation.auto_turn_off_pump:
icon: 'mdi:water-pump'
# 让 homekit 能识别这个是空气质量感应器
# https://www.home-assistant.io/integrations/homekit/
sensor.waqi_pudong_monitoring_station_shanghai_shang_hai_pu_dong_jian_ce_zhan:
icon: mdi:skull
friendly_name: AQI
device_class: 'pm25'
group.all_switches:
icon: 'mdi:toggle-switch'
friendly_name: Switches
group.all_scripts:
icon: 'mdi:script-outline'
friendly_name: Scripts
group.all_devices:
icon: 'mdi:cellphone-iphone'
friendly_name: Devices
group.all_automations:
icon: 'mdi:auto-fix'
friendly_name: Automations

41
groups.yaml Normal file
View File

@ -0,0 +1,41 @@
# https://www.home-assistant.io/integrations/group/
light: # 开关时可整组开关
entities:
- switch.light_1_smart
- switch.light_2_smart
- switch.light_3_smart
control: hidden
theater: # 前端有用到
icon: mdi:movie-open
entities:
- switch.theater_mode
- switch.amplifier_power
- switch.projector_power
- switch.screen
- switch.screen_pause
control: hidden
# all_switches:
# control: hidden
# all_scripts:
# control: hidden
# all_automations:
# control: hidden
# amplifier:
# entities:
# - switch.amplifier_power
# - switch.amplifier_mute
# - switch.amplifier_volume_up
# - switch.amplifier_volume_down
# aircon:
# entities:
# - switch.aircon_heat_30
# - switch.aircon_cool_28
# others:
# entities:
# - switch.water_pump

View File

@ -0,0 +1,8 @@
{
"folders":
[
{
"path": "."
}
]
}

46
homekit.yaml Normal file
View File

@ -0,0 +1,46 @@
# 这里控制的是homekit也就是iOS的home app里出现哪些内容。
# https://www.home-assistant.io/integrations/homekit/
filter:
# include_domains:
include_entities: # 要出现的
# Amplifier
- script.amplifier_volume_up_10_times
- script.amplifier_volume_down_10_times
- switch.amplifier_mute
- script.media_play_pause
- script.media_previous
- script.media_next
# Air Conditionor
- switch.aircon_auto
# Lights
- light.light_1
- light.light_2
- light.light_3
# Pump
- switch.water_pump
# Screen
# - switch.screen
# Theater mode
# - script.theater_mode_on
# - script.theater_mode_off
- switch.theater_mode
# Sensor
# 需要在 customize 里设置特定的 device_class 来帮助识别
# 但我仍无法让 Siri 直接播报 AQIiPhone默认可以识别部分国家地区的AQI
- sensor.waqi_pudong_monitoring_station_shanghai_shang_hai_pu_dong_jian_ce_zhan
# exclude_entities: # 要排除的
# - remote.broadlink
entity_config:
switch.water_pump: # 显示为水龙头的图标
type: valve # homekit icon (faucet/outlet/shower/sprinkler/valve)

48
known_devices.yaml Normal file
View File

@ -0,0 +1,48 @@
# 这里是配合configuration.yaml里的device_tracker使用的。
# https://www.home-assistant.io/integrations/device_tracker/
# 通过ping判断手机状态
pingiphonexr: # 这个名称要和device tracker中的一致
hide_if_away: false
icon: mdi:cellphone-iphone
mac: !secret iphone_xr_mac
name: Ping iPhoneXR
picture:
track: true
vendor: Apple, Inc.
# interval_seconds: 12 # default 12
# consider_home: 60 # default 180 只判断离线满xx秒后算离开
# 以下是iCloud自动生成的
erimussiphonexr:
hide_if_away: false
icon: mdi:cellphone-iphone
mac:
name: Erimus's iPhoneXR
picture:
track: true
# consider_home: 60
erimussmba:
hide_if_away: false
icon: mdi:laptop-mac
mac:
name: Erimuss MBA
picture:
track: false
erimussiphone5s:
hide_if_away: false
icon: mdi:cellphone-iphone
mac:
name: Erimuss iPhone5s
picture:
track: false
erimussiphone6:
hide_if_away: false
icon: mdi:face-woman
mac:
name: Erimuss iPhone6
picture:
track: false

18
media_player.yaml Normal file
View File

@ -0,0 +1,18 @@
# 这里有时候是电视等设备,有时候是远程电脑上的媒体播放器。
# https://www.home-assistant.io/integrations/media_player/
# vlc telnet 设置
# vlc播放器内ctrl+P打开设置
# 点左下角显示设置/全部
# 界面/主界面>勾选telnet
# 界面/主界面/lua>lua telnet/密码这里必须设一个密码比如myvlc不然hass里会报无密码没试过留空。
# vlc telnet 获取进度条可能有问题,无法配合下面的网易云,暂时用不上。
# - platform: vlc_telnet
# name: VLC Player
# host: 10.0.0.13
# port: 4212
# password: myvlc
# 网易云音乐(功能还不太完善,就是网页版,无法登陆个人账号。暂时不用。)
# - platform: ha_cloud_music
# api_url: http://localhost:3000

139
scripts.yaml Normal file
View File

@ -0,0 +1,139 @@
# 这里是脚本,可以理解为一些组合命令。
# 不同于automation不会自动触发。
# 虽然script也完全可以写到switch里但有时候为了保持switch简单易读就分离出来。
# https://www.home-assistant.io/integrations/script/
# amplifier ==============================
amplifier_volume_up_10_times:
alias: Amplifier Vol ++
sequence:
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- service: switch.turn_on
entity_id: switch.amplifier_volume_up
- delay: 00:00:00
amplifier_volume_down_10_times:
alias: Amplifier Vol --
sequence:
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- service: switch.turn_on
entity_id: switch.amplifier_volume_down
- delay: 00:00:00
# 发送媒体键 shell command 无法被前端直接调用 套个壳
media_play_pause:
alias: Play/Pause
sequence:
- service: shell_command.send_play_pause
media_previous:
alias: Previous
sequence:
- service: shell_command.send_previous_track
media_next:
alias: Next
sequence:
- service: shell_command.send_next_track
# theater mode ==============================
theater_mode_on:
alias: 'Theater Mode ON'
sequence:
# 状态记录器
- service: input_boolean.turn_on
entity_id: input_boolean.theater_mode
# 放下幕布 不灵敏多按几次
- service: switch.turn_on
entity_id: switch.screen
- service: switch.turn_on
entity_id: switch.screen
- service: switch.turn_on
entity_id: switch.screen
- service: switch.turn_on
entity_id: switch.screen
- service: switch.turn_on
entity_id: switch.screen
- delay: 00:00:10
# 打开投影仪 为了保险多按几次
- service: switch.turn_on
entity_id: switch.projector_power
- service: switch.turn_on
entity_id: switch.projector_power
- service: switch.turn_on
entity_id: switch.projector_power
- delay: 00:00:10
# 关灯
- service: switch.turn_off
entity_id: group.light
theater_mode_off:
alias: 'Theater Mode OFF'
sequence:
# 状态记录器
- service: input_boolean.turn_off
entity_id: input_boolean.theater_mode
# 收起幕布 不灵敏多按几次
- service: switch.turn_off
entity_id: switch.screen
- service: switch.turn_off
entity_id: switch.screen
- service: switch.turn_off
entity_id: switch.screen
- service: switch.turn_off
entity_id: switch.screen
- service: switch.turn_off
entity_id: switch.screen
- delay: 00:00:01
# 关闭投影仪 为了保险多按几次
- service: switch.turn_off
entity_id: switch.projector_power
- delay: 00:00:03
- service: switch.turn_off
entity_id: switch.projector_power
- delay: 00:00:03
- service: switch.turn_off
entity_id: switch.projector_power
- delay: 00:00:03
- service: switch.turn_off
entity_id: switch.projector_power
- delay: 00:00:03
- service: switch.turn_off
entity_id: switch.projector_power
# 开灯 天亮的话就不开
- service: switch.turn_on
data_template:
entity_id: >
switch.light{% if is_state('sun.sun','below_horizon') %}_2_smart{% endif %}

28
secrets_sample.yaml Normal file
View File

@ -0,0 +1,28 @@
# secrets.yaml用来记录隐私信息
# 源文件含隐私信息,不便共享。这个文件是示范文件,给新人参考。
# 你可以把这个文件改名为secrests.yaml然后填上你自己的数据。
# Use this file to store secrets like usernames and passwords.
# Learn more at https://home-assistant.io/docs/configuration/secrets/
# home GPS
home_latitude: 11.1234 # 纬度
home_longitude: 111.1234 # 经度
home_elevation: 11.1234 # 海拔高度
# iCloud
icloud_username: youricloudid@mail.com
icloud_password: yourpassword
# iPhone
iphone_xr_mac: ff:ff:ff:ff:ff:ff
# broadlink mac address
broadlink_mac: ff:ff:ff:ff:ff:ff
# token
waqi_token: 00cb1f56f3c3a8f5fcfd7a0cb9b7241eebca449b
darksky_token: 228faae9a32f7bb0462144255ce8ba11
baidu_tts_app_id: 18081234
baidu_tts_api_key: W57NjC0nhoo1SYU0zy8LdXxx
baidu_tts_secret_key: KeFbGgYPWNr0oIID9matFD6jMCaxhmvv

90
sensor.yaml Normal file
View File

@ -0,0 +1,90 @@
# sensor可以用来获取环境状态等。
# 包括数据服务(天气/比特币价格),和状态检测硬件(报警器/植物检测)等。
# 更多感应器 Integrations - Home Assistant
# https://www.home-assistant.io/integrations/#sensor
# Weather prediction
# - platform: yr
# name: Weather
# forecast: 24
# monitored_conditions:
# - temperature # 温度
# - precipitation # 雨量
# - windSpeed # 风速
# - windDirection # 风向
# - pressure # 气压
# - humidity # 湿度
# AQI 空气质量
# https://www.home-assistant.io/integrations/waqi/
# 需要先请求一个token https://aqicn.org/data-platform/token/
- platform: waqi
token: !secret waqi_token
locations:
- shanghai
# stations:
# - us-consulate
# 获取attribute作为记录
# 不少部件只返回一个状态states但有很多详情在attribute里。
# 可是HA无法直接统计attr的数字所以需要单独提取出来记录一份。
# https://www.home-assistant.io/integrations/template/
- platform: template
sensors:
# darksky_temperature:
# friendly_name: darksky
# unit_of_measurement: '℃'
# value_template: '{{ states.weather.dark_sky.attributes.temperature }}'
pudong_temperature:
friendly_name: pudong
unit_of_measurement: '℃'
value_template: '{{ states.sensor.waqi_pudong_monitoring_station_shanghai_shang_hai_pu_dong_jian_ce_zhan.attributes.temperature }}'
us_consulate_temperature:
friendly_name: us_consulate
unit_of_measurement: '℃'
value_template: '{{ states.sensor.waqi_shanghai_us_consulate_shanghai_shang_hai_shang_hai_mei_guo_zong_ling_shi_guan.attributes.temperature }}'
shanghai_temperature:
friendly_name: shanghai
unit_of_measurement: '℃'
value_template: '{{ states.sensor.waqi_shanghai_shang_hai.attributes.temperature }}'
# 统计使用时间
# https://www.home-assistant.io/integrations/history_stats/
# 剧院模式累计使用时间
- platform: history_stats
name: Theater Mode Time
entity_id: switch.theater_mode
state: 'on'
start: '{{ 0 }}'
end: '{{ now() }}'
# 剧院模式每日使用时间
- platform: history_stats
name: Theater Mode Time Daily
entity_id: switch.theater_mode
state: 'on'
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
# start: '{{ now().replace(minute=0).replace(second=0) }}' # hourly
end: '{{ now() }}'
# 空调累计使用时间
- platform: history_stats
name: Aircon Time
entity_id: switch.aircon_auto
state: 'on'
start: '{{ 0 }}'
end: '{{ now() }}'
# 空调每日使用时间
- platform: history_stats
name: Aircon Time Daily
entity_id: switch.aircon_auto
state: 'on'
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
# start: '{{ now().replace(minute=0).replace(second=0) }}' # hourly
end: '{{ now() }}'

14
shell_command.yaml Normal file
View File

@ -0,0 +1,14 @@
# say_weather: "say \"现在的温度是{{states('sensor.weather_temperature')}}度。湿度百分之{{states('sensor.weather_humidity')}}。风速{{states('sensor.weather_wind_speed')}}, 气压{{states('sensor.weather_pressure')}}。\""
# say_time: 'say "现在是{{now().hour}}点{{now().minute}}分"'
say_welcom_back: 'say "欢迎回家"'
# 以下是利用我写的另一个服务,在一台远程电脑上接收按键命令并在远程机器运行。
# 可以通过发送媒体键,来控制远程电脑上的播放器。
# https://github.com/Erimus-Koo/utility/blob/master/remote_key_service.py
# send_stop: 'curl -v http://10.0.0.13:8836/send?key=stop'
send_play_pause: 'curl http://10.0.0.13:8836/send?key=playpause'
send_previous_track: 'curl http://10.0.0.13:8836/send?key=prevtrack'
send_next_track: 'curl http://10.0.0.13:8836/send?key=nexttrack'
send_volume_up: 'curl http://10.0.0.13:8836/send?key=volumeup' # wakeup screen

200
switch.yaml Normal file
View File

@ -0,0 +1,200 @@
# 开关
# 关于博联万能遥控学习射频码的方式iOS用户可以参考我写的另一个小工具。
# https://github.com/Erimus-Koo/Extract_BroadLink_learned_codes_from_iOS_App
# 非iOS用户可以参考下官方文档。
# https://www.home-assistant.io/integrations/broadlink/
# 我在这里控制了大部分的传统家电和开关。
- platform: broadlink
host: 10.0.0.30
mac: !secret broadlink_mac
timeout: 15
switches:
# amplifier ==============================
amplifier_power:
friendly_name: Amplifier Power
command_on: JgBYAAABKpIVERQ1FTUVNhU1FTUVNRURFDUVERQSFBEUERQRFBIUNhQRFDYUERQ2FBIUNRURFBEUNRUSEzYVERQ2FBEUNRU1FQAFHgABKkgVAAxeAAEqSBUADQU=
command_off: JgBYAAABKpIVERQ1FTUVNhU1FTUVNRURFDUVERQSFBEUERQRFBIUNhQRFDYUERQ2FBIUNRURFBEUNRUSEzYVERQ2FBEUNRU1FQAFHgABKkgVAAxeAAEqSBUADQU=
# 这类遥控器虽然开关是同一个键但还是要写on和off。
# 简化方案是可以把off写成''但在调用的时候也只能对应用switch.trun_on。
# 但是如果投射到homekit它会区分开关状态并调用trunoff所以只能复制一遍。
amplifier_mute:
friendly_name: Amplifier Mute
command_on: JgBQAAABJ5QSEhI3EhISNxI3EjcSNxISEjcSEhI3EhISEhISEhISNxISEhISNxI3EjcSEhISEhISNxI3EhISEhISEjcSNxI3EgAFJQABJ0oSAAxS
command_off: JgBQAAABJ5QSEhI3EhISNxI3EjcSNxISEjcSEhI3EhISEhISEhISNxISEhISNxI3EjcSEhISEhISNxI3EhISEhISEjcSNxI3EgAFJQABJ0oSAAxS
amplifier_volume_up:
friendly_name: Amplifier Vol +
command_on: JgBQAAABJ5QSEhI3EhISNxI3EjcSNxISEjcSEhI3EhISEhISEhISNxISEjcSEhI3EjcSEhISEhISNxISEjcSEhISEjcSNxI3EgAFJQABJ0oSAAxS
command_off: ''
amplifier_volume_down:
friendly_name: Amplifier Vol -
command_on: JgBQAAABJ5QSEhI3EhISNxI3EjcSNxISEjcSEhI3EhISEhISEhISNxI3EjcSEhI3EjcSEhISEhISEhISEjcSEhISEjcSNxI3EgAFJQABJ0oSAAxS
command_off: ''
# projector ==============================
projector_power:
friendly_name: Projector
command_on: JgBUAAABFocUEBIQExASEBMxFDETMxIyE4gTMhMQExASEBMQEhATMRQQEgADtQABFYgTEBIREhATEBIyEzEUMRQxE4gUMhIREhASERIQExASMhMQEwANBQAAAAA=
command_off: JgBUAAABFYgTDxQPEw8UDxMyEzITMRQxFIcUDxMyEw8UDxMQEw8TMhMPFAADtAABFYgTEBMPExASEBQxEzITMhMyE4gTDxQxExATDxQPEw8UMRMQEwANBQAAAAA=
# air conditioner ==============================
aircon_heat_30:
friendly_name: Aircon Heating 30℃
command_on: JgAWAnI2DycPDQ8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDycPDQ8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDycPDQ8nDycPJw8nDycPJw8NDycPJw8nDycPJw8nDycPJw8nDw0PDQ8NDw0PDQ8NDw0PDQ8NDw0PJw8nDw0PDQ8nDycPJw8nDw0PDQ8nDycPDQ8NDw0PJw8NDw0PJw8NDw0PJw8nDw0PJw8nDw0PJw8nDw0PJw8nDw0PDQ8nDw0PDQ8NDw0PDQ8nDycPDQ8nDycPJw8NDw0PDQ8nDycPJw8nDw0PJw8nDycPDQ8NDw0PDQ8nDw0PDQ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w0PJw8NDycPJw8NDycPJw8nDw0PJw8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDycPJw8nDycPJw8nDycPJw8NDw0PDQ8NDw0PDQ8NDw0PJw8nDycPJw8nDycPJw8nEgABSA==
command_off: ''
aircon_power_off:
friendly_name: Aircon Power OFF
command_on: ''
command_off: JgAWAnI2DycPDQ8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDycPDQ8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDycPDQ8nDycPJw8nDycPJw8NDycPJw8nDycPJw8nDycPJw8nDw0PDQ8NDw0PDQ8NDw0PDQ8NDw0PJw8nDw0PDQ8nDycPJw8nDw0PDQ8nDycPDQ8NDw0PJw8NDw0PJw8NDw0PJw8nDw0PJw8nDw0PJw8nDw0PJw8nDw0PDQ8nDw0PDQ8NDw0PDQ8nDycPDQ8nDycPJw8NDw0PJw8NDw0PDQ8NDw0PJw8nDw0PJw8nDycPJw8nDw0PDQ8NDw0PDQ8NDw0PDQ8nDycPJw8nDycPJw8nDycPDQ8NDw0PDQ8NDw0PDQ8NDycPJw8nDycPJw8nDycPJw8NDw0PDQ8NDw0PDQ8NDw0PJw8nDycPJw8nDycPJw8nDw0PDQ8NDw0PDQ8NDw0PDQ8nDycPJw8nDycPJw8nDycPDQ8NDw0PDQ8NDw0PDQ8NDycPJw8nDycPJw8nDycPJw8nDycPJw8NDycPDQ8nDw0PDQ8NDw0PJw8NDycPDQ8nDycPDQ8NDw0PDQ8NDycPJw8NDycPJw8nDycPJw8NDw0PDQ8NDw0PDQ8NDw0PDQ8NDycPJw8nDycPJw8nDycPJw8NDw0PDQ8NDw0PDQ8NDw0PJw8nDycPJw8nDycPJw8nEgABSA==
# RF Lights ==============================
light: # 空开关
friendly_name: Fake Light
command_on: ''
command_off: ''
light_1:
friendly_name: Light 1
command_on: eQAYAQgXCRYJFwgXCBcZBwgXCBcJFgoWGAcYBxkGGQcJFhgHCRcJFgkWCRYKFgkWGA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AcJFgkWCvAJFwkWCBcJFwkWGAcIGAgWCRcJFhkHFwcZBxgHCBcYBwkWCRcJFQoWGQcYBgoWCBcJ8QkWCRYKFgkWCRYZBgoWCBcJFgkXGAYZBxkGGAAF3AAAAAA=
# RF Pump ==============================
water_pump:
friendly_name: Pump
command_on: sgc0AAoaChoLGhwJHAkKAAENHAgcCAoaCxoLGhwIHAgcCBwIChocCBwIHAgcCAoaHAgcCAoaCxkAAAAA
command_off: shA0ABwIHAkKGhwIHAgcCBwIChocCRwJChoLGgsaChoKGgoaHAgLAAEPHAgcCAoaChoKGhwIHAgAAAAA
# RF Screen ==============================
screen:
friendly_name: Screen
command_on: eB0yAAgSCBIVBhUGFAYIEhUGFQYIEhUGCBMIEgnAFQYVBhQGCBIVBQgSFQYIEgkSFQYVBRUFAAAAAAAA
command_off: eBYyABUGFQYUBggSFAYIEhUGCRIIEhUGFAYVBgkSCBIVBhUGFAYIEhUGFAYIEggSFQYIEgnAAAAAAAAA
screen_pause:
friendly_name: Screen Pause
command_on: eAwyABUGFQUVBggSFQUIExUGCBIIEhUGFQYVBggTCBIVBhUGFAYIEhUGFQYVBggSCBIIEgjAAAAAAAAA
command_off: eAwyABUGFQUVBggSFQUIExUGCBIIEhUGFQYVBggTCBIVBhUGFAYIEhUGFQYVBggSCBIIEgjAAAAAAAAA
# fake switches ==============================
# 下面是一些【假的】开关,可以赋予开关一些条件判断。
# https://www.home-assistant.io/integrations/switch.template/
- platform: template
switches:
# 剧院模式 ==============================
# 这里是把两组script组合成为一个开关这样在前端调用时就比较简洁。
# 这里面的input_boolean相当于一个状态记录器写在configration里。
# 关于这部分可以参考我的一个提问,和网友的解答。
# https://community.home-assistant.io/t/make-scripts-as-toggle-switch
theater_mode:
friendly_name: Theater Mode
icon_template: mdi:movie-open
value_template: "{{ is_state('input_boolean.theater_mode', 'on') }}"
turn_on:
- service: script.theater_mode_on
turn_off:
- service: script.theater_mode_off
# 这里也可以考虑把命令罗列出来但剥离为script会让这个按钮本身简洁易读。
# 空调根据温度开启 ==============================
# 这里是根据当前温度,判断空调开启是制冷还是制热。
# 其中温度数据来自sensor.pudong_temperature
# 空调的红外命令是一个组合数据,通过各个位置控制模式/温度/风力/等等,比较复杂。没找到现成的组合命令的轮子,就直接记录了两个状态的完整命令。
aircon_auto:
friendly_name: Aircon
icon_template: mdi:fan
value_template: "{{ is_state('input_boolean.aircon', 'on') }}"
turn_on:
- service: input_boolean.turn_on
entity_id: input_boolean.aircon # recorder
- service: switch.turn_on
data_template:
entity_id: >
{% if states('sensor.pudong_temperature') | float < 15 %}
switch.aircon_heat_30
{% elif states('sensor.pudong_temperature') | float > 25 %}
switch.aircon_cool_28
{% endif %}
turn_off:
- service: input_boolean.turn_off
entity_id: input_boolean.aircon # recoder
- service: switch.turn_off
entity_id:
- switch.aircon_power_off
# 如果在这里增加关闭制冷和制热那两个独立switch的状态可能因为同时发出命令太多会导致关闭失败。所以就不管那两个了。
# 根据灯的状态决定是否开关 ==============================
# 因为我的灯是开关为同一个键的射频接收器,所以开关命令是一样的。
# 开的状态下再发送一次开会导致关灯。vice versa
# 所以增加一组智能开关。让它关灯时不再发送命令导致开灯,反之亦然。
# 这里switch.turn_on等命令如果作用在不存在的实体上好像会导致错误所以还造了一个假的开关switch.light发送的是空命令。
# 同时为了代码剥离还是保留了原switch。
# 而且偶尔射频发射失败原switch便于在不改变状态的情况下发送指令。
light_1_smart:
friendly_name: Light 1 smart
icon_template: mdi:wall-sconce-flat
value_template: "{{ states('switch.light_1') }}"
turn_on:
service: switch.turn_on
data_template:
entity_id: >
switch.light{% if is_state('switch.light_1', 'off') %}_1{% endif %}
turn_off:
service: switch.turn_off
data_template:
entity_id: >
switch.light{% if is_state('switch.light_1', 'on') %}_1{% endif %}
light_2_smart:
friendly_name: Light 2 smart
icon_template: mdi:ceiling-light
value_template: "{{ states('switch.light_2') }}"
turn_on:
service: switch.turn_on
data_template:
entity_id: >
switch.light{% if is_state('switch.light_2', 'off') %}_2{% endif %}
turn_off:
service: switch.turn_off
data_template:
entity_id: >
switch.light{% if is_state('switch.light_2', 'on') %}_2{% endif %}
light_3_smart:
friendly_name: Light 3 smart
icon_template: mdi:track-light
value_template: "{{ states('switch.light_3') }}"
turn_on:
service: switch.turn_on
data_template:
entity_id: >
switch.light{% if is_state('switch.light_3', 'off') %}_3{% endif %}
turn_off:
service: switch.turn_off
data_template:
entity_id: >
switch.light{% if is_state('switch.light_3', 'on') %}_3{% endif %}

View File

@ -0,0 +1,126 @@
erimus-dark-mode:
# text
primary-text-color: '#DDD' # most text
secondary-text-color: '#888'
text-primary-color: '#FFF' # text on main header & most primary-color
disabled-text-color: '#468'
# main interface colors
primary-color: '#F80' # 主要是标题
main-color: '#F80' # instead of primary color
dark-primary-color: '#D82' # mostly in dev panel
light-primary-color: '#444' # account icon
accent-color: '#F80' # the pencil icon for edit
divider-color: rgba(128, 128, 128, .1)
scrollbar-thumb-color: rgb(128, 128, 128, .1)
error-color: 'red'
error-state-color: var(--error-color)
# states and badges
state-icon-color: '#369' # icon truned off (gray blue)
state-icon-active-color: '#FF0' # icon truned on (light yellow)
state-icon-unavailable-color: var(--disabled-text-color)
# background and sidebar
card-background-color: rgba(128, 128, 128, .2)
primary-background-color: '#000'
secondary-background-color: '#000' # popup card header background
# sidebar menu
sidebar-text-color: var(--primary-text-color)
sidebar-background-color: '#000' # just work on bottom part / other follows card
sidebar-icon-color: var(--primary-text-color)
sidebar-selected-text-color: var(--main-color)
sidebar-selected-icon-color: var(--main-color)
# controls
switch-checked-color: var(--main-color) # flash icon selected
switch-unchecked-color: rgba(127, 127, 127, .25) # flash icon unselected(not work)
# toggle button (a circle handle on a track)
switch-checked-button-color: var(--main-color) # circle handle
switch-checked-track-color: var(--switch-checked-color)
switch-unchecked-button-color: var(--primary-text-color) #circle handle
switch-unchecked-track-color: rgba(0,0,0,.5)
# slider
slider-color: var(--main-color)
slider-secondary-color: var(--light-primary-color)
slider-bar-color: var(--disabled-text-color)
# for label-badge
label-badge-background-color: var(--card-background-color)
label-badge-text-color: var(--primary-text-color)
label-badge-red: '#DF4C1E'
label-badge-blue: '#039be5'
label-badge-green: '#0DA035'
label-badge-yellow: '#f4b400'
label-badge-grey: var(--paper-grey-500)
# Paper-styles color.html dependency is stripped on build.
# When a default paper-style color is used, it needs to be copied
# from paper-styles/color.html to here.
paper-grey-50: '#fafafa' # default for: --mwc-switch-unchecked-button-color
paper-grey-200: '#eeeeee' # for ha-date-picker-style
paper-grey-500: '#9e9e9e' # --label-badge-grey
# for paper-spinner
google-red-500: '#db4437'
google-blue-500: '#4285f4'
google-green-500: '#0f9d58'
google-yellow-500: '#f4b400'
paper-spinner-color: var(--main-color)
# for paper-slider
paper-green-400: '#66bb6a'
paper-blue-400: '#42a5f5'
paper-orange-400: '#ffa726'
# opacity for dark text on a light background
dark-divider-opacity: 0.12
dark-disabled-opacity: 0.38 # or hint text or icon
dark-secondary-opacity: 0.54
dark-primary-opacity: 0.87
# opacity for light text on a dark background
light-divider-opacity: 0.12
light-disabled-opacity: 0.3 # or hint text or icon
light-secondary-opacity: 0.7
light-primary-opacity: 1.0
# derived colors, to keep existing themes mostly working
paper-card-background-color: var(--card-background-color)
paper-listbox-background-color: var(--card-background-color)
paper-item-icon-color: var(--state-icon-color)
paper-item-icon-active-color: var(--state-icon-active-color)
table-row-background-color: var(--primary-background-color)
table-row-alternative-background-color: var(--secondary-background-color)
# set our slider style
paper-slider-knob-color: var(--slider-color)
paper-slider-knob-start-color: var(--slider-color)
paper-slider-pin-color: var(--slider-color)
paper-slider-active-color: var(--slider-color)
paper-slider-secondary-color: var(--slider-secondary-color)
paper-slider-container-color: var(--slider-bar-color)
ha-paper-slider-pin-font-size: 15px
# set data table style
data-table-background-color: var(--card-background-color)
# rgb
rgb-primary-color: 3, 169, 244
rgb-accent-color: 255, 152, 0
rgb-primary-text-color: 33, 33, 33
rgb-secondary-text-color: 114, 114, 114
rgb-text-primary-color: 255, 255, 255
# mwc
mdc-theme-primary: var(--main-color) # config page
mdc-theme-secondary: var(--accent-color)
mdc-theme-background: var(--primary-background-color)
mdc-theme-surface: var(--paper-card-background-color, var(--card-background-color))
# mwc text styles
mdc-theme-on-primary: var(--text-primary-color)
mdc-theme-on-secondary: var(--text-primary-color)
mdc-theme-on-surface: var(--primary-text-color)
# app header background color
app-header-text-color: var(--text-primary-color)
app-header-background-color: '#000' # header bg
# CARD
ha-card-border-radius: 0
# GLOBAL
background: black

19
tts.yaml Normal file
View File

@ -0,0 +1,19 @@
# tts是文本转语音服务。text to speech
# 一般是用来把文字转为声音文件,然后发送给播放器,以实现语音播报的效果。
# 文件会保存在ha根目录的tts目录里可能需要定期去手动清除一下。
# mac用户可以直接用系统自带的say命令更加方便。
# 百度tts
# - platform: baidu
# #app_idapi_keysecret_key从百度云上注册得到
# app_id: !secret baidu_tts_app_id
# api_key: !secret baidu_tts_api_key
# secret_key: !secret baidu_tts_secret_key
# #speed语速0-9缺省5
# #pitch语调0-9缺省5
# #volume音量0-15缺省5
# #person声音013百度合成4百度合成缺省0
# speed: 5
# pitch: 5
# volume: 15
# person: 0

File diff suppressed because one or more lines are too long