
## Installation of home-assistant on Synology

Follow https://www.home-assistant.io/installation/alternative/:

The steps would be:

* Install “Docker” package on your Synology NAS

* Launch Docker-app and move to “Registry”-section

* Find “homeassistant/home-assistant” within registry and click on “Download”. Choose the “stable” tag.

* Wait for some time until your NAS has pulled the image

* Move to the “Image”-section of the Docker-app

* Click on “Launch”

* Choose a container-name you want (e.g., “homeassistant”)

* Click on “Advanced Settings”

* Set “Enable auto-restart” if you like

* Within “Volume” click on “Add Folder” and choose either an existing
  folder or add a new folder. The “mount path” has to be “/config”, so
  that Home Assistant will use it for the configs and logs. It is
  therefore recommended that the folder you choose should be named
  “config” or “homeassistant/config” to avoid confusion when
  referencing it within service calls. 

* Within “Network” select “Use same network as Docker Host”

* To ensure that Home Assistant displays the correct timezone go to
the “Environment” tab and click the plus sign then add variable = TZ &
value = Europe/London choosing your correct timezone

* Confirm the “Advanced Settings”

* Click on “Next” and then “Apply”

* Your Home Assistant within Docker should now run and will serve the
  web interface from port 8123 on your Docker host (this will be your
  Synology NAS IP address - for example http://10.0.0.142:8123, dethlefsen:8123) 


## Update and restart HA on Synology in Docker

Remark: to update your Home Assistant on your Docker within Synology NAS, you just have to do the following:

* Go to the Docker-app and move to “Registry”-section

* Find “homeassistant/home-assistant” within registry and click on
  “Download”. Choose the “stable” tag.
  
* Wait until the system-message/-notification comes up, that the
  download is finished (there is no progress bar)
  
* Move to “Container”-section

* Stop your container if it’s running

* Right-click on it and select “Action”->“Reset”. You won’t lose any
  data, as all files are stored in your configuration-directory

* Start the container again - it will then boot up with the new Home
  Assistant image
 
Remark: to restart your Home Assistant within Synology NAS, you just have to do the following:

* Go to the Docker-app and move to “Container”-section

* Right-click on it and select “Action”->“Restart”.


## Install git on Synology via SynoCommunity (https://synocommunity.com/)

Install the SynoCommunity package source
Install ‘git’ using the package manager
Now you can use ‘git’ commands from the CLI while SSHed into the
Synology.


## Install Gitea via Docker

https://thomes.blog/2020/12/09/how-to-gitea-on-synology/

## Synology infrastructure stack

Hvis Synology genstarter, er det let at ende med at Mosquitto, Gitea DB og Gitea ikke kommer op i korrekt rækkefølge.

Denne repo indeholder derfor også en compose-baseret variant i [docker-compose.infrastructure.yml](docker-compose.infrastructure.yml) med:

* `restart: unless-stopped` på Mosquitto, Gitea DB og Gitea
* healthchecks på alle tre services
* `depends_on` så Gitea først starter når databasen er healthy
* Gitea-vaerdier justeret til at spejle den nuvaerende interne `app.ini`-opsaetning

Brug den sammen med en lokal `.env.infrastructure` baseret på [.env.infrastructure.example](.env.infrastructure.example).

Det giver en mere robust opstart end manuelt oprettede containere i Synology UI, især efter NAS-reboot.

### Sikker migration fra Synology UI til compose

Hvis du vil flytte Mosquitto, Gitea DB og Gitea fra Synology UI til compose uden datatab, saa goer det i denne raekkefoelge:

1. Bekraeft at paths i `.env.infrastructure` matcher de eksisterende mounts i Synology UI.
2. Tag backup af mindst disse mapper: `/volume1/docker/gitea/data`, `/volume1/docker/gitea/db` og Mosquitto `config`, `data`, `log`.
3. Eksporter eller tag screenshots af nuvaerende container-indstillinger i Synology UI, saa porte, mounts og miljoevariabler kan sammenlignes bagefter.
4. Stop foerst `gitea`, derefter `gitea-db` og til sidst `mosquitto` i Synology UI.
5. Lad containerne blive liggende i UI i foerste omgang, men undgaa at starte dem igen under testen.
6. Kør compose-stakken med samme data-mounts, saa de nye containere genbruger eksisterende data i stedet for at initialisere nyt dataindhold.
7. Start foerst `gitea-db` og vent til den er healthy.
8. Start derefter `gitea` og kontroller at login, repositories og push virker som foer.
9. Start `mosquitto` og kontroller at Home Assistant reconnecter, og at dørklokker eller andre MQTT-afhaengige funktioner virker igen.
10. Naar alt virker stabilt, kan de gamle UI-oprettede containere slettes eller deaktiveres permanent.

Praktisk testsekvens efter migration:

* Aabn Gitea og bekraeft at repos og historik er intakte.
* Test et `git pull` og et lille `git push` mod Gitea.
* Bekraeft at Home Assistant kan ramme MQTT igen.
* Ring paa en doerklokke eller test en anden MQTT-trigger.

Vigtig regel: genbrug eksisterende data-paths under hele migrationen. Den stoerste risiko er ikke compose-filen, men at man ved en fejl starter en ny tom database eller en ny tom Gitea-data-mappe.

En kort cutover-version findes i [dokumenter/infrastructure_cutover_checklist.md](dokumenter/infrastructure_cutover_checklist.md).

## use git version control on the local gitea client
https://community.home-assistant.io/t/sharing-your-configuration-on-github/195144

Ensure a sensible .gitignore and secrets.yaml

git init
git config user.email "you@example.com"
git config user.name "Your Name"
git add .
git commit

(use gitea instead of github)

Make repos on gitea and use the commands at the initial page to do
git remote add origin


http://dethlefsen:12080/
(claus og Moulin Rouge)

## Editing in Emacs

Now, the synology homeassistant drive can be mounted and files be
opened in Emacs

Use the VC mode
https://www.youtube.com/watch?v=0YlYX_UjH5Q
CTRL-x v CTRL-h

C-x v v : vc-next-action

C-c C-c : commit  (C-c C-e to amend)

C-x v P

## Initial configuration

Setup admin user

# Add Persons and Zones as "customize"

* Add customize: persons, zones, sensors

* In the UI, add users under 'persons'. Copy images into www/

## Discoverable integrations

See the secrets.yaml for details

* Sonos

* Synology DSM

* Hue Bridge. Kræver man trykker på Hue bridge knappen.

* Officejet pro 8600

* HASS bridge (homekit). Opret nyt hjem og derindefra (tilføj tilbehør) scan QR koden. En masse spørgsmål...

* Google Cast

* Denon AVR-X2300W

* Plex

* MediaAccess TG799vac Xtream (Router)

## HACS

https://www.reddit.com/r/homeassistant/comments/munj6h/cant_install_hacs_in_homeassistant_in_docker_on/

* do it manually, download latest ver. from here https://github.com/hacs/integration/releases/tag/1.12.4
Step 1+2 Downloading and unzipping is straightforward

* copy zip content to your system homeassistant\custom_components\hacs

* restart your Home Assistant server

* search for hacs integration like explained in Initial Configuration> https://hacs.xyz/docs/configuration/basic

* if the integration don't show, try it with other browser or clear cache

## Additional official integrations

* powerview (add IP)

* Tile

* IFTTT

 - For at sende hændelser til Home Assistant skal du bruge handlingen "Foretag en web-forespørgsel" fra [IFTTT Webhook-applet] (https://ifttt.com/maker_webhooks).

 - Udfyld følgende oplysninger:

 - Webadresse: http://10.0.0.142:8123/api/webhook/f293046b797af1316cbbd2f2c1766ba8e9bddead77178fba1756ccfbb33a2ba0
 
 - Metode: POST
 
 - Indholdstype: application/json

* Netatmo

* Gogogate

* Foscam

* icloud (med familien). Een for hver apple-id (2-faktor godkendelse)

* speedtest.net

* Unifi network. Need to be running on Mac Mini. In dropdown, choose which "IP-adresses" (MAC numbers) that should have a switch.block_... created.

* spotify. Need to go to anneclaus.duckdns.org to setup integration. And in spotify, use the duckdns adress.

* Melcloud

* whithings. Opret konto (med kvadratisk foto, hvid baggrund, max 300kb). Callback url skal være duckdns.

* Home Connect. Redirecturl: http://anneclaus.duckdns.org:8123/auth/external/callback. Og så skal integrationen tilføjes fra anneclaus.duckdns.org:8123

## Unofficial integrations via HACS

* Sonoff lan

* Garbage collection

* Garmin connect (first HACS and then as integration)

* Miele. Do not let 1password autofill. The country should not me Miele Denmark. Try https://www.miele.com/developer/swagger-ui/swagger.html and authorize. May need the base_url. May need to run from local IP address.

* Eloverblik https://github.com/JonasPed/homeassistant-eloverblik. Did not show up in integrations, but used another browser after restart to "refresh cache"


## Other integrations (in configuration)

* Touchline (climate)

## Check this out - official

* google maps travel time

* mobile app. I think it is included when the iphones register the app's.

* samsung smart tv

* shopping list

* irobot roomba


## Check this out - HACS

* Google home


## Check this out - non-Hacs non-official

* rejseplanen https://www.home-assistant.io/integrations/rejseplanen/

* google calendar


* sonos alarm. Obsolete?

## Check this out - automations

* Sunrise effect. https://community.home-assistant.io/t/wake-up-light-alarm-with-sunrise-effect/255193?fbclid=IwAR2a2yckeftExa1Gec5WkstiGPProsws0dODAAbBrBoBsmdY1wbz4cDHHbs

* Blueprint to control light. https://gist.github.com/rvdlee/2af667b095d783d44395ba25798217aa


* Stue thermostat EQ3. https://www.home-assistant.io/integrations/eq3btsmart/

* checkout (Gollum) https://github.com/gollum/gollum/ wiki for docker (and git))

## Lovelace

### non-HACS

* Lovelace_gen https://github.com/thomasloven/hass-lovelace_gen

### HACS

* mini-graph-card