Support for custom notification services
This commit is contained in:
parent
6eafd9af8b
commit
a74ffff976
4 changed files with 15 additions and 4 deletions
|
@ -75,6 +75,8 @@ If set to _somesecretkeynobodycanguess_, you can browse to `https://your.configu
|
|||
HTTP requests include the hostname to which the request has been made. To improve security you can set this parameter to `yourdomain.example.com`. This will check if the hostname within the request matches the one you are expecting. If it does not match, a `403 Forbidden` response will be sent. As a result attackers that scan your IP address won't be able to connect unless they know the correct hostname. Be careful with this option though, because it prohibits you from accessing the configurator directly via IP.
|
||||
#### ENV_PREFIX (string)
|
||||
To modify the default prefix for settings passed as environment variables (`HC_`) change this setting to another value that meets your demands.
|
||||
#### NOTIFY_SERVICE (string)
|
||||
Define a notification service from your Home Assistant setup that should be used to send notifications, e.g. `notify.mytelegram`. The default is `persistent_notification.create`. Do __NOT__ change the value of the `NOTIFY_SERVICE_DEFAULT` variable!
|
||||
|
||||
__Note regarding `ALLOWED_NETWORKS`, `BANNED_IPS` and `BANLIMIT`__:
|
||||
The way this is implemented works in the following order:
|
||||
|
|
|
@ -2,6 +2,7 @@ Version 0.3.0 (2018-)
|
|||
- Allow passing settings via environment variables (Issue #100) @danielperna84
|
||||
- Added basic git stash functionality (Issue #16) @danielperna84
|
||||
- Logging warnings if used passwords are insecure (Issue #100) @danielperna84
|
||||
- Added NOTIFY_SERVICE option @danielperna84
|
||||
|
||||
Version 0.2.9 (2018-06-22)
|
||||
- Material Icons and HASS-help now open in new tab instead of modal (Issues #85 and #34) @danielperna84
|
||||
|
|
|
@ -68,6 +68,9 @@ SESAME = None
|
|||
VERIFY_HOSTNAME = None
|
||||
# Prefix for environment variables
|
||||
ENV_PREFIX = "HC_"
|
||||
# Notification service like `notify.mytelegram`. Default is `persistent_notification.create`
|
||||
NOTIFY_SERVICE_DEFAULT = "persistent_notification.create"
|
||||
NOTIFY_SERVICE = NOTIFY_SERVICE_DEFAULT
|
||||
### End of options
|
||||
|
||||
LOGLEVEL = logging.INFO
|
||||
|
@ -3386,7 +3389,7 @@ def load_settings(settingsfile):
|
|||
global LISTENIP, LISTENPORT, BASEPATH, SSL_CERTIFICATE, SSL_KEY, HASS_API, \
|
||||
HASS_API_PASSWORD, CREDENTIALS, ALLOWED_NETWORKS, BANNED_IPS, BANLIMIT, \
|
||||
DEV, IGNORE_PATTERN, DIRSFIRST, SESAME, VERIFY_HOSTNAME, ENFORCE_BASEPATH, \
|
||||
ENV_PREFIX
|
||||
ENV_PREFIX, NOTIFY_SERVICE
|
||||
settings = {}
|
||||
if settingsfile:
|
||||
try:
|
||||
|
@ -3429,6 +3432,7 @@ def load_settings(settingsfile):
|
|||
DIRSFIRST = settings.get("DIRSFIRST", DIRSFIRST)
|
||||
SESAME = settings.get("SESAME", SESAME)
|
||||
VERIFY_HOSTNAME = settings.get("VERIFY_HOSTNAME", VERIFY_HOSTNAME)
|
||||
NOTIFY_SERVICE = settings.get("NOTIFY_SERVICE", NOTIFY_SERVICE_DEFAULT)
|
||||
|
||||
def is_safe_path(basedir, path, follow_symlinks=True):
|
||||
if basedir is None:
|
||||
|
@ -4537,7 +4541,7 @@ class SimpleServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
|||
def __init__(self, server_address, RequestHandlerClass):
|
||||
socketserver.TCPServer.__init__(self, server_address, RequestHandlerClass)
|
||||
|
||||
def notify(service="persistent_notification.create",
|
||||
def notify(service=NOTIFY_SERVICE,
|
||||
title="HASS Configurator",
|
||||
message="Notification by HASS Configurator",
|
||||
notification_id=None):
|
||||
|
@ -4550,7 +4554,7 @@ def notify(service="persistent_notification.create",
|
|||
"title": title,
|
||||
"message": message
|
||||
}
|
||||
if notification_id:
|
||||
if notification_id and NOTIFY_SERVICE == NOTIFY_SERVICE_DEFAULT:
|
||||
data["notification_id"] = notification_id
|
||||
if HASS_API_PASSWORD:
|
||||
headers["x-ha-access"] = HASS_API_PASSWORD
|
||||
|
@ -4579,6 +4583,7 @@ def main(args):
|
|||
problems = password_problems(HASS_API_PASSWORD, "HASS_API_PASSWORD")
|
||||
if problems:
|
||||
data = {
|
||||
"service": NOTIFY_SERVICE,
|
||||
"title": "HASS Configurator - Password warning",
|
||||
"message": "Your HASS API password seems insecure (%i). " \
|
||||
"Refer to the HASS configurator logs for further information." % problems,
|
||||
|
@ -4591,6 +4596,7 @@ def main(args):
|
|||
problems = password_problems(SESAME, "SESAME")
|
||||
if problems:
|
||||
data = {
|
||||
"service": NOTIFY_SERVICE,
|
||||
"title": "HASS Configurator - Password warning",
|
||||
"message": "Your SESAME seems insecure (%i). " \
|
||||
"Refer to the HASS configurator logs for further information." % problems,
|
||||
|
@ -4603,6 +4609,7 @@ def main(args):
|
|||
problems = password_problems(":".join(CREDENTIALS.split(":")[1:]), "CREDENTIALS")
|
||||
if problems:
|
||||
data = {
|
||||
"service": NOTIFY_SERVICE,
|
||||
"title": "HASS Configurator - Password warning",
|
||||
"message": "Your CREDENTIALS seems insecure (%i). " \
|
||||
"Refer to the HASS configurator logs for further information." % problems,
|
||||
|
|
|
@ -15,5 +15,6 @@
|
|||
"DIRSFIRST": false,
|
||||
"SESAME": null,
|
||||
"VERIFY_HOSTNAME": null,
|
||||
"ENV_PREFIX": "HC_"
|
||||
"ENV_PREFIX": "HC_",
|
||||
"NOTIFY_SERVICE": "persistent_notification.create"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue