Sensor scripts selection #68

This commit is contained in:
tomaae 2020-12-12 12:30:05 +01:00
parent 3efe6d451b
commit d07b6c3004

View file

@ -39,6 +39,8 @@ from .const import (
DEFAULT_SENSOR_CLIENT_TRAFFIC,
CONF_SENSOR_SIMPLE_QUEUES,
DEFAULT_SENSOR_SIMPLE_QUEUES,
CONF_SENSOR_SCRIPTS,
DEFAULT_SENSOR_SCRIPTS,
)
from .exceptions import ApiEntryNotFound
from .helper import parse_api
@ -179,6 +181,16 @@ class MikrotikControllerData:
CONF_SENSOR_SIMPLE_QUEUES, DEFAULT_SENSOR_SIMPLE_QUEUES
)
# ---------------------------
# option_sensor_scripts
# ---------------------------
@property
def option_sensor_scripts(self):
"""Config entry option to not track ARP."""
return self.config_entry.options.get(
CONF_SENSOR_SCRIPTS, DEFAULT_SENSOR_SCRIPTS
)
# ---------------------------
# option_scan_interval
# ---------------------------
@ -317,7 +329,7 @@ class MikrotikControllerData:
if self.api.connected():
await self.hass.async_add_executor_job(self.get_system_health)
if self.api.connected():
if self.api.connected() and self.option_sensor_scripts:
await self.hass.async_add_executor_job(self.get_script)
if self.api.connected():