Exemplo n.º 1
0
                                                     DeviceScanner)
from homeassistant.const import (CONF_HOST, CONF_PORT, CONF_SSL,
                                 CONF_VERIFY_SSL, CONF_PASSWORD, CONF_USERNAME)

CONF_HTTP_ID = 'http_id'

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Optional(CONF_PORT):
    cv.port,
    vol.Optional(CONF_SSL, default=False):
    cv.boolean,
    vol.Optional(CONF_VERIFY_SSL, default=True):
    vol.Any(cv.boolean, cv.isfile),
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Required(CONF_HTTP_ID):
    cv.string
})


def get_scanner(hass, config):
    """Validate the configuration and returns a Tomato scanner."""
    return TomatoDeviceScanner(config[DOMAIN])


class TomatoDeviceScanner(DeviceScanner):
Exemplo n.º 2
0
CONF_PROTOCOL = 'protocol'
CONF_MODE = 'mode'
DEFAULT_SSH_PORT = 22
CONF_SSH_KEY = 'ssh_key'
CONF_PUB_KEY = 'pub_key'
SECRET_GROUP = 'Password or SSH Key'

PLATFORM_SCHEMA = vol.All(
    cv.has_at_least_one_key(CONF_PASSWORD, CONF_PUB_KEY, CONF_SSH_KEY),
    PLATFORM_SCHEMA.extend({
        vol.Required(CONF_HOST): cv.string,
        vol.Required(CONF_USERNAME): cv.string,
        vol.Optional(CONF_PROTOCOL, default='ssh'):
            vol.In(['ssh', 'telnet']),
        vol.Optional(CONF_MODE, default='router'):
            vol.In(['router', 'ap']),
        vol.Optional(CONF_PORT, default=DEFAULT_SSH_PORT): cv.port,
        vol.Exclusive(CONF_PASSWORD, SECRET_GROUP): cv.string,
        vol.Exclusive(CONF_SSH_KEY, SECRET_GROUP): cv.isfile,
        vol.Exclusive(CONF_PUB_KEY, SECRET_GROUP): cv.isfile
    }))


_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['pexpect==4.0.1']

_LEASES_CMD = 'cat /var/lib/misc/dnsmasq.leases'
_LEASES_REGEX = re.compile(
    r'\w+\s' +
    r'(?P<mac>(([0-9a-f]{2}[:-]){5}([0-9a-f]{2})))\s' +
    r'(?P<ip>([0-9]{1,3}[\.]){3}[0-9]{1,3})\s' +
import logging

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME

_LOGGER = logging.getLogger(__name__)

CONF_DEFAULT_IP = '169.254.1.1'  # This IP is valid for all FRITZ!Box routers.

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_HOST, default=CONF_DEFAULT_IP): cv.string,
    vol.Optional(CONF_PASSWORD, default='admin'): cv.string,
    vol.Optional(CONF_USERNAME, default=''): cv.string
})


def get_scanner(hass, config):
    """Validate the configuration and return FritzBoxScanner."""
    scanner = FritzBoxScanner(config[DOMAIN])
    return scanner if scanner.success_init else None


class FritzBoxScanner(DeviceScanner):
    """This class queries a FRITZ!Box router."""

    def __init__(self, config):
        """Initialize the scanner."""
Exemplo n.º 4
0
from requests.exceptions import RequestException
import voluptuous as vol

from homeassistant.components.device_tracker import (DOMAIN, PLATFORM_SCHEMA,
                                                     DeviceScanner)
from homeassistant.const import (CONF_HOST, CONF_PASSWORD)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['quantum-gateway==0.0.3']

_LOGGER = logging.getLogger(__name__)

DEFAULT_HOST = 'myfiosgateway.com'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
    vol.Required(CONF_PASSWORD): cv.string
})


def get_scanner(hass, config):
    """Validate the configuration and return a Quantum Gateway scanner."""
    scanner = QuantumGatewayDeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


class QuantumGatewayDeviceScanner(DeviceScanner):
    """This class queries a Quantum Gateway."""

    def __init__(self, config):
        """Initialize the scanner."""
Exemplo n.º 5
0
    CONF_DEVICES, ATTR_GPS_ACCURACY, ATTR_LATITUDE,
    ATTR_LONGITUDE, ATTR_BATTERY_LEVEL)

DEPENDENCIES = ['mqtt']

_LOGGER = logging.getLogger(__name__)

GPS_JSON_PAYLOAD_SCHEMA = vol.Schema({
    vol.Required(ATTR_LATITUDE): vol.Coerce(float),
    vol.Required(ATTR_LONGITUDE): vol.Coerce(float),
    vol.Optional(ATTR_GPS_ACCURACY, default=None): vol.Coerce(int),
    vol.Optional(ATTR_BATTERY_LEVEL, default=None): vol.Coerce(str),
}, extra=vol.ALLOW_EXTRA)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(mqtt.SCHEMA_BASE).extend({
    vol.Required(CONF_DEVICES): {cv.string: mqtt.valid_subscribe_topic},
})


@asyncio.coroutine
def async_setup_scanner(hass, config, async_see, discovery_info=None):
    """Set up the MQTT JSON tracker."""
    devices = config[CONF_DEVICES]
    qos = config[CONF_QOS]

    dev_id_lookup = {}

    @callback
    def async_tracker_message_received(topic, payload, qos):
        """Handle received MQTT message."""
        dev_id = dev_id_lookup[topic]
Exemplo n.º 6
0
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.components.device_tracker import (
    PLATFORM_SCHEMA, CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
from homeassistant.const import (
    CONF_HOST, CONF_PORT)

REQUIREMENTS = ['aiofreepybox==0.0.4']

_LOGGER = logging.getLogger(__name__)

FREEBOX_CONFIG_FILE = 'freebox.conf'

PLATFORM_SCHEMA = vol.All(
    PLATFORM_SCHEMA.extend({
        vol.Required(CONF_HOST): cv.string,
        vol.Required(CONF_PORT): cv.port
    }))

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)


async def async_setup_scanner(hass, config, async_see, discovery_info=None):
    """Set up the Freebox device tracker and start the polling."""
    freebox_config = copy.deepcopy(config)
    if discovery_info is not None:
        freebox_config[CONF_HOST] = discovery_info['properties']['api_domain']
        freebox_config[CONF_PORT] = discovery_info['properties']['https_port']
        _LOGGER.info("Discovered Freebox server: %s:%s",
                     freebox_config[CONF_HOST], freebox_config[CONF_PORT])

    scanner = FreeboxDeviceScanner(hass, freebox_config, async_see)
Exemplo n.º 7
0
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

CONF_DHCP_SOFTWARE = 'dhcp_software'
DEFAULT_DHCP_SOFTWARE = 'dnsmasq'
DHCP_SOFTWARES = [
    'dnsmasq',
    'odhcpd',
    'none'
]

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Optional(CONF_DHCP_SOFTWARE, default=DEFAULT_DHCP_SOFTWARE):
        vol.In(DHCP_SOFTWARES),
})


def get_scanner(hass, config):
    """Validate the configuration and return an ubus scanner."""
    dhcp_sw = config[DOMAIN][CONF_DHCP_SOFTWARE]
    if dhcp_sw == 'dnsmasq':
        scanner = DnsmasqUbusDeviceScanner(config[DOMAIN])
    elif dhcp_sw == 'odhcpd':
        scanner = OdhcpdUbusDeviceScanner(config[DOMAIN])
    else:
        scanner = UbusDeviceScanner(config[DOMAIN])
Exemplo n.º 8
0
DEPENDENCIES = ['mqtt']

_LOGGER = logging.getLogger(__name__)

DMSMASQ_JSON_PAYLOAD_SCHEMA = vol.Schema(
    {
        vol.Required("op"): cv.string,
        vol.Required("mac"): cv.string,
        vol.Required("host"): cv.string,
    },
    extra=vol.ALLOW_EXTRA)

CONF_MQTT_TOPIC = 'topic'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(mqtt.SCHEMA_BASE).extend({
    vol.Required(CONF_MQTT_TOPIC):
    cv.string,
})

HOME_MODE_AWAY = 'not_home'
HOME_MODE_HOME = 'home'


async def async_setup_scanner(hass, config, async_see, discovery_info=None):
    """Set up the MQTT tracker."""
    topic = config[CONF_MQTT_TOPIC]
    qos = config[CONF_QOS]

    @callback
    def async_message_received(msg):
        payload = msg.payload
        """Handle received MQTT message."""
Exemplo n.º 9
0
_LOGGER = logging.getLogger(__name__)

CONF_PUB_KEY = 'pub_key'
CONF_SSH_KEY = 'ssh_key'
CONF_REQUIRE_IP = 'require_ip'
DEFAULT_SSH_PORT = 22
SECRET_GROUP = 'Password or SSH Key'

PLATFORM_SCHEMA = vol.All(
    cv.has_at_least_one_key(CONF_PASSWORD, CONF_PUB_KEY, CONF_SSH_KEY),
    PLATFORM_SCHEMA.extend({
        vol.Required(CONF_HOST): cv.string,
        vol.Required(CONF_USERNAME): cv.string,
        vol.Optional(CONF_PROTOCOL, default='ssh'): vol.In(['ssh', 'telnet']),
        vol.Optional(CONF_MODE, default='router'): vol.In(['router', 'ap']),
        vol.Optional(CONF_PORT, default=DEFAULT_SSH_PORT): cv.port,
        vol.Optional(CONF_REQUIRE_IP, default=True): cv.boolean,
        vol.Exclusive(CONF_PASSWORD, SECRET_GROUP): cv.string,
        vol.Exclusive(CONF_SSH_KEY, SECRET_GROUP): cv.isfile,
        vol.Exclusive(CONF_PUB_KEY, SECRET_GROUP): cv.isfile
    }))


_LEASES_CMD = 'cat /var/lib/misc/dnsmasq.leases'
_LEASES_REGEX = re.compile(
    r'\w+\s' +
    r'(?P<mac>(([0-9a-f]{2}[:-]){5}([0-9a-f]{2})))\s' +
    r'(?P<ip>([0-9]{1,3}[\.]){3}[0-9]{1,3})\s' +
    r'(?P<host>([^\s]+))')

# Command to get both 5GHz and 2.4GHz clients
Exemplo n.º 10
0
# Base UUID: 00000000-0000-1000-8000-00805F9B34FB
# Battery characteristic: 0x2a19 (https://www.bluetooth.com/specifications/gatt/characteristics/)
BATTERY_CHARACTERISTIC_UUID = UUID("00002a19-0000-1000-8000-00805f9b34fb")
CONF_TRACK_BATTERY = "track_battery"
CONF_TRACK_BATTERY_INTERVAL = "track_battery_interval"
DEFAULT_TRACK_BATTERY_INTERVAL = timedelta(days=1)
DATA_BLE = "BLE"
DATA_BLE_ADAPTER = "ADAPTER"
BLE_PREFIX = "BLE_"
MIN_SEEN_NEW = 5

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_TRACK_BATTERY, default=False):
    cv.boolean,
    vol.Optional(CONF_TRACK_BATTERY_INTERVAL,
                 default=DEFAULT_TRACK_BATTERY_INTERVAL):
    cv.time_period,
})


def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the Bluetooth LE Scanner."""

    new_devices = {}
    hass.data.setdefault(DATA_BLE, {DATA_BLE_ADAPTER: None})

    def handle_stop(event):
        """Try to shut down the bluetooth child process nicely."""
        # These should never be unset at the point this runs, but just for
        # safety's sake, use `get`.
Exemplo n.º 11
0
https://home-assistant.io/components/device_tracker.xiaomi_miio/
"""
import logging

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (DOMAIN, PLATFORM_SCHEMA,
                                                     DeviceScanner)
from homeassistant.const import (CONF_HOST, CONF_TOKEN)

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_TOKEN):
    vol.All(cv.string, vol.Length(min=32, max=32)),
})

REQUIREMENTS = ['python-miio==0.3.9', 'construct==2.9.41']


def get_scanner(hass, config):
    """Return a Xiaomi MiIO device scanner."""
    from miio import WifiRepeater, DeviceException

    scanner = None
    host = config[DOMAIN].get(CONF_HOST)
    token = config[DOMAIN].get(CONF_TOKEN)

    _LOGGER.info("Initializing with host %s (token %s...)", host, token[:5])
Exemplo n.º 12
0
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.const import HTTP_BAD_REQUEST, HTTP_UNPROCESSABLE_ENTITY
from homeassistant.core import callback
from homeassistant.components.http import HomeAssistantView
from homeassistant.components.device_tracker import PLATFORM_SCHEMA, SOURCE_TYPE_ROUTER

CONF_VALIDATOR = "validator"
CONF_SECRET = "secret"
URL = "/api/meraki"
VERSION = "2.0"

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_VALIDATOR): cv.string,
    vol.Required(CONF_SECRET): cv.string
})


async def async_setup_scanner(hass, config, async_see, discovery_info=None):
    """Set up an endpoint for the Meraki tracker."""
    hass.http.register_view(MerakiView(config, async_see))

    return True


class MerakiView(HomeAssistantView):
    """View to handle Meraki requests."""

    url = URL
    name = "api:meraki"
Exemplo n.º 13
0
ATTR_IS_LOST = "is_lost"
ATTR_RING_STATE = "ring_state"
ATTR_VOIP_STATE = "voip_state"
ATTR_TILE_ID = "tile_identifier"
ATTR_TILE_NAME = "tile_name"

CONF_SHOW_INACTIVE = "show_inactive"

DEFAULT_ICON = "mdi:view-grid"
DEFAULT_SCAN_INTERVAL = timedelta(minutes=2)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Optional(CONF_SHOW_INACTIVE, default=False):
    cv.boolean,
    vol.Optional(CONF_MONITORED_VARIABLES, default=DEVICE_TYPES):
    vol.All(cv.ensure_list, [vol.In(DEVICE_TYPES)]),
})


async def async_setup_scanner(hass, config, async_see, discovery_info=None):
    """Validate the configuration and return a Tile scanner."""
    websession = aiohttp_client.async_get_clientsession(hass)

    config_file = hass.config.path(".{}{}".format(
        slugify(config[CONF_USERNAME]), CLIENT_UUID_CONFIG_FILE))
    config_data = await hass.async_add_job(load_json, config_file)
    if config_data:
        client = await async_login(
Exemplo n.º 14
0
    '204': 'unregistered',
}

SERVICE_SCHEMA = vol.Schema({
    vol.Optional(ATTR_ACCOUNTNAME):
    vol.All(cv.ensure_list, [cv.slugify]),
    vol.Optional(ATTR_DEVICENAME):
    cv.slugify,
    vol.Optional(ATTR_INTERVAL):
    cv.positive_int,
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Optional(ATTR_ACCOUNTNAME):
    cv.slugify,
})


def setup_scanner(hass, config: dict, see, discovery_info=None):
    """Set up the iCloud Scanner."""
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    account = config.get(CONF_ACCOUNTNAME, slugify(username.partition('@')[0]))

    icloudaccount = Icloud(hass, username, password, account, see)

    if icloudaccount.api is not None:
        ICLOUDTRACKERS[account] = icloudaccount
Exemplo n.º 15
0
_LOGGER = logging.getLogger(__name__)

ATTR_ADDRESS = 'address'
ATTR_FULL_NAME = 'full_name'
ATTR_LAST_SEEN = 'last_seen'
ATTR_NICKNAME = 'nickname'

CONF_MAX_GPS_ACCURACY = 'max_gps_accuracy'

CREDENTIALS_FILE = '.google_maps_location_sharing.cookies'

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=30)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Optional(CONF_MAX_GPS_ACCURACY, default=100000): vol.Coerce(float),
})


def setup_scanner(hass, config: ConfigType, see, discovery_info=None):
    """Set up the Google Maps Location sharing scanner."""
    scanner = GoogleMapsScanner(hass, config, see)
    return scanner.success_init


class GoogleMapsScanner:
    """Representation of an Google Maps location sharing account."""

    def __init__(self, hass, config: ConfigType, see) -> None:
        """Initialize the scanner."""
Exemplo n.º 16
0
    DOMAIN,
    PLATFORM_SCHEMA,
    DeviceScanner,
)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_VERIFY_SSL

INTERFACES = 2
DEFAULT_TIMEOUT = 10

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_VERIFY_SSL, default=True):
    cv.boolean,
})


def get_scanner(hass, config):
    """Validate the configuration and return a Linksys AP scanner."""
    try:
        return LinksysAPDeviceScanner(config[DOMAIN])
    except ConnectionError:
        return None


class LinksysAPDeviceScanner(DeviceScanner):
Exemplo n.º 17
0
from homeassistant.helpers.event import track_point_in_utc_time
from homeassistant.components.device_tracker import (
    YAML_DEVICES, CONF_TRACK_NEW, CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL,
    load_config, PLATFORM_SCHEMA, DEFAULT_TRACK_NEW, SOURCE_TYPE_BLUETOOTH)
import homeassistant.util.dt as dt_util

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['pybluez==0.22', 'bt_proximity==0.1.2']

BT_PREFIX = 'BT_'

CONF_REQUEST_RSSI = 'request_rssi'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_TRACK_NEW): cv.boolean,
    vol.Optional(CONF_REQUEST_RSSI): cv.boolean
})


def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the Bluetooth Scanner."""
    # pylint: disable=import-error
    import bluetooth
    from bt_proximity import BluetoothRSSI

    def see_device(mac, name, rssi=None):
        """Mark a device as seen."""
        attributes = {}
        if rssi is not None:
            attributes['rssi'] = rssi
        see(mac="{}_{}".format(BT_PREFIX, mac), host_name=name,
Exemplo n.º 18
0
ATTR_TIME_ZONE = 'time_zone'

WARNED = 'warned'
SOURCE_TYPE = ATTR_SOURCE_TYPE
STATE = ATTR_STATE

SOURCE_TYPE_BINARY_SENSOR = BS_DOMAIN
STATE_BINARY_SENSOR_HOME = STATE_ON

SOURCE_TYPE_NON_GPS = (SOURCE_TYPE_BINARY_SENSOR, SOURCE_TYPE_BLUETOOTH,
                       SOURCE_TYPE_BLUETOOTH_LE, SOURCE_TYPE_ROUTER)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_NAME):
    cv.slugify,
    vol.Required(CONF_ENTITY_ID):
    cv.entity_ids,
    vol.Optional(CONF_TIME_AS, default=TIME_AS_OPTS[0]):
    vol.In(TIME_AS_OPTS),
})


def setup_scanner(hass, config, see, discovery_info=None):
    CompositeScanner(hass, config, see)
    return True


class CompositeScanner:
    def __init__(self, hass, config, see):
        self._hass = hass
        self._see = see
        entities = config[CONF_ENTITY_ID]
Exemplo n.º 19
0
from homeassistant.util import Throttle

# Return cached results if last scan was less then this time ago
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)

_LOGGER = logging.getLogger(__name__)

# Interval in minutes to exclude devices from a scan while they are home
CONF_HOME_INTERVAL = 'home_interval'
CONF_EXCLUDE = 'exclude'

REQUIREMENTS = ['python-nmap==0.6.1']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOSTS): cv.ensure_list,
    vol.Required(CONF_HOME_INTERVAL, default=0): cv.positive_int,
    vol.Optional(CONF_EXCLUDE, default=[]):
        vol.All(cv.ensure_list, vol.Length(min=1))
})


def get_scanner(hass, config):
    """Validate the configuration and return a Nmap scanner."""
    scanner = NmapDeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None

Device = namedtuple('Device', ['mac', 'name', 'ip', 'last_update'])


def _arp(ip_address):
    """Get the MAC address for a given IP."""
Exemplo n.º 20
0
_LOGGER = logging.getLogger(__name__)

# Interface name to track devices for. Most likely one will not need to
# change it from default 'Home'. This is needed not to track Guest WI-FI-
# clients and router itself
CONF_INTERFACE = 'interface'

DEFAULT_INTERFACE = 'Home'
DEFAULT_PORT = 23

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Required(CONF_PORT, default=DEFAULT_PORT):
    cv.port,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_INTERFACE, default=DEFAULT_INTERFACE):
    cv.string,
})


def get_scanner(_hass, config):
    """Validate the configuration and return a Nmap scanner."""
    scanner = KeeneticNDMS2DeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


class KeeneticNDMS2DeviceScanner(DeviceScanner):
Exemplo n.º 21
0
CONF_MQTT_TOPIC = 'mqtt_topic'
CONF_REGION_MAPPING = 'region_mapping'
CONF_EVENTS_ONLY = 'events_only'

DEPENDENCIES = ['mqtt']

DEFAULT_OWNTRACKS_TOPIC = 'owntracks/#'
REGION_MAPPING = {}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_MAX_GPS_ACCURACY): vol.Coerce(float),
    vol.Optional(CONF_WAYPOINT_IMPORT, default=True): cv.boolean,
    vol.Optional(CONF_EVENTS_ONLY, default=False): cv.boolean,
    vol.Optional(CONF_MQTT_TOPIC, default=DEFAULT_OWNTRACKS_TOPIC):
        mqtt.valid_subscribe_topic,
    vol.Optional(CONF_WAYPOINT_WHITELIST): vol.All(
        cv.ensure_list, [cv.string]),
    vol.Optional(CONF_SECRET): vol.Any(
        vol.Schema({vol.Optional(cv.string): cv.string}),
        cv.string),
    vol.Optional(CONF_REGION_MAPPING, default=REGION_MAPPING): dict
})


def get_cipher():
    """Return decryption function and length of key.

    Async friendly.
    """
    from libnacl import crypto_secretbox_KEYBYTES as KEYLEN
    from libnacl.secret import SecretBox
Exemplo n.º 22
0
import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME

REQUIREMENTS = ['fritzconnection==0.6.5']

_LOGGER = logging.getLogger(__name__)

CONF_DEFAULT_IP = '169.254.1.1'  # This IP is valid for all FRITZ!Box routers.

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_HOST, default=CONF_DEFAULT_IP): cv.string,
    vol.Optional(CONF_PASSWORD, default='admin'): cv.string,
    vol.Optional(CONF_USERNAME, default=''): cv.string
})


def get_scanner(hass, config):
    """Validate the configuration and return FritzBoxScanner."""
    scanner = FritzBoxScanner(config[DOMAIN])
    return scanner if scanner.success_init else None


class FritzBoxScanner(DeviceScanner):
    """This class queries a FRITZ!Box router."""

    def __init__(self, config):
        """Initialize the scanner."""
Exemplo n.º 23
0
import homeassistant.helpers.config_validation as cv
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
from homeassistant.util import Throttle
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.helpers.aiohttp_client import async_create_clientsession

_LOGGER = logging.getLogger(__name__)

CONF_HOME_ID = 'home_id'

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=30)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Optional(CONF_HOME_ID): cv.string,
})


def get_scanner(hass, config):
    """Return a Tado scanner."""
    scanner = TadoDeviceScanner(hass, config[DOMAIN])
    return scanner if scanner.success_init else None


Device = namedtuple("Device", ["mac", "name"])


class TadoDeviceScanner(DeviceScanner):
    """This class gets geofenced devices from Tado."""
Exemplo n.º 24
0
                                                     DEFAULT_SCAN_INTERVAL)
from homeassistant.helpers.event import track_point_in_utc_time
from homeassistant import util
from homeassistant import const
import homeassistant.helpers.config_validation as cv

DEPENDENCIES = []

_LOGGER = logging.getLogger(__name__)

CONF_PING_COUNT = 'count'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(const.CONF_HOSTS): {
        cv.string: cv.string
    },
    vol.Optional(CONF_PING_COUNT, default=1):
    cv.positive_int,
})


class Host:
    """Host object with ping detection."""
    def __init__(self, ip_address, dev_id, hass, config):
        """Initialize the Host pinger."""
        self.hass = hass
        self.ip_address = ip_address
        self.dev_id = dev_id
        self._count = config[CONF_PING_COUNT]
        if sys.platform == "win32":
            self._ping_cmd = ['ping', '-n 1', '-w 1000', self.ip_address]
Exemplo n.º 25
0
LOCATION_TOPIC = 'owntracks/+/+'

VALIDATE_LOCATION = 'location'
VALIDATE_TRANSITION = 'transition'
VALIDATE_WAYPOINTS = 'waypoints'

WAYPOINT_LAT_KEY = 'lat'
WAYPOINT_LON_KEY = 'lon'
WAYPOINT_TOPIC = 'owntracks/{}/{}/waypoint'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_MAX_GPS_ACCURACY): vol.Coerce(float),
    vol.Optional(CONF_WAYPOINT_IMPORT, default=True): cv.boolean,
    vol.Optional(CONF_WAYPOINT_WHITELIST): vol.All(
        cv.ensure_list, [cv.string]),
    vol.Optional(CONF_SECRET): vol.Any(
        vol.Schema({vol.Optional(cv.string): cv.string}),
        cv.string)
})


def get_cipher():
    """Return decryption function and length of key.

    Async friendly.
    """
    from libnacl import crypto_secretbox_KEYBYTES as KEYLEN
    from libnacl.secret import SecretBox

    def decrypt(ciphertext, key):
Exemplo n.º 26
0
HANDLERS = decorator.Registry()

BEACON_DEV_ID = 'beacon'

CONF_MAX_GPS_ACCURACY = 'max_gps_accuracy'
CONF_SECRET = 'secret'
CONF_WAYPOINT_IMPORT = 'waypoints'
CONF_WAYPOINT_WHITELIST = 'waypoint_whitelist'

OWNTRACKS_TOPIC = 'owntracks/#'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_MAX_GPS_ACCURACY):
    vol.Coerce(float),
    vol.Optional(CONF_WAYPOINT_IMPORT, default=True):
    cv.boolean,
    vol.Optional(CONF_WAYPOINT_WHITELIST):
    vol.All(cv.ensure_list, [cv.string]),
    vol.Optional(CONF_SECRET):
    vol.Any(vol.Schema({vol.Optional(cv.string): cv.string}), cv.string)
})


def get_cipher():
    """Return decryption function and length of key.

    Async friendly.
    """
    from libnacl import crypto_secretbox_KEYBYTES as KEYLEN
    from libnacl.secret import SecretBox

    def decrypt(ciphertext, key):
Exemplo n.º 27
0
import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import (
    CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_VERIFY_SSL)

INTERFACES = 2
DEFAULT_TIMEOUT = 10

REQUIREMENTS = ['beautifulsoup4==4.6.0']

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean,
})


def get_scanner(hass, config):
    """Validate the configuration and return a Linksys AP scanner."""
    try:
        return LinksysAPDeviceScanner(config[DOMAIN])
    except ConnectionError:
        return None


class LinksysAPDeviceScanner(DeviceScanner):
    """This class queries a Linksys Access Point."""
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

DEFAULT_USERNAME = "******"
DEFAULT_PORT = 8001
DEFAULT_SSL = True
DEFAULT_VERIFY_SSL = False

PLATFORM_SCHEMA = DEVICE_TRACKER_PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_USERNAME, default=DEFAULT_USERNAME):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Optional(CONF_PORT, default=DEFAULT_PORT):
    cv.port,
    vol.Optional(CONF_SSL, default=DEFAULT_SSL):
    cv.boolean,
    vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL):
    cv.boolean,
})

ATTRIBUTE_ALIAS = {
    "band": None,
    "connection": None,
    "current_rate": None,
    "dev_type": None,
    "hostname": None,
    "ip6_addr": None,
    "ip_addr": None,
Exemplo n.º 29
0
                                 CONF_USERNAME,
                                 CONF_PORT)
from homeassistant.util import Throttle

REQUIREMENTS = ['librouteros==1.0.2']

# Return cached results if last scan was less then this time ago.
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)

MTK_DEFAULT_API_PORT = '8728'

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Optional(CONF_PORT, default=MTK_DEFAULT_API_PORT): cv.port
})


def get_scanner(hass, config):
    """Validate the configuration and return MTikScanner."""
    scanner = MikrotikScanner(config[DOMAIN])
    return scanner if scanner.success_init else None


class MikrotikScanner(DeviceScanner):
    """This class queries a Mikrotik router."""

    def __init__(self, config):
        """Initialize the scanner."""
Exemplo n.º 30
0
CONF_DEVICES = 'devices'
CONF_SECRET = 'secret'

DATA_CONFIGURING = 'automatic_configurator_clients'
DATA_REFRESH_TOKEN = 'refresh_token'
DEFAULT_SCOPE = ['location', 'trip', 'vehicle:events', 'vehicle:profile']
DEFAULT_TIMEOUT = 5
DEPENDENCIES = ['http']

EVENT_AUTOMATIC_UPDATE = 'automatic_update'

FULL_SCOPE = DEFAULT_SCOPE + ['current_location']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_CLIENT_ID): cv.string,
    vol.Required(CONF_SECRET): cv.string,
    vol.Optional(CONF_CURRENT_LOCATION, default=False): cv.boolean,
    vol.Optional(CONF_DEVICES): vol.All(cv.ensure_list, [cv.string]),
})


def _get_refresh_token_from_file(hass, filename):
    """Attempt to load session data from file."""
    path = hass.config.path(filename)

    if not os.path.isfile(path):
        return None

    try:
        with open(path) as data_file:
            data = json.load(data_file)
            if data is None:
Exemplo n.º 31
0
CLIENT_UUID_CONFIG_FILE = '.tile.conf'
DEFAULT_ICON = 'mdi:bluetooth'
DEVICE_TYPES = ['PHONE', 'TILE']

ATTR_ALTITUDE = 'altitude'
ATTR_CONNECTION_STATE = 'connection_state'
ATTR_IS_DEAD = 'is_dead'
ATTR_IS_LOST = 'is_lost'
ATTR_LAST_SEEN = 'last_seen'
ATTR_LAST_UPDATED = 'last_updated'
ATTR_RING_STATE = 'ring_state'
ATTR_VOIP_STATE = 'voip_state'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Optional(CONF_MONITORED_VARIABLES):
        vol.All(cv.ensure_list, [vol.In(DEVICE_TYPES)]),
})


def setup_scanner(hass, config: dict, see, discovery_info=None):
    """Validate the configuration and return a Tile scanner."""
    TileDeviceScanner(hass, config, see)
    return True


class TileDeviceScanner(DeviceScanner):
    """Define a device scanner for Tiles."""

    def __init__(self, hass, config, see):
        """Initialize."""
Exemplo n.º 32
0
                                                     DeviceScanner)
from homeassistant.const import CONF_HOSTS

_LOGGER = logging.getLogger(__name__)

CONF_EXCLUDE = 'exclude'
# Interval in minutes to exclude devices from a scan while they are home
CONF_HOME_INTERVAL = 'home_interval'
CONF_OPTIONS = 'scan_options'
DEFAULT_OPTIONS = '-F --host-timeout 5s'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOSTS):
    cv.ensure_list,
    vol.Required(CONF_HOME_INTERVAL, default=0):
    cv.positive_int,
    vol.Optional(CONF_EXCLUDE, default=[]):
    vol.All(cv.ensure_list, [cv.string]),
    vol.Optional(CONF_OPTIONS, default=DEFAULT_OPTIONS):
    cv.string
})


def get_scanner(hass, config):
    """Validate the configuration and return a Nmap scanner."""
    return NmapDeviceScanner(config[DOMAIN])


Device = namedtuple('Device', ['mac', 'name', 'ip', 'last_update'])


def _arp(ip_address):
Exemplo n.º 33
0
CONF_DEVICES = 'devices'
CONF_SECRET = 'secret'

DATA_CONFIGURING = 'automatic_configurator_clients'
DATA_REFRESH_TOKEN = 'refresh_token'
DEFAULT_SCOPE = ['location', 'trip', 'vehicle:events', 'vehicle:profile']
DEFAULT_TIMEOUT = 5
DEPENDENCIES = ['http']

EVENT_AUTOMATIC_UPDATE = 'automatic_update'

FULL_SCOPE = DEFAULT_SCOPE + ['current_location']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_CLIENT_ID): cv.string,
    vol.Required(CONF_SECRET): cv.string,
    vol.Optional(CONF_CURRENT_LOCATION, default=False): cv.boolean,
    vol.Optional(CONF_DEVICES): vol.All(cv.ensure_list, [cv.string]),
})


def _get_refresh_token_from_file(hass, filename):
    """Attempt to load session data from file."""
    path = hass.config.path(filename)

    if not os.path.isfile(path):
        return None

    try:
        with open(path) as data_file:
            data = json.load(data_file)
            if data is None:
Exemplo n.º 34
0
_DDWRT_DATA_REGEX = re.compile(r"\{(\w+)::([^\}]*)\}")
_MAC_REGEX = re.compile(r"(([0-9A-Fa-f]{1,2}\:){5}[0-9A-Fa-f]{1,2})")

DEFAULT_SSL = False
DEFAULT_VERIFY_SSL = True
CONF_WIRELESS_ONLY = "wireless_only"
DEFAULT_WIRELESS_ONLY = True

PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_SSL, default=DEFAULT_SSL):
    cv.boolean,
    vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL):
    cv.boolean,
    vol.Optional(CONF_WIRELESS_ONLY, default=DEFAULT_WIRELESS_ONLY):
    cv.boolean,
})


def get_scanner(hass, config):
    """Validate the configuration and return a DD-WRT scanner."""
    try:
        return DdWrtDeviceScanner(config[DOMAIN])
    except ConnectionError:
        return None
Exemplo n.º 35
0
"""Support for Xiaomi Mi WiFi Repeater 2."""
import logging

import voluptuous as vol

from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST, CONF_TOKEN
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['python-miio==0.4.5', 'construct==2.9.45']

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_TOKEN): vol.All(cv.string, vol.Length(min=32, max=32)),
})


def get_scanner(hass, config):
    """Return a Xiaomi MiIO device scanner."""
    from miio import WifiRepeater, DeviceException

    scanner = None
    host = config[DOMAIN].get(CONF_HOST)
    token = config[DOMAIN].get(CONF_TOKEN)

    _LOGGER.info(
        "Initializing with host %s (token %s...)", host, token[:5])

    try:
from homeassistant.const import ATTR_ID
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType


_LOGGER = logging.getLogger(__name__)
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=15)

CONF_NAME = 'name'
CONF_KEY = 'key'
CONF_SEC = 'sec'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_NAME): cv.string,
    vol.Required(CONF_KEY): cv.string,
    vol.Required(CONF_SEC): cv.string
})

ATTR_LAST_SEEN = 'last_seen'
ATTR_INTERVAL = 'interval'

def setup_scanner(hass, config: ConfigType, see, discovery_info=None):
    scanner = PetpointerScanner(hass, config, see)
    return scanner.success_init

class PetpointerScanner(object):
    
    def __init__(self, hass, config: ConfigType, see):
        self.name = config[CONF_NAME]
        self.key = config[CONF_KEY]
Exemplo n.º 37
0
_LOGGER = logging.getLogger(__name__)

# Interface name to track devices for. Most likely one will not need to
# change it from default 'Home'. This is needed not to track Guest WI-FI-
# clients and router itself
CONF_INTERFACE = 'interface'

DEFAULT_INTERFACE = 'Home'
DEFAULT_PORT = 23


PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PORT, default=DEFAULT_PORT): cv.port,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Required(CONF_INTERFACE, default=DEFAULT_INTERFACE): cv.string,
})


def get_scanner(_hass, config):
    """Validate the configuration and return a Nmap scanner."""
    scanner = KeeneticNDMS2DeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


class KeeneticNDMS2DeviceScanner(DeviceScanner):
    """This class scans for devices using keenetic NDMS2 web interface."""
Exemplo n.º 38
0
    PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
    DeviceScanner,
)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType

_LOGGER = logging.getLogger(__name__)

DEFAULT_IP = "192.168.0.1"

PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_PASSWORD): cv.string,
        vol.Optional(CONF_HOST, default=DEFAULT_IP): cv.string,
    }
)


async def async_get_scanner(
    hass: HomeAssistant, config: ConfigType
) -> DeviceScanner | None:
    """Return the UPC device scanner."""
    conf = config[DOMAIN]
    session = async_get_clientsession(hass)
    connect_box = ConnectBox(session, conf[CONF_PASSWORD], host=conf[CONF_HOST])

    # Check login data
    try:
        await connect_box.async_initialize_token()
Exemplo n.º 39
0
REQUIREMENTS = ['aioautomatic==0.2.1']

_LOGGER = logging.getLogger(__name__)

CONF_CLIENT_ID = 'client_id'
CONF_SECRET = 'secret'
CONF_DEVICES = 'devices'

DEFAULT_TIMEOUT = 5

SCOPE = ['location', 'vehicle:profile', 'trip']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_CLIENT_ID): cv.string,
    vol.Required(CONF_SECRET): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Optional(CONF_DEVICES, default=None): vol.All(
        cv.ensure_list, [cv.string])
})


@asyncio.coroutine
def async_setup_scanner(hass, config, async_see, discovery_info=None):
    """Validate the configuration and return an Automatic scanner."""
    import aioautomatic

    client = aioautomatic.Client(
        client_id=config[CONF_CLIENT_ID],
        client_secret=config[CONF_SECRET],
        client_session=async_get_clientsession(hass),
        request_kwargs={'timeout': DEFAULT_TIMEOUT})
Exemplo n.º 40
0
    PLATFORM_SCHEMA,
    DeviceScanner,
)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

CONF_MODEL = "model"
DEFAULT_MODEL = "detect"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_MODEL, default=DEFAULT_MODEL):
    vol.Any("EVW32C-0N", "EVW320B", "EVW321B", "EVW3200-Wifi", "EVW3226@UPC"),
})


def get_scanner(hass, config):
    """Validate the configuration and return a Ubee scanner."""
    info = config[DOMAIN]
    host = info[CONF_HOST]
    username = info[CONF_USERNAME]
    password = info[CONF_PASSWORD]
    model = info[CONF_MODEL]

    ubee = Ubee(host, username, password, model)
Exemplo n.º 41
0
from homeassistant.core import callback
from homeassistant.components.http import HomeAssistantView
from homeassistant.components.device_tracker import (
    PLATFORM_SCHEMA, SOURCE_TYPE_ROUTER)

CONF_VALIDATOR = 'validator'
CONF_SECRET = 'secret'
URL = '/api/meraki'
VERSION = '2.0'


_LOGGER = logging.getLogger(__name__)


PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_VALIDATOR): cv.string,
    vol.Required(CONF_SECRET): cv.string
})


async def async_setup_scanner(hass, config, async_see, discovery_info=None):
    """Set up an endpoint for the Meraki tracker."""
    hass.http.register_view(
        MerakiView(config, async_see))

    return True


class MerakiView(HomeAssistantView):
    """View to handle Meraki requests."""

    url = URL
Exemplo n.º 42
0
    CONF_PASSWORD,
    CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import track_utc_time_change
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_CLIENT_ID):
    cv.string,
    vol.Required(CONF_CLIENT_SECRET):
    cv.string,
    vol.Optional(CONF_INCLUDE, default=[]):
    vol.All(cv.ensure_list, [cv.string]),
})


def setup_scanner(
    hass: HomeAssistant,
    config: ConfigType,
    see: SeeCallback,
    discovery_info: DiscoveryInfoType | None = None,
) -> bool:
    """Set up the DeviceScanner and check if login is valid."""
    scanner = FleetGoDeviceScanner(config, see)
Exemplo n.º 43
0
import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import DOMAIN, PLATFORM_SCHEMA
from homeassistant.const import CONF_HOST
from homeassistant.util import Throttle

# Return cached results if last scan was less then this time ago.
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)

_LOGGER = logging.getLogger(__name__)

_MAC_REGEX = re.compile(r'(([0-9A-Fa-f]{1,2}\:){5}[0-9A-Fa-f]{1,2})')

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string
})


# pylint: disable=unused-argument
def get_scanner(hass, config):
    """Return a BT Home Hub 5 scanner if successful."""
    scanner = BTHomeHub5DeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


class BTHomeHub5DeviceScanner(object):
    """This class queries a BT Home Hub 5."""

    def __init__(self, config):
Exemplo n.º 44
0
ATTR_WIFI_ON = 'wifi_on'

SERVICE_ZONES_FROM_PLACES = 'life360_zones_from_places'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Optional(CONF_FILENAME, default=DEFAULT_FILENAME): cv.string,
    vol.Optional(CONF_SHOW_AS_STATE, default=[]): vol.All(
        cv.ensure_list_csv, [vol.In(SHOW_AS_STATE_OPTS)]),
    vol.Optional(CONF_HOME_PLACE, default=DEFAULT_HOME_PLACE): cv.string,
    vol.Optional(CONF_MAX_GPS_ACCURACY): vol.Coerce(float),
    vol.Optional(CONF_MAX_UPDATE_WAIT): vol.All(
        cv.time_period, cv.positive_timedelta),
    vol.Optional(CONF_PREFIX): cv.string,
    vol.Optional(CONF_MEMBERS): vol.All(
        cv.ensure_list, [cv.string]),
    vol.Optional(CONF_DRIVING_SPEED): vol.Coerce(float),
    vol.Optional(CONF_ADD_ZONES):
        vol.Any(vol.In(AZ_OPTS), cv.boolean),
    vol.Optional(CONF_ZONE_INTERVAL):
        vol.All(cv.time_period, vol.Range(min=MIN_ZONE_INTERVAL)),
    vol.Optional(CONF_TIME_AS, default=TIME_AS_OPTS[0]):
        vol.In(TIME_AS_OPTS),
    vol.Optional(CONF_WARNING_THRESHOLD): cv.positive_int,
    vol.Optional(CONF_ERROR_THRESHOLD, default = 0): cv.positive_int,
})

_API_EXCS = (HTTPError, ConnectionError, Timeout, JSONDecodeError)

Exemplo n.º 45
0
from homeassistant.const import (
    CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT, CONF_SSL, CONF_METHOD)

_LOGGER = logging.getLogger(__name__)

MTK_DEFAULT_API_PORT = '8728'
MTK_DEFAULT_API_SSL_PORT = '8729'

CONF_ENCODING = 'encoding'
DEFAULT_ENCODING = 'utf-8'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Optional(CONF_METHOD): cv.string,
    vol.Optional(CONF_PORT): cv.port,
    vol.Optional(CONF_SSL, default=False): cv.boolean,
    vol.Optional(CONF_ENCODING, default=DEFAULT_ENCODING): cv.string,
})


def get_scanner(hass, config):
    """Validate the configuration and return MTikScanner."""
    scanner = MikrotikScanner(config[DOMAIN])
    return scanner if scanner.success_init else None


class MikrotikScanner(DeviceScanner):
    """This class queries a Mikrotik router."""
Exemplo n.º 46
0
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, \
    CONF_PORT
from homeassistant.util import Throttle

# Return cached results if last scan was less then this time ago.
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['pexpect==4.0.1']

PLATFORM_SCHEMA = vol.All(
    PLATFORM_SCHEMA.extend({
        vol.Required(CONF_HOST): cv.string,
        vol.Required(CONF_USERNAME): cv.string,
        vol.Optional(CONF_PASSWORD, default=''): cv.string,
        vol.Optional(CONF_PORT): cv.port,
    })
)


def get_scanner(hass, config):
    """Validate the configuration and return a Cisco scanner."""
    scanner = CiscoDeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


class CiscoDeviceScanner(DeviceScanner):
    """This class queries a wireless router running Cisco IOS firmware."""
Exemplo n.º 47
0
)
from homeassistant.components.http import (
    CONF_API_PASSWORD, HomeAssistantView
)
# pylint: disable=unused-import
from homeassistant.components.device_tracker import (  # NOQA
    DOMAIN, PLATFORM_SCHEMA
)
from homeassistant.helpers.typing import HomeAssistantType, ConfigType

_LOGGER = logging.getLogger(__name__)

DEPENDENCIES = ['http']

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_PASSWORD): cv.string,
})


async def async_setup_scanner(hass: HomeAssistantType, config: ConfigType,
                              async_see, discovery_info=None):
    """Set up an endpoint for the GPSLogger application."""
    hass.http.register_view(GPSLoggerView(async_see, config))

    return True


class GPSLoggerView(HomeAssistantView):
    """View to handle GPSLogger requests."""

    url = '/api/gpslogger'
Exemplo n.º 48
0
TODO
"""
import logging
import requests
import voluptuous as vol

from homeassistant.components.device_tracker import PLATFORM_SCHEMA
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import track_utc_time_change

_LOGGER = logging.getLogger(__name__)
DEFAULT_TIMEOUT = 10

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string
})


def setup_scanner(hass, config, see, discovery_info=None):
    """Validate the configuration and return a Life360 scanner."""
    Life360Scanner(hass, config, see)
    return True


class Life360Scanner(object):
    """A class representing a Life360 scanner."""

    def __init__(self, hass, config, see):
        """Initialize the Life360 scanner."""
        self.hass = hass
Exemplo n.º 49
0
import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST
from homeassistant.helpers.aiohttp_client import async_get_clientsession


REQUIREMENTS = ['defusedxml==0.5.0']

_LOGGER = logging.getLogger(__name__)

DEFAULT_IP = '192.168.0.1'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_HOST, default=DEFAULT_IP): cv.string,
})

CMD_DEVICES = 123


@asyncio.coroutine
def async_get_scanner(hass, config):
    """Return the UPC device scanner."""
    scanner = UPCDeviceScanner(hass, config[DOMAIN])
    success_init = yield from scanner.async_initialize_token()

    return scanner if success_init else None


class UPCDeviceScanner(DeviceScanner):
Exemplo n.º 50
0
    PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
    DeviceScanner,
)
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType

_LOGGER = logging.getLogger(__name__)

CONF_DEFAULT_IP = "192.168.1.254"
CONF_SMARTHUB_MODEL = "smarthub_model"

PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_HOST, default=CONF_DEFAULT_IP):
    cv.string,
    vol.Optional(CONF_SMARTHUB_MODEL):
    vol.In([1, 2]),
})


def get_scanner(hass: HomeAssistant,
                config: ConfigType) -> DeviceScanner | None:
    """Return a BT Smart Hub scanner if successful."""
    info = config[DOMAIN]
    smarthub_client = BTSmartHub(router_ip=info[CONF_HOST],
                                 smarthub_model=info.get(CONF_SMARTHUB_MODEL))
    scanner = BTSmartHubScanner(smarthub_client)
    return scanner if scanner.success_init else None


def _create_device(data):
    PLATFORM_SCHEMA, load_config
)
import homeassistant.util.dt as dt_util
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['gattlib==0.20150805']

BLE_PREFIX = 'BLE_'
MIN_SEEN_NEW = 5
CONF_SCAN_DURATION = "scan_duration"
CONF_BLUETOOTH_DEVICE = "device_id"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_SCAN_DURATION, default=10): cv.positive_int,
    vol.Optional(CONF_BLUETOOTH_DEVICE, default="hci0"): cv.string
})


def setup_scanner(hass, config, see, discovery_info=None):
    """Setup the Bluetooth LE Scanner."""
    # pylint: disable=import-error
    from gattlib import DiscoveryService

    new_devices = {}

    def see_device(address, name, new_device=False):
        """Mark a device as seen."""
        if new_device:
            if address in new_devices:
                _LOGGER.debug("Seen %s %s times", address,
Exemplo n.º 52
0
import requests
import voluptuous as vol

from homeassistant.components.device_tracker import (
    DOMAIN,
    PLATFORM_SCHEMA,
    DeviceScanner,
)
from homeassistant.const import CONF_HOST
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)
_MAC_REGEX = re.compile(r"(([0-9A-Fa-f]{1,2}\:){5}[0-9A-Fa-f]{1,2})")

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string})


def get_scanner(hass, config):
    """Return a Sky Hub scanner if successful."""
    scanner = SkyHubDeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


class SkyHubDeviceScanner(DeviceScanner):
    """This class queries a Sky Hub router."""

    def __init__(self, config):
        """Initialise the scanner."""
        _LOGGER.info("Initialising Sky Hub")
Exemplo n.º 53
0
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, \
    CONF_PORT
from homeassistant.util import Throttle

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['pexpect==4.0.1']

PLATFORM_SCHEMA = vol.All(
    PLATFORM_SCHEMA.extend({
        vol.Required(CONF_HOST): cv.string,
        vol.Required(CONF_USERNAME): cv.string,
        vol.Optional(CONF_PASSWORD, default=''): cv.string,
        vol.Optional(CONF_PORT): cv.port,
    })
)


def get_scanner(hass, config):
    """Validate the configuration and return a Cisco scanner."""
    scanner = CiscoDeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


class CiscoDeviceScanner(DeviceScanner):
    """This class queries a wireless router running Cisco IOS firmware."""
Exemplo n.º 54
0
    DOMAIN,
    PLATFORM_SCHEMA,
    DeviceScanner,
)
from homeassistant.const import CONF_HOST
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
import homeassistant.util.dt as dt_util

_LOGGER = logging.getLogger(__name__)

DEFAULT_HOST = "192.168.1.254"

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=60)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string})


def get_scanner(hass, config):
    """Validate the configuration and return a Bbox scanner."""
    scanner = BboxDeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


Device = namedtuple("Device", ["mac", "name", "ip", "last_update"])


class BboxDeviceScanner(DeviceScanner):
    """This class scans for devices connected to the bbox."""
    def __init__(self, config):
Exemplo n.º 55
0
import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import DOMAIN, PLATFORM_SCHEMA
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD

# Unifi package doesn't list urllib3 as a requirement
REQUIREMENTS = ["urllib3", "unifi==1.2.5"]

_LOGGER = logging.getLogger(__name__)
CONF_PORT = "port"
CONF_SITE_ID = "site_id"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Optional(CONF_HOST, default="localhost"): cv.string,
        vol.Optional(CONF_SITE_ID, default="default"): cv.string,
        vol.Required(CONF_PASSWORD): cv.string,
        vol.Required(CONF_USERNAME): cv.string,
        vol.Required(CONF_PORT, default=8443): cv.port,
    }
)


def get_scanner(hass, config):
    """Setup Unifi device_tracker."""
    from unifi.controller import Controller

    host = config[DOMAIN].get(CONF_HOST)
    username = config[DOMAIN].get(CONF_USERNAME)
    password = config[DOMAIN].get(CONF_PASSWORD)
    site_id = config[DOMAIN].get(CONF_SITE_ID)
    port = config[DOMAIN].get(CONF_PORT)
CONF_CALLSIGNS = "callsigns"

DEFAULT_HOST = "rotate.aprs2.net"
DEFAULT_PASSWORD = "******"
DEFAULT_TIMEOUT = 30.0

FILTER_PORT = 14580

MSG_FORMATS = ["compressed", "uncompressed", "mic-e"]

PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({
    vol.Required(CONF_CALLSIGNS):
    cv.ensure_list,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Optional(CONF_PASSWORD, default=DEFAULT_PASSWORD):
    cv.string,
    vol.Optional(CONF_HOST, default=DEFAULT_HOST):
    cv.string,
    vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT):
    vol.Coerce(float),
})


def make_filter(callsigns: list) -> str:
    """Make a server-side filter from a list of callsigns."""
    return " ".join(f"b/{sign.upper()}" for sign in callsigns)


def gps_accuracy(gps, posambiguity: int) -> int:
    """Calculate the GPS accuracy based on APRS posambiguity."""
Exemplo n.º 57
0
import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.util import Throttle

# Return cached results if last scan was less then this time ago.
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=5)

CONF_HTTP_ID = "http_id"

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_HTTP_ID): cv.string
})


def get_scanner(hass, config):
    """Validate the configuration and returns a Tomato scanner."""
    return TomatoDeviceScanner(config[DOMAIN])


class TomatoDeviceScanner(DeviceScanner):
    """This class queries a wireless router running Tomato firmware."""

    def __init__(self, config):
        """Initialize the scanner."""
        host, http_id = config[CONF_HOST], config[CONF_HTTP_ID]
Exemplo n.º 58
0
from homeassistant.components.device_tracker import (
    DOMAIN, PLATFORM_SCHEMA, DeviceScanner)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

CONF_VERSION = 'version'

CONF_DEFAULT_IP = '192.168.1.1'
CONF_DEFAULT_USERNAME = '******'
CONF_DEFAULT_VERSION = 2

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_VERSION, default=CONF_DEFAULT_VERSION): cv.positive_int,
    vol.Required(CONF_HOST, default=CONF_DEFAULT_IP): cv.string,
    vol.Required(CONF_USERNAME, default=CONF_DEFAULT_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
})


def get_scanner(hass, config):
    """Return a router scanner instance."""
    scanner = EEBrightBoxScanner(config[DOMAIN])

    return scanner if scanner.check_config() else None


class EEBrightBoxScanner(DeviceScanner):
    """Scan EE Brightbox router."""

    def __init__(self, config):
Exemplo n.º 59
0
REQUIREMENTS = ['pysnmp==4.4.2']

_LOGGER = logging.getLogger(__name__)

CONF_AUTHKEY = 'authkey'
CONF_BASEOID = 'baseoid'
CONF_COMMUNITY = 'community'
CONF_PRIVKEY = 'privkey'

DEFAULT_COMMUNITY = 'public'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_BASEOID): cv.string,
    vol.Required(CONF_HOST): cv.string,
    vol.Optional(CONF_COMMUNITY, default=DEFAULT_COMMUNITY): cv.string,
    vol.Inclusive(CONF_AUTHKEY, 'keys'): cv.string,
    vol.Inclusive(CONF_PRIVKEY, 'keys'): cv.string,
})


# pylint: disable=unused-argument
def get_scanner(hass, config):
    """Validate the configuration and return an SNMP scanner."""
    scanner = SnmpScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


class SnmpScanner(DeviceScanner):
    """Queries any SNMP capable Access Point for connected devices."""
Exemplo n.º 60
0
    CONF_PASSWORD,
    CONF_TYPE,
    CONF_USERNAME,
    HTTP_OK,
)
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

DEFAULT_TYPE = "rogers"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_HOST):
    cv.string,
    vol.Required(CONF_USERNAME):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Optional(CONF_TYPE, default=DEFAULT_TYPE):
    cv.string,
})


def get_scanner(_hass, config):
    """Validate the configuration and return a Hitron CODA-4582U scanner."""
    scanner = HitronCODADeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


Device = namedtuple("Device", ["mac", "name"])