name: home-assistant-snap
title: Home assistant
version: '2021.9.4'
icon: snap/gui/home-assistant-snap.svg
summary: Open source home automation that puts local control and privacy first
description: |
  Home Assistant is a free and open-source software for home automation that is designed to be the central control system for smart home devices with focus on local control and privacy. 

  It can be accessed via a web-based user interface, via companion apps for Android and iOS, or using voice commands via a supported virtual assistant like Google Assistant or Amazon Alexa.
  Home Assistant integrates with over a thousand different devices and services.

  Read more about Home Assistant at
  - https://en.wikipedia.org/wiki/Home_Assistant
  - https://www.home-assistant.io/

  **NOTE!** This is Home Assistant Core (not supervised). 

  Your new installation will be available through your browser at http://localhost:8123/ (or change localhost to any other IP address where the snap packages is installed). You will get a launcher available in your application menu on desktops.

  **Important information about updates**

  Since each major versions of Home Assistant might bring breaking changes, you will **only** auto-update for minor releases. Each major release must be upgraded manually, by switching channel. 

  See available channels in the software center or with 
  `snap info home-assistant-snap`
  Please use the stable versions, e.g `2021.8/stable`. 

  You can switch channel with:

  `
  $ snap switch home-assistant-snap --channel=<channel>
  `

  where `<channel>` could be `2021.8/stable`.

  There is a binary sensor `binary_sensor.updater` that will flip to `true` from `false` whenever there are updates available in a newer channel. Use this to show a notification whenever a new major release is available.

  **Need help?** 

  Please use https://www.home-assistant.io/docs/ for documentation and https://community.home-assistant.io for  help from the community.

  **Necessary plugs**

  Can't connect to your USB (e.g Zigbee, Z-wave, removable drive)?

  See `snap connections home-assistant-snap` for necessary plugs (such as access to USB, removable media etc) and connect them with 

  `$ snap connect home-assistant-snap:<plug>`

  where `<plug>` can be in example `raw-usb`.

  **Required plugs**

  - *network:* allows Home Assistant access to the network.
  - *network-bind:* allows operating as a network service, to run the Home Assistant server.
  - *network-control:* enables the configuration of networking and network namespaces via `ip netns`, providing a wide, privileged access to networking. This is required for the DHCP discovery integration to work which will watch the network for DHCP requests for supported devices and services. To disable this feature you will have to disable the `default_config` from you `configuration.yaml` and disconnect the `network-control` plug with `snap disconnect home-assistant-snap:network-control`.

  **NOTE!** Removing the `default_config` will require you to build up a whole new configuration for Home Assistant. More on what is enabled by default at this link: https://www.home-assistant.io/integrations/default_config/

  **Optional plugs**
  - *raw-usb:* allows access to all connected USB devices via a raw interface.
  - *removable-media*: allows read/write access to mounted removable storage in /media, /run/media and /mnt.
  - *serial-port*: enables access to a specific serial port. This interface is restricted because it provides privileged access to configure serial port hardware. Might require hot-plug support `snap set system experimental.hotplug=true` followed by `systemctl restart snapd`.

  **Available slots**
  - *components:* Load custom components to Home Assistant. You will find the Home Assistant Community Store package here: https://snapcraft.io/home-assistant-hacs - Installations on own risk and note that provided integrations are not tested or guaranteed to work.
  - *bin:* Missing binaries might be in the Home Assistant Toolbox, such as cURL etc. See https://snapcraft.io/home-assistant-toolbox
  - *configurator:* Edit your configuration files with HASS configurator. There is a ready package called Home Assistant Configurator here: https://snapcraft.io/home-assistant-configurator.
# source-code: "https://github.com/home-assistant-snap/home-assistant-snap"
# website: "https://github.com/home-assistant-snap/home-assistant-snap"
# issues: "https://github.com/home-assistant-snap/home-assistant-snap/issues"
# donation: "https://www.paypal.com/donate/?hosted_button_id=69NA8SXXFBDBN"
license: Apache-2.0

base: core20
grade: stable
confinement: strict

architectures:
  - build-on: amd64
  - build-on: arm64
  - build-on: armhf
  # - build-on: ppc64el

layout:
  /usr/local/lib:
    bind: $SNAP/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}
  /etc/pip.conf:
    bind-file: $SNAP_COMMON/pip.conf
  /etc/openzwave:
    bind: $SNAP/openzwave
  /etc/ethertypes:
    bind-file: $SNAP/etc/ethertypes
  /etc/protocols:
    bind-file: $SNAP/etc/protocols
  /etc/services:
    bind-file: $SNAP/etc/services

plugs:
  bin:
    interface: content
    content: executables
    target: $SNAP/shared-bin

slots:
  components:
    interface: content
    content: components
    write: 
      - $SNAP_DATA/custom_components
  configurations:
    interface: content
    write:
      - $SNAP_DATA

apps:
  home-assistant-snap:
    command: bin/hass --config $SNAP_DATA
    command-chain:
      - bin/plug-bin
    daemon: simple
    environment:
      PIP_USER: 1
    restart-condition: always
    plugs: 
      - bluez
      - network
      - network-bind
      - network-control
      - raw-usb
      - serial-port
      - physical-memory-control
      - removable-media
    slots: 
      - components
  open-localhost:
    command: bin/open-localhost
    plugs:
      - desktop
  check-config:
    plugs: 
      - network
    environment:
      PIP_USER: 1
    command: bin/hass --script check_config --config $SNAP_DATA -i

parts:
  homeassistant:
    plugin: python-wot-plugin
    source: https://github.com/home-assistant/core.git
    source-tag: ${SNAPCRAFT_PROJECT_VERSION}
    python-packages:
      - setuptools
      - wheel
      - Cython
      - pip
    build-packages:
      - python3
      - python3-dev
      - python3-setuptools
      - python3-wheel
      - pkg-config
      - autoconf
      - build-essential
      - cmake
      - cython3
      - ffmpeg
      - libavcodec-dev
      - libavdevice-dev
      - libavfilter-dev
      - libavformat-dev
      - libavresample-dev
      - libavutil-dev
      - libffi-dev
      - libglib2.0-dev
      - libglu1-mesa-dev
      - libgpiod-dev
      - libjpeg-dev
      - libopenzwave1.5-dev
      - libpcap0.8-dev
      - libswresample-dev
      - libssl-dev
      - libswscale-dev
      - libudev-dev
      - libxml2-dev
      - libxslt1-dev
      - zlib1g-dev
    stage-packages:
      - freeglut3
      - ffmpeg
      - libglu1-mesa
      - netbase
      - tcpdump
      - libpcap0.8
      - libpcap0.8-dev
      - zlib1g
    stage:
      - -lib/python3.8/site-packages/homeassistant/components/updater
    requirements:
      - requirements_all.txt
    constraints:
      - homeassistant/package_constraints.txt
    override-build: |
      snapcraftctl build
      sed -i 's/include-system-site-packages = false/include-system-site-packages = true/g' $SNAPCRAFT_PART_INSTALL/pyvenv.cfg
    # override-stage: |
    #   snapcraftctl stage
    #   ls -al ${SNAPCRAFT_STAGE}/
    #   echo "WE're here now"
    #   touch ${SNAPCRAFT_STAGE}/etc/ld.so.conf.d/ha-${SNAPCRAFT_ARCH_TRIPLET}.conf
    #   # echo "/usr/lib/home-assistant" > prime/etc/ld.so.conf.d/libc.conf
  updater:
    after: [homeassistant]
    plugin: dump
    source: ./src/components
    source-type: local
    organize:
      '*': lib/python3.8/site-packages/homeassistant/components/
  bins:
    plugin: dump
    source: ./src/bin
    source-type: local
    organize:
      open-localhost: bin/open-localhost
  hooks:
    plugin: dump
    source: ./src/hooks
    source-type: local
    stage-packages:
      - uuid
    organize:
      install: snap/hooks/install
      configure: snap/hooks/configure
      post-refresh: snap/hooks/post-refresh
      connect-plug-bin: snap/hooks/connect-plug-bin
  config:
    plugin: dump
    source: ./src/config
    source-type: local
    organize:
      plug-bin: bin/plug-bin