Raspberry Pi Hass.io - JackieWSC/Onepiece GitHub Wiki

Raspberry Pi - Hass.io

Phrase 1

  • [done] Setup Hassio (HassOs 2.12) on Raspberry Pi
  • [done] Added Broadlink Device
    • [done] Control Samsung TV
    • [done] Control Dalen Light
    • link
  • Added Xiaomi MiJia BLE Sensor
    • need to get the mac address with android phone
    • link
  • [done] Setup Customization
  • [done] Setup Lovelace UI
  • [done] Setup Themes

Installation

  • Download the Hass.io image
  • Download the etcher
  • Use the Etcher to flash the downloaded Hass.io image to SD card
  • Plug the card to raspberry pi
  • Plug the lan and power adapter
  • Wait for 10 mins
  • Access http://hassio.local:8123 for further setup

Configuration (configuration.yaml)

Home Assistant Info setup (HassOS 2.12)

  • Setup the Location, time zone
  • Select the location via google map after HassOS 2.12
# configuration.yaml
homeassistant:
  # Name of the location where Home Assistant is running
  name: Scity's Home
  # Location required to calculate the time the sun rises and sets
  latitude: xx.xx
  longitude: yy.yy
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 80
  # 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: Hongkong
  temperature_unit: C
  # Customization file
  customize: !include customize.yaml

Wifi Setup

  • Format a USB as FAT32 with volume name 'CONFIG'
  • create a folder named 'network' in work
  • create a file named 'my-network'
  • plug the USB to raspberry Pi 3
  • Reference
[connection]
id=my-network
uuid=72111c67-4a5d-4d5c-925e-f8ee26efb3c3
type=802-11-wireless

[802-11-wireless]
mode=infrastructure
ssid=MY_SSID
# Uncomment below if your SSID is not broadcasted
#hidden=true

[802-11-wireless-security]
auth-alg=open
key-mgmt=wpa-psk
psk=MY_WLAN_SECRET_KEY

[ipv4]
method=auto

[ipv6]
addr-gen-mode=stable-privacy
method=auto

Homekit setup

  • Create Name, Username and Password on the Home Assistant Page
  • Home assistant support homekit since 0.64
  • So it can be controlled from Apple’s Home app and Siri
# configuration.yaml
homekit:
  filter:
    include_domains:
      - alarm_control_panel
      - light
      - media_player
  entity_config:
    alarm_control_panel.home:
      code: 1234
    light.kitchen_table:
      name: Kitchen Table Light
    lock.front_door:
      code: 1234
    media_player.living_room:
      feature_list:
        - feature: on_off
        - feature: play_pause
        - feature: play_stop
        - feature: toggle_mute
    switch.bedroom_outlet:
      type: outlet

Apple TV setup

  • Get the login id
    • Service > apple_tv.apple_tv_scan
    • find the info on the first page
  • Get the Credentials
    • Service > apple_tv.apple_tv_authenticate > input the entity "media_player.apple_tv"
    • call apple tv
# configuration.yaml
apple_tv:
  - host: '192.168.31.243'
    login_id: 'login_id'
    name: 'Apple TV'
    start_off: true
    credentials: 'credentials'

Customization

  • Allow you to name the device on font page
  • Allow you to show on/off the device on the font page
  • Allow you to change the icon (add mdi:watch-variant) of devices (https://materialdesignicons.com/)
# customize.yaml
device_tracker.34_7c_25_b4_00_1e:
  friendly_name: Apple Watch
  icon: mdi:watch-variant
sensor.miwifi_router_bytes_received:
  hidden: true
sensor.miwifi_router_bytes_sent:
  hidden: true
switch.dalen_led_on_off: {}
switch.samsung_tv:
  icon: mdi:television
switch.samsung_tv_hdmi:
  icon: mdi:video-input-hdmi
switch.dalen_led_up_down:
  icon: mdi:lightbulb-on-outline
switch.dalen_led_warm_cool:
  icon: mdi:white-balance-sunny

Group and View

  • Group the devices by entities id
  • Create view for group
# group
Device_Tracker_1:
  name: Jackie Devices
  entities:
    - device_tracker.jackies_iphone
    - device_tracker.34_7c_25_b4_00_1e # apple watch
    - device_tracker.scity_ipad_mini 

Device_Tracker_2:
  name: Home Devices
  entities:
    - device_tracker.scitys_imac
    - device_tracker.apple_tv
    - device_tracker.hassio 

Lovelace UI

  • customizable and powerful way for users to manage their homes, working both on mobile and desktop
  • UI Editor. A configuration UI to manage your Lovelace UI including live preview when editing cards.

Lovelace UI - Example

  • vertical card
- cards:
      - type: vertical-stack
        cards:
          - type: markdown
            content: |
              ## Living Room
          - type: horizontal-stack
            cards:
              - type: entity-button
                entity: switch.samsung_tv
                hold_action:
                  action: more-info
                icon: 'mdi:television'
                icon_height: 64px
                name: Samsung TV
                show_icon: true
                show_name: true
                tap_action:
                  action: toggle
                theme: default
              - type: entity-button
                entity: switch.dalen_led_on_off
                hold_action:
                  action: more-info
                icon: 'mdi:lightbulb-outline'
                icon_height: 64px
                name: Dalen
                show_icon: true
                show_name: true
                tap_action:
                  action: toggle
          - type: vertical-stack
            cards:
              - type: entities
                title: Dalen Light
                entities:
                  - entity: switch.dalen_led_warm_cool
                    name: Cool / Warm
                  - entity: switch.dalen_led_up_down
                    name: Dark / Bright
                show_header_toggle: false
          - type: vertical-stack
            cards:
              - type: entities
                title: TV
                entities:
                  - entity: switch.samsung_tv_hdmi
                    name: HDMI
                show_header_toggle: false
  • entity-button
      - entity: switch.samsung_tv
        hold_action:
          action: more-info
        icon: 'mdi:television'
        icon_height: 64px
        name: Samsung TV
        show_icon: true
        show_name: true
        tap_action:
          action: toggle
        theme: default
        type: entity-button

Broadlink

  • How to obtain IR/RF packets
    • Developer Tools > Service
      • Service:broadlink.learn
      • {"host":"192.168.31.136"}
switch:
  - platform: broadlink
    host: 192.168.31.136
    mac: '<mac address>'
    timeout: 15
    switches:
      samsung_tv:
        friendly_name: "Living Room TV"
        command_on: '<get by broadlink.learn service>'
        command_off: '<get by broadlink.learn service>'
      samsung_tv_hdmi:
        friendly_name: "Living Room TV HDMI"
        command_on: '<get by broadlink.learn service>'
        command_off: '<get by broadlink.learn service>'

Weather

  • Create the account on Dark Sky
weather:
  - platform: darksky
    api_key: '<api key>'
    latitude: '22.287121'
    longitude: '114.145313'
    mode: 'hourly'

Addon

Configurator

  • Menu > Hass.io > ADD-ON STORE > Configurator > Install
  • Wait for the config come out, create the username and password and save
{
  "username": "admin",
  "password": null,
  ...
}

e.g.

{
  "username": "jackie",
  "password": "jackie",
  "ssl": false,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "allowed_networks": [
    "192.168.0.0/16",
    "172.30.0.0/16"
  ],
  "banned_ips": [
    "8.8.8.8"
  ],
  "banlimit": 0,
  "ignore_pattern": [
    "__pycache__"
  ],
  "dirsfirst": false,
  "enforce_basepath": false,
  "notify_service": "persistent_notification.create"
}
  • click START and use the OPEN WEB UI to open the apps with username and password

SSH server

  • Allow ssh remote from other computer
  • Menu > Hass.io > ADD-ON STORE > SSH server > Install
  • Wait for the config come out, create the authorized_keys and save
{
  "authorized_keys": [
    "ssh-rsa AKDJD3839...== my-key"
  ],
  "password": ""
}

Samba share

  • allow access the file on hass.io on other computer
  • on mac os: ctrl+k, use smb:http://hassio.local with username and password to mount the driver
{
  "workgroup": "WORKGROUP",
  "username": "hassio",
  "password": "hassio",
  "interface": "",
  "allow_hosts": [
    "10.0.0.0/8",
    "172.16.0.0/12",
    "192.168.0.0/16"
  ]
}

Reference

⚠️ **GitHub.com Fallback** ⚠️