本帖最后由 lidicn 于 2017-9-9 11:17 编辑
package详细内容,见官方文档
https://home-assistant.io/docs/configuration/packages/
package使用,有种方法。这里推荐用下面这种。其他指定文件的方法,【见官方文档】
第一步:在configuration.yaml增加packages: !include_dir_named packages【注意缩进】
homeassistant:
packages: !include_dir_named packages
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 11.1111
longitude: 111.11
复制代码
第二步:在.homeassisatant文件夹【群晖docker、Hassio都是config文件夹】下新建packages文件夹
第三步:在packeages文件夹下新建yaml
这些yaml文件都是相互独立的配置文件【互不影响】
因此,建议一个yaml 写一个单独的功能模块,出问题了直接将yaml文件移除,这个功能也就移除了。
下面是device.yaml 作为范例
#设备在线
sensor:
- platform: template
sensors:
mate7:
friendly_name: '华为Mate7'
value_template: "{{ 'Online' if is_state('device_tracker.dnawdnbp_lidicnphone', 'home') else 'Offline' }}"
mibox:
friendly_name: '小米盒子'
value_template: "{{ 'Online' if is_state('device_tracker.1048b196afde', 'home') else 'Offline' }}"
notebook:
friendly_name: '渣渣笔记本'
value_template: "{{ 'Online' if is_state('device_tracker.desktopk870tpr', 'home') else 'Offline' }}"
#测速
- platform: speedtest
minute: 30
hour:
- 0
- 6
- 12
- 18
monitored_conditions:
- ping
- download
- upload
#树莓派状态
- platform: command_line
name: CPU温度
command: "cat /sys/class/thermal/thermal_zone0/temp"
unit_of_measurement: "°C"
value_template: '{{ value | multiply(0.001) | round(2) }}'
- platform: systemmonitor
resources:
- type: memory_use_percent
- type: processor_use
- type: last_boot
- type: memory_free
- type: last_boot
- type: since_last_boot
- type: disk_use_percent
arg: /
## Last boot Template
- platform: template
sensors:
since_last_boot_templated:
value_template: >-
{% if states.sensor.since_last_boot.state.count("day") > 0 %}
{{states.sensor.since_last_boot.state.split(",") [0] +
"," +
states.sensor.since_last_boot.state.split(",") [1].split(":") [0] +
" hours, " +
states.sensor.since_last_boot.state.split(",") [1].split(":") [1] +
" minutes" }}
{% else %}
{{ "0 days, " +
states.sensor.since_last_boot.state.split(",") [0].split(":") [0] +
" hours, " +
states.sensor.since_last_boot.state.split(",") [0].split(":") [1] +
" minutes" }}
{% endif %}
group:
device:
name: 我的设备
view: no
entities:
- sensor.mate7
- sensor.mibox
- sensor.notebook
- sensor.speedtest_download
- sensor.speedtest_upload
- sensor.speedtest_ping
raspberryPi:
name: "树莓派状态"
view: false
entities:
- sensor.cpu
- sensor.cpu_use
- sensor.ram_use
- sensor.ram_free
- sensor.disk_use_
- sensor.last_boot
- sensor.since_last_boot_templated
Pcview:
name: "电脑状态"
view: false
entities:
- sensor.glances_cpu_load
- sensor.glances_disk_free
- sensor.glances_disk_use
- sensor.glances_disk_use_2
- sensor.glances_ram_free
- sensor.glances_ram_use
- sensor.glances_ram_use_2
- sensor.glances_running
- sensor.glances_sleeping
- sensor.glances_swap_free
- sensor.glances_swap_use
- sensor.glances_swap_use_2
- sensor.glances_thread
- sensor.glances_total
time:
name: "时间日期"
view: false
entities:
- sensor.date
- sensor.time
- sensor.time_utc
- sensor.sunrise_time
- sensor.sunset_time
- sensor.wedding_countdown
automation:
#电脑电源选项
- alias: z800_restart
trigger:
platform: state
entity_id: input_select.pcoptions
to: "Restart"
action:
- service: shell_command.restart_z800
- alias: z800_shutdown
trigger:
platform: state
entity_id: input_select.pcoptions
to: "Shutdown"
action:
- service: shell_command.shutdown_z800
- alias: z800_sleep
trigger:
platform: state
entity_id: input_select.pcoptions
to: "Sleep"
action:
- service: shell_command.sleep_z800
- alias: z800_hibernate
trigger:
platform: state
entity_id: input_select.pcoptions
to: "Hibernate"
action:
- service: shell_command.hibernate_z800
homeassistant:
customize:
automation.z800_restart:
friendly_name: 渣渣笔记本重启
homebridge_hidden: true
icon: mdi:laptop-windows
automation.z800_shutdown:
friendly_name: 渣渣笔记本关机
homebridge_hidden: true
icon: mdi:laptop-windows
automation.z800_sleep:
friendly_name: 渣渣笔记本睡眠
homebridge_hidden: true
icon: mdi:laptop-windows
automation.z800_hibernate:
friendly_name: 渣渣笔记本待机
homebridge_hidden: true
icon: mdi:laptop-windows
复制代码
检测配置:这个技能极为重要,不掌握 在HA【 寸步难行 】
当你修改了ha目录下的【任意配置文件{yaml}】 注意是只要修改保存了文件,不需要重启HA
如果HA已经无法启动了,那就只能用命令来检测配置文件
Hassio,打开ssh,输入下面命令
hassio homeassistant check
复制代码
Hassbian, 忘记了 。 知道的补充
安装了hassctl的
另外:package下面的自动化,检测配置是检测不出来问题的,一检测就全部自动化报一边错误。因此,刚上手 ,自动化最好在automation.yaml下面写。