Allow for overriding the DoorBird push notification URL in configuration (#13268)
* Allow for overriding the DoorBird push notification URL in configuration * rename override config key
This commit is contained in:
parent
507c658fe9
commit
170763ef2f
1 changed files with 12 additions and 2 deletions
|
@ -22,6 +22,7 @@ DOMAIN = 'doorbird'
|
||||||
API_URL = '/api/{}'.format(DOMAIN)
|
API_URL = '/api/{}'.format(DOMAIN)
|
||||||
|
|
||||||
CONF_DOORBELL_EVENTS = 'doorbell_events'
|
CONF_DOORBELL_EVENTS = 'doorbell_events'
|
||||||
|
CONF_CUSTOM_URL = 'hass_url_override'
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
|
@ -29,6 +30,7 @@ CONFIG_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
vol.Required(CONF_USERNAME): cv.string,
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
vol.Required(CONF_PASSWORD): cv.string,
|
||||||
vol.Optional(CONF_DOORBELL_EVENTS): cv.boolean,
|
vol.Optional(CONF_DOORBELL_EVENTS): cv.boolean,
|
||||||
|
vol.Optional(CONF_CUSTOM_URL): cv.string,
|
||||||
})
|
})
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
|
@ -61,9 +63,17 @@ def setup(hass, config):
|
||||||
# Provide an endpoint for the device to call to trigger events
|
# Provide an endpoint for the device to call to trigger events
|
||||||
hass.http.register_view(DoorbirdRequestView())
|
hass.http.register_view(DoorbirdRequestView())
|
||||||
|
|
||||||
|
# Get the URL of this server
|
||||||
|
hass_url = hass.config.api.base_url
|
||||||
|
|
||||||
|
# Override it if another is specified in the component configuration
|
||||||
|
if config[DOMAIN].get(CONF_CUSTOM_URL):
|
||||||
|
hass_url = config[DOMAIN].get(CONF_CUSTOM_URL)
|
||||||
|
_LOGGER.info("DoorBird will connect to this instance via %s",
|
||||||
|
hass_url)
|
||||||
|
|
||||||
# This will make HA the only service that gets doorbell events
|
# This will make HA the only service that gets doorbell events
|
||||||
url = '{}{}/{}'.format(
|
url = '{}{}/{}'.format(hass_url, API_URL, SENSOR_DOORBELL)
|
||||||
hass.config.api.base_url, API_URL, SENSOR_DOORBELL)
|
|
||||||
device.reset_notifications()
|
device.reset_notifications()
|
||||||
device.subscribe_notification(SENSOR_DOORBELL, url)
|
device.subscribe_notification(SENSOR_DOORBELL, url)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue