Skip to content

Latest commit

 

History

History
139 lines (105 loc) · 7.36 KB

Test.md

File metadata and controls

139 lines (105 loc) · 7.36 KB

Testing EMHASS-Add-on

To test EMHASS-Add-on integration, you will need a Home Assistant (with Supervisor) environment.

The common Home Assistant options are:

  • Adding EMHASS-Add-on into a pre-existing Home Assistant environment.
  • Testing EMHASS-Add-on on a Home Assistant inside a vertual test environment (Using VS-Code).

See the following steps for both options.

The following examples are for testing the EMHASS-Add-on integration (Docker wrapper of EMHASS for Home Assistant). To develop/test the EMHASS Packadge itself, check EMHASS Develop page.

See Test EMHASS-Add-On build for an example of testing Home Assistants Docker image build.

Develop on VS-Code DevContainer with Home Assistant test environment

Using VS-Code DevContainers, you can generate a Home Assistant test environment for the Add-on before release. We can pull a version of the EMHASS package (required with EMHASS-Add-on) from a Git repo/branch, or via pip. Alternately, we can specify different pre-built EMHASS-Add-On versions (EMHASS-Add-On Docker images) from DockerHub.

See the following steps:

  • DockerHub:
    • Edit the version line from from config.yml to pull different versions of EMHASS-Add-On via DockerHub
  • Git/pip:
    • Comment out image: "davidusb/image-{arch}-emhass" line from config.yml. This will tell the addon to build from the local Dockerfile and not pull Image from DockerHub

    • Git

      • Change build_version: addon in build.yaml to build_version: addon-git. (This overrides the pip version of EMHASS specified via requirements.txt)
      • To specify the Git repo and branch, change lines accordingly in build.yaml.
        • repo: #build_repo: https://github.com/davidusb-geek/emhass.git #addon-git mode
        • branch: #build_branch: master #addon-git mode
    • pip

      • Change emhass version in requirements.txt to pull EMHASS via pip version.
        • You may need to modify the other python packages to different versions to match
  • Finally
    • Run (if not already) the VS-Code DevContainer (Shortcut: F1 > Dev Containers: Rebuild and Reopen in Container) - This requires DevContainers to be operational. See visualstudio.com - Developing inside a Container for more info
    • Start VS-Code Task to start Home Assistant (ctrl+shift+p>Tasks: Run Task> Start Home Assistant)
      • Login to the generated HA Portal: localhost:7123
      • Navigate to Home Assistant: Add-ons > ADD-ON STORE
      • Install/Run and Test Add-on

Note: If, on run, the emhass version looks off. Try: uninstalling Add-on, check for updates on Add-on Store page, and re-installing.
If you have chosen Git, also try removing the emhass python package from requirements.txt .

Adding EMHASS-Add-on into pre-existing Home Assistant environment

If you would like to test a version of EMHASS-Add-on inside a pre-existing Home Assistant (with Supervisor) environment, see the following steps:

  • With your preferred method of choice, clone the emhass-add-on repository to the addons folder

  • With your preferred method of choice, indicate which EMHASS package to build with (image), or specify what built DockerHub version of EMHASS-Add-on (version) to use, in section of config.yml file:

    • Comment out the image line image: "davidusb/image-{arch}-emhass" if you wish to pull a EMHASS version from pip or Git repo/branch
      • ssh example:
        sed -i.bak '/image:/ s/./#&/' ~/addons/emhass-add-on/emhass/config.yml
    • Change version if you would like to pull in an older version of EMHASS-Add-on (pre built Docker image) from DockerHub (Default state)
      • ssh example:
        emhassVersion=0.6.5
        sed -i.bak "s/version:.*/version: $emhassVersion/g"  ~/addons/emhass-add-on/emhass/config.yml
  • If you want EMHASS from pip:

    • To specify the EMHASS pip version, modify the emhass version number in requirements.txt
      • ssh example:
        emhassVersion=0.7.7
        sed -i.bak "s/emhass==.*/emhass==$emhassVersion/g"  ~/addons/emhass-add-on/emhass/requirements.txt
  • If you want EMHASS from Git:

    • Tell the Add-on to use Git, and specify what EMHASS repo and branch you would like to pull.

      • To tell Docker to pull from Git, change the build argument from addon to addon-git in the build.yaml.
        • ssh example:
          sed -i.bak "s/build_version:.*/build_version: addon-git/g"  ~/addons/emhass-add-on/emhass/build.yaml
      • To specify the EMHASS Git repository and branch values, (optional) change lines in build.yaml:
        • #build_repo: https://github.com/davidusb-geek/emhass.git #addon-git mode

        • #build_branch: master #addon-git mode _

        • ssh example:

          repo=https://github.com/daviasdasdsasddusb-geek/emhass.git
          branch=masaddasdasdter
          
          sed -i.bak "s%build_repo:\s.*%build_repo: $repo%g"  ~/addons/emhass-add-on/emhass/build.yaml
          sed -i.bak "s/build_branch:\s.*/build_branch: $branch/g"  ~/addons/emhass-add-on/emhass/build.yaml
  • Finally:

    • head to Home Assistant: Add-ons > ADD-ON STORE
      • you should see an EMHASS Add-on under Local add-ons
        • If you don't, try hamburger button (3 dots) on top right > check updates > refresh page
    • Install and test Add-on
    • Use the Supervisor logs (on the config/logs page) to see any logs with the Add-on.

Note: If, on run, the emhass version looks off. Try: uninstalling Add-on, check for updates on Add-on Store page, and re-installing.
If you have chosen Git, also try removing the emhass python package from requirements.txt .

Test EMHASS-Add-On build

You can test the EMHASS-Add-On docker image build using the Home Assistant builder.

emhass-add-on local repo

Linux example:

architecture=amd64 #your host machine architecture

docker run --rm --privileged -v ~/.docker:/root/.docker -v ${PWD}:/data ghcr.io/home-assistant/${architecture}-builder:latest --test --${architecture} --target /data/emhass

confirm terminal directory is in root emhass-add-on folder

emhass-add-on Git repo

Linux example:

architecture=amd64 #your host machine architecture

repo=https://github.com/davidusb-geek/emhass-add-on.git #repo example
branch=main #branch example

docker run --rm --privileged -v ~/.docker:/root/.docker ghcr.io/home-assistant/${architecture}-builder:latest --test --${architecture} --target emhass -r ${repo} -b ${branch}