mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
- Use docker container via registry.freedombox.org to obtain the package. Specify this in the description. - Mark the app as experimental. - Show information that a dedicated domain is required to host Home Assistant. - Use special YAML loader/dumper to deal with custom YAML tags in configuration file. - Obtain logo file from a test file in code repository with Apache license as the actual logo files are freely licensed. - Write functional tests without accessing the website as a dedicated domain is necessary. Tests: - Functional tests work. - Add a domain 'mydomain.example' using the Names app. Assign this domain in Home Assistant app configuration. In /etc/hosts on the host machine add a mapping from mydomain.example to the IP address of the container/VM. Access the web interface using https://mydomain.example. Home Assistant web interface is available and functional. - After install of the app the configuration.yaml file contains the proxy related lines are expected. - Diagnostics work (expect the URL access). - Re-run setup works. - 'Launch web client' and frontpage shortcut work as expected. - Non-admin users can't connect on port 8123. - Home Assistant is able to establish websocket connection in its web UI. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Django views for Home Assistant app."""
|
|
|
|
import logging
|
|
|
|
from django.contrib import messages
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from plinth.forms import DomainSelectionForm
|
|
from plinth.views import AppView
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class HomeAssistantAppView(AppView):
|
|
"""Show Home Assistant app main view."""
|
|
|
|
app_id = 'homeassistant'
|
|
template_name = 'homeassistant.html'
|
|
form_class = DomainSelectionForm
|
|
|
|
def get_initial(self):
|
|
"""Return the values to fill in the form."""
|
|
initial = super().get_initial()
|
|
component = self.app.get_component('webserverroot-homeassistant')
|
|
initial.update({
|
|
'domain_name': component.domain_get() or '',
|
|
})
|
|
return initial
|
|
|
|
def get_form_kwargs(self):
|
|
"""Return the arguments to instantiate form with."""
|
|
kwargs = super().get_form_kwargs()
|
|
kwargs['show_none'] = True
|
|
return kwargs
|
|
|
|
def form_valid(self, form):
|
|
"""Apply the changes submitted in the form."""
|
|
old_config = self.get_initial()
|
|
new_config = form.cleaned_data
|
|
|
|
is_changed = False
|
|
|
|
def _value_changed(key):
|
|
return old_config.get(key) != new_config.get(key)
|
|
|
|
if _value_changed('domain_name'):
|
|
component = self.app.get_component('webserverroot-homeassistant')
|
|
component.domain_set(new_config['domain_name'] or None)
|
|
is_changed = True
|
|
|
|
if is_changed:
|
|
messages.success(self.request, _('Configuration updated.'))
|
|
|
|
return super().form_valid(form)
|