Add netgear_lte.disconnect_lte service (#25967)

This commit is contained in:
Anders Melchiorsen 2019-08-16 00:59:08 +02:00 committed by Paulus Schoutsen
parent a64dccc80b
commit 26c99454a6
4 changed files with 24 additions and 12 deletions

View File

@ -43,6 +43,7 @@ EVENT_SMS = "netgear_lte_sms"
SERVICE_DELETE_SMS = "delete_sms"
SERVICE_SET_OPTION = "set_option"
SERVICE_CONNECT_LTE = "connect_lte"
SERVICE_DISCONNECT_LTE = "disconnect_lte"
ATTR_HOST = "host"
ATTR_SMS_ID = "sms_id"
@ -122,6 +123,8 @@ SET_OPTION_SCHEMA = vol.Schema(
CONNECT_LTE_SCHEMA = vol.Schema({vol.Optional(ATTR_HOST): cv.string})
DISCONNECT_LTE_SCHEMA = vol.Schema({vol.Optional(ATTR_HOST): cv.string})
@attr.s
class ModemData:
@ -199,18 +202,20 @@ async def async_setup(hass, config):
await modem_data.modem.set_autoconnect_mode(autoconnect)
elif service.service == SERVICE_CONNECT_LTE:
await modem_data.modem.connect_lte()
elif service.service == SERVICE_DISCONNECT_LTE:
await modem_data.modem.disconnect_lte()
hass.services.async_register(
DOMAIN, SERVICE_DELETE_SMS, service_handler, schema=DELETE_SMS_SCHEMA
)
service_schemas = {
SERVICE_DELETE_SMS: DELETE_SMS_SCHEMA,
SERVICE_SET_OPTION: SET_OPTION_SCHEMA,
SERVICE_CONNECT_LTE: CONNECT_LTE_SCHEMA,
SERVICE_DISCONNECT_LTE: DISCONNECT_LTE_SCHEMA,
}
hass.services.async_register(
DOMAIN, SERVICE_SET_OPTION, service_handler, schema=SET_OPTION_SCHEMA
)
hass.services.async_register(
DOMAIN, SERVICE_CONNECT_LTE, service_handler, schema=CONNECT_LTE_SCHEMA
)
for service, schema in service_schemas.items():
hass.services.async_register(
DOMAIN, service, service_handler, schema=schema
)
netgear_lte_config = config[DOMAIN]

View File

@ -3,7 +3,7 @@
"name": "Netgear lte",
"documentation": "https://www.home-assistant.io/components/netgear_lte",
"requirements": [
"eternalegypt==0.0.8"
"eternalegypt==0.0.9"
],
"dependencies": [],
"codeowners": []

View File

@ -27,3 +27,10 @@ connect_lte:
host:
description: The modem that should connect.
example: 192.168.5.1
disconnect_lte:
description: Ask the modem to close the LTE connection.
fields:
host:
description: The modem that should disconnect.
example: 192.168.5.1

View File

@ -455,7 +455,7 @@ epson-projector==0.1.3
epsonprinter==0.0.9
# homeassistant.components.netgear_lte
eternalegypt==0.0.8
eternalegypt==0.0.9
# homeassistant.components.keyboard_remote
# evdev==0.6.1