Closed GeoDerp closed 4 months ago
Note: these methods are still developmental. Somethings act slightly differently then they should. However, the hope is that this will be an assistance for developers that choose to use it. And maybe someone can refine one of these (or both) processes from here.
This looks nice for add-on testing.
To try to emulate even better the add-on environment we could use this image for docker: ghcr.io/home-assistant/amd64-base-debian:bookworm
This looks nice for add-on testing. To try to emulate even better the add-on environment we could use this image for docker:
ghcr.io/home-assistant/amd64-base-debian:bookworm
Good Idea 👍 7171b3564cda7f052097d7cb5c1da72b5a50ca2e
Hi. Could consider your changes to the web_server.py. Were they necessary to implement these new testing methods. I like these new methods but your modifications to the web_server.py invalidates the use of the use_options helper that I'm using for debug (look at the current open review)
Yeah sorry about that. I Should be able to add it back in without a problem. Will check now however
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
195e774
) 89.84% compared to head (9562dcb
) 89.90%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@davidusb-geek Added support to use Environment Variables. I understand that this adds a bit of code. Let me know if you want me to revert any aspects (ex: no ENV support for url and key)
I was also thinking about adding security with the secrets with the use of docker secrets. But since the docker container in question is for development only I thought it was outside of scope.
@davidusb-geek Added support to use Environment Variables. I understand that this adds a bit of code. Let me know if you want me to revert any aspects (ex: no ENV support for url and key)
From what I see in the code the default values are what it was before so it should be ok. I need to take some time to test this further. This week-end...
Merging... Added this page to the wiki as a help following this PR: https://github.com/davidusb-geek/emhass/wiki/Contributing
This is an optional pull request uses VS-Code Dev container or Dockerfile (as an sandboxed environment) for debugging and testing the application. Both of which where designed with focus on running with Add-on mode. And both need an additional HA environment to operate (no supervisor support for the moment)
Method 1: VS-Code Debug and Run
Recommended steps to run are:
emhass
) foulder in VS-Codecontrol+shift+p
>Tasks: Run Task
>EMHASS Install
. This has been set up in the tasks.json file. Re-run this every time a change has been made emhass before run & debug.Run and Debug
tab (Ctrl+Shift+D.) >EMHASS run Addon
. This has been setup in the Launch.json. You will need to modify theEMHASS_URL
(http://HAIPHERE:8123/) andEMHASS_KEY
(PLACEKEYHERE) before running to match your HA environment in order to work. you can also choose to runEMHASS run
. This acts more like standalone mode and uses the secrets file (however less tested)Testing
tab on the left hand sideMethod 2: Dockerfile run
Alternatively: This PR also adds a dockerfile that tries to emulate the Add-on environment as best as possible. This method is slower, however does not need VS-code to run (just Docker environment) Run it on the emhass root dir with: (It is recommended to run this on the host device, rather than an dev container)
Delete docker container and image with:
For Rapid testing try a command chain like this: Bash Example
With example above use
secrets_emhass.yaml
oroptions.yaml
file to set time_zone,Lat,Lon & AltDocker Alternative
We can also pass location, key and url parameters via environment variables
This allows the user to set variables prior to build Linux Example: (in you host terminal)
Note:
secrets_emhass.yaml
instead of passing secret parameters as environment variables/ arguments