2025年2月17日 星期一

Home Assistant再加上Web和USB Camera


Add-ons:增加motionEye


Devices&services:增加motionEye

UI:黃底黑字是新增的

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
views:
  - path: default_view
    title: Home
    cards:
      - type: entities
        entities:
          - person.nfu_demo
      - type: entities
        entities:
          - light.bed_room_light
          - light.live_room_light
        title: Light
      - type: entities
        entities:
          - switch.bed_room_switch
          - switch.live_room_switch
        title: Switch
      - show_name: true
        show_icon: true
        type: button
        entity: binary_sensor.windows_contact
        tap_action:
          action: toggle
      - type: iframe
        url: https://www.nfu.edu.tw
        aspect_ratio: 100%
        title: 國立虎尾科技大學
      - camera_view: auto
        type: picture-glance
        image: https://demo.home-assistant.io/stub_config/kitchen.png
        entities:
          - sensor.sun_next_dawn
          - sensor.sun_next_dusk
        camera_image: camera.camera1
        title: 樹莓派
      - camera_view: auto
        type: picture-glance
        title: 尚虎雲
        image: https://demo.home-assistant.io/stub_config/kitchen.png
        entities:
          - sensor.sun_next_midnight
          - sensor.sun_next_noon
        camera_image: camera.camera2

注意! 這次沒有變化configurations.yaml和automations.yaml

Home Assistant上MQTT電燈和開關測試

 畫面:


開關:


Add-ons:

安裝File editor和Mosquitto。


Devices&services:

安裝MQTT


/homeassistant/configuration.yaml:
# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

mqtt:
    - light:
        - name: Bed room light
          command_topic: "bed_room/light"
        - name: Live room light
          command_topic: "live_room/light"
    - switch:
        - name: Bed room switch
          command_topic: "bed_room/switch"
        - name: Live room switch
          command_topic: "live_room/switch"
    - binary_sensor:
        - name: Windows contact
          state_topic: "home-assistant/window/contact"
          value_template: "{%if is_state(entity_id,\"on\")-%}OFF{%-else-%}ON{%-endif%}"

  


/homeassistant/automations.yaml

- id: '1739746357824'
  alias: bed light turn on
  description: ''
  triggers:
  - trigger: state
    entity_id:
    - switch.bed_room_switch
    from: 'off'
    to: 'on'
  conditions: []
  actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.bed_room_light
  mode: single
- id: '1739746513220'
  alias: bed light turn off
  description: ''
  triggers:
  - trigger: state
    entity_id:
    - switch.bed_room_switch
    from: 'on'
    to: 'off'
  conditions: []
  actions:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: light.bed_room_light
  mode: single

2025年2月13日 星期四

在Home Assistant上,實作簡易的自動化(Automations)

上一篇文章:在Home Assistant上,實現MQTT Light的功能

本篇延續上一篇文章,以下是實作當太陽下山就點亮電燈的步驟。

1.請點選設定(Settings),再選擇自動化和情境(Automations & Scenes)。


2.選擇右下方的建立自動化(CREATE AUTOMATION)。


3.建立新的自動化(Create new automation)。


4.選擇新增觸發器(ADD TRIGER)。


5.輸入sun,並選擇sun。


6.選擇Sunset,並設定在太陽下山前半小時點亮,再選擇新增行動(ADD ACTION)。


7.選擇Light。


8.選擇Turn on。


9. 選擇實體(Choose entity)。


10. 選擇MQTT LightEntity。


11.選擇存檔


12.取個名字,儲存檔案。


2025年2月12日 星期三

在Home Assistant上,實現MQTT Light的功能

執行畫面:


按下電燈旁的三個點,會出現電燈的控制開關。



MQTT 測試工具:MQTT Explorer 
初始設定:

按下連線鈕後,就可以在下圖的右邊,下達控制命令,左邊可以監控運作的情形。


畫面布局的指令:


configration.yaml的設定:



在Home Assistant添加MQTT Broker,並測試MQTT

 1.點選Settings後再選Add-ons,然後選右下方的Add-on Store,最後選擇安裝Mosqutto broker。


2.選擇安裝按鈕(INSTALL),安裝Mosquitto broker。


3.安裝完成


4.再選Settings,添加裝置和服務(Devices&Services),再選MQTT ADD選項。

5.選擇SUBMIT選項。

6.完成MQTT安裝。

7.點選mqtt。

8. 測試MQTT,Home Assistant和MQTT Explorer需要同步進行測試。
Home Assistant端:



MQTT Explorer端:
新增一個連線,取名Home assistant(名字可以自訂),Host填上192.168.1.123(要看您的Home Assistant配置的IP),輸入帳號和密碼,再按下連線(CONNECT),然後就可以進行測試。

測試結果:


在Home Assistant添加檔案編輯工具(File editor)和網路分享工具(Samba share)

樹莓派上安裝居家助理(Home Assistant)的文章:

本篇文章將在居家助理上安裝兩個常用的工具,分別是檔案編輯工具(File editor)和網路分享工具(Samba share)。
 
1.選擇Settings,再點選Add-ons。


2.點選添加商店(ADD-ON STORE)

3.點選檔案編輯器(File editor),Samba share等到第9步驟時再點。

4.點選安裝(INSTALL)

5.打開當機重新啟動(Watch dog)和顯示在側邊功能表(Show in sidebar)選項,再按下啟動(START)。

6.等待安裝完成後,點選回到上一頁選項。

7.在側邊功能表上發現檔案編輯器(File editor),選點它。

8.就可以用它來編輯相關文件。

9.請執行第1-3步驟,然後再點選Samba share,再執行安裝(INSTALL)。


10.選點上方的配置選項(Configration)。

11.輸入使用者帳號(Username)和密碼(Password),然後按下方的儲存按鈕(SAVE)。

12. 按下上方資訊選項(Info),並按下啟動選項(START)。

13.等待完成安裝後,點選回到上一層按鈕。

14.再按回到添加商店(Add-on Store)。

15.在添加頁面上已經顯示安裝檔案編輯工具(File editor)和網路分享工具(Samba share)。

16.打開Windows的檔案管理員,並點選網路選項,就可以發現Home Assistant的圖示,點兩下啟動它。

17.就可以看到Home Assistant的登入畫面。