Esempio n. 1
0
def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the Volkswagen tracker."""
    if discovery_info is None:
        return

    vin, component, attr = discovery_info
    data = hass.data[DATA_KEY]
    instrument = data.instrument(vin, component, attr)
    vehicle = instrument.vehicle

    def see_vehicle(vehicle):
        """Handle the reporting of the vehicle position."""
        host_name = data.vehicle_name(vehicle)
        dev_id = '{}'.format(slugify(host_name))
        _LOGGER.debug('Updating location of %s' % host_name)
        if instrument.state:
            see(dev_id=dev_id,
                host_name=host_name,
                source_type=SOURCE_TYPE_GPS,
                gps=instrument.state,
                icon='mdi:car')

    dispatcher_connect(hass, SIGNAL_STATE_UPDATED, see_vehicle)
    #dispatcher_send(hass, SIGNAL_STATE_UPDATED)
    return True
Esempio n. 2
0
def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the Nissan Leaf tracker."""
    if discovery_info is None:
        return False

    def see_vehicle():
        """Handle the reporting of the vehicle position."""
        for vin, datastore in hass.data[DATA_LEAF].items():
            host_name = datastore.leaf.nickname
            dev_id = 'nissan_leaf_{}'.format(slugify(host_name))
            if not datastore.data[DATA_LOCATION]:
                _LOGGER.debug("No position found for vehicle %s", vin)
                return
            _LOGGER.debug("Updating device_tracker for %s with position %s",
                          datastore.leaf.nickname,
                          datastore.data[DATA_LOCATION].__dict__)
            attrs = {
                'updated_on': datastore.last_location_response,
            }
            see(dev_id=dev_id,
                host_name=host_name,
                gps=(datastore.data[DATA_LOCATION].latitude,
                     datastore.data[DATA_LOCATION].longitude),
                attributes=attrs,
                icon=ICON_CAR)

    dispatcher_connect(hass, SIGNAL_UPDATE_LEAF, see_vehicle)

    return True
Esempio n. 3
0
 def __init__(self, hass, controller):
     """Instantiate a new Rachio standby mode switch."""
     dispatcher_connect(
         hass, SIGNAL_RACHIO_CONTROLLER_UPDATE, self._handle_any_update
     )
     super().__init__(controller, poll=False)
     self._poll_update(controller.init_data)
def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the Nissan Leaf tracker."""
    if discovery_info is None:
        return False

    def see_vehicle():
        """Handle the reporting of the vehicle position."""
        for vin, datastore in hass.data[DATA_LEAF].items():
            host_name = datastore.leaf.nickname
            dev_id = 'nissan_leaf_{}'.format(slugify(host_name))
            if not datastore.data[DATA_LOCATION]:
                _LOGGER.debug("No position found for vehicle %s", vin)
                return
            _LOGGER.debug("Updating device_tracker for %s with position %s",
                          datastore.leaf.nickname,
                          datastore.data[DATA_LOCATION].__dict__)
            attrs = {
                'updated_on': datastore.last_location_response,
            }
            see(dev_id=dev_id,
                host_name=host_name,
                gps=(
                    datastore.data[DATA_LOCATION].latitude,
                    datastore.data[DATA_LOCATION].longitude
                ),
                attributes=attrs,
                icon=ICON_CAR)

    dispatcher_connect(hass, SIGNAL_UPDATE_LEAF, see_vehicle)

    return True
Esempio n. 5
0
 def __init__(self, hass, config, port):
     """Initialize Axis Communications camera component."""
     super().__init__(hass, config)
     self.port = port
     dispatcher_connect(hass,
                        DOMAIN + '_' + config[CONF_NAME] + '_new_ip',
                        self._new_ip)
def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the Volvo tracker."""
    if discovery_info is None:
        return

    vin, _ = discovery_info
    vw = hass.data[DATA_KEY]
    vehicle = vw.vehicles[vin]

    def see_vehicle(vehicle):
        """Handle the reporting of the vehicle position."""
        host_name = vw.vehicle_name(vehicle)
        dev_id = '{}'.format(slugify(host_name))
        attrs = {}
        if vehicle.model_image:
            attrs['entity_picture'] = vehicle.model_image
        _LOGGER.debug('Updating location of %s' % host_name)
        see(dev_id=dev_id,
            host_name=host_name,
            gps=(vehicle.position['lat'], vehicle.position['lng']),
            attributes=attrs,
            icon='mdi:car')

    dispatcher_connect(hass, SIGNAL_VEHICLE_SEEN, see_vehicle)
    dispatcher_send(hass, SIGNAL_VEHICLE_SEEN, vehicle)
    return True
Esempio n. 7
0
 def __init__(self, hass, name, addr, default_attr=None, default_unit=None):
     """Initialize the sensor."""
     self._name = name
     self._addr = addr
     self._default_attr = default_attr if default_attr != '' else None
     self._default_unit = default_unit if default_unit != '' else None
     self._attributes = {}
     dispatcher_connect(hass, ZGT_SIGNAL_UPDATE.format(self._addr), self.update_attributes)
Esempio n. 8
0
    def __init__(
        self,
        hass,
        cl,
        name,
        lights_ct,
        lights_rgb,
        lights_xy,
        lights_brightness,
        disable_brightness_adjust,
        min_brightness,
        max_brightness,
        sleep_entity,
        sleep_state,
        sleep_colortemp,
        sleep_brightness,
        disable_entity,
        disable_state,
        initial_transition,
    ):
        """Initialize the Circadian Lighting switch."""
        self.hass = hass
        self._cl = cl
        self._name = name
        self._entity_id = "switch." + slugify(f"circadian_lighting {name}")
        self._state = None
        self._icon = ICON
        self._hs_color = None
        self._lights_ct = lights_ct
        self._lights_rgb = lights_rgb
        self._lights_xy = lights_xy
        self._lights_brightness = lights_brightness
        self._disable_brightness_adjust = disable_brightness_adjust
        self._min_brightness = min_brightness
        self._max_brightness = max_brightness
        self._sleep_entity = sleep_entity
        self._sleep_state = sleep_state
        self._sleep_colortemp = sleep_colortemp
        self._sleep_brightness = sleep_brightness
        self._disable_entity = disable_entity
        self._disable_state = disable_state
        self._initial_transition = initial_transition
        self._attributes = {"hs_color": self._hs_color, "brightness": None}

        self._lights = lights_ct + lights_rgb + lights_xy + lights_brightness

        # Register callbacks
        dispatcher_connect(hass, CIRCADIAN_LIGHTING_UPDATE_TOPIC,
                           self.update_switch)
        track_state_change(hass, self._lights, self.light_state_changed)
        if self._sleep_entity is not None:
            track_state_change(hass, self._sleep_entity,
                               self.sleep_state_changed)
        if self._disable_entity is not None:
            track_state_change(hass, self._disable_entity,
                               self.disable_state_changed)
Esempio n. 9
0
    def __init__(self, hass, cl, name, lights_ct, lights_rgb, lights_xy,
                 lights_brightness, disable_brightness_adjust, min_brightness,
                 max_brightness, sleep_entity, sleep_state, sleep_colortemp,
                 sleep_brightness, disable_entity, disable_state,
                 initial_transition):
        """Initialize the Circadian Lighting switch."""
        self.hass = hass
        self._cl = cl
        self._name = name
        self._entity_id = "switch." + slugify("{} {}".format(
            'circadian_lighting', name))
        self._state = None
        self._icon = ICON
        self._hs_color = None
        self._lights_ct = lights_ct
        self._lights_rgb = lights_rgb
        self._lights_xy = lights_xy
        self._lights_brightness = lights_brightness
        self._disable_brightness_adjust = disable_brightness_adjust
        self._min_brightness = min_brightness
        self._max_brightness = max_brightness
        self._sleep_entity = sleep_entity
        self._sleep_state = sleep_state
        self._sleep_colortemp = sleep_colortemp
        self._sleep_brightness = sleep_brightness
        self._disable_entity = disable_entity
        self._disable_state = disable_state
        self._initial_transition = initial_transition
        self._attributes = {}
        self._attributes['hs_color'] = self._hs_color
        self._attributes['brightness'] = None
        self._attributes['kelvin'] = None
        self._attributes['hs_color'] = None
        self._attributes['xy_color'] = None
        self._attributes['color_temp'] = None
        self._attributes['rgb_color'] = None

        self._lights = []
        if lights_ct != None:
            self._lights += lights_ct
        if lights_rgb != None:
            self._lights += lights_rgb
        if lights_xy != None:
            self._lights += lights_xy
        if lights_brightness != None:
            self._lights += lights_brightness
        """Register callbacks."""
        dispatcher_connect(hass, CIRCADIAN_LIGHTING_UPDATE_TOPIC,
                           self.update_switch)
        track_state_change(hass, self._lights, self.light_state_changed)
        if self._sleep_entity is not None:
            track_state_change(hass, self._sleep_entity,
                               self.sleep_state_changed)
        if self._disable_entity is not None:
            track_state_change(hass, self._disable_entity,
                               self.disable_state_changed)
Esempio n. 10
0
    def __init__(self, hass, controller, poll=True):
        """Set up a new Rachio controller binary sensor."""
        self._controller = controller

        if poll:
            self._state = self._poll_update()
        else:
            self._state = None

        dispatcher_connect(hass, SIGNAL_RACHIO_CONTROLLER_UPDATE,
                           self._handle_any_update)
Esempio n. 11
0
 def __init__(self, hass, name, addrep, default_attr, switchtype, inverted):
     """Initialize the switch."""
     self._name = name
     self._addrep = addrep
     self._default_attr = default_attr
     self._switchtype = switchtype
     self._inverted = inverted
     self._attributes = {}
     self._state = False
     dispatcher_connect(hass, ZGT_SIGNAL_UPDATE.format(self._addrep),
                        self.update_attributes)
Esempio n. 12
0
    def __init__(self, hass, controller, poll=True):
        """Set up a new Rachio controller binary sensor."""
        self._controller = controller

        if poll:
            self._state = self._poll_update()
        else:
            self._state = None

        dispatcher_connect(hass, SIGNAL_RACHIO_CONTROLLER_UPDATE,
                           self._handle_any_update)
Esempio n. 13
0
    def __init__(self, hass, controller, data, manual_run_time):
        """Initialize a new Rachio Zone."""
        self._id = data[KEY_ID]
        self._zone_name = data[KEY_NAME]
        self._zone_number = data[KEY_ZONE_NUMBER]
        self._zone_enabled = data[KEY_ENABLED]
        self._manual_run_time = manual_run_time
        self._summary = str()
        super().__init__(controller)

        # Listen for all zone updates
        dispatcher_connect(hass, SIGNAL_RACHIO_ZONE_UPDATE, self._handle_update)
Esempio n. 14
0
    def __init__(self, hass, controller, data, manual_run_time):
        """Initialize a new Rachio Zone."""
        self._id = data[KEY_ID]
        self._zone_name = data[KEY_NAME]
        self._zone_number = data[KEY_ZONE_NUMBER]
        self._zone_enabled = data[KEY_ENABLED]
        self._manual_run_time = manual_run_time
        self._summary = str()
        super().__init__(controller)

        # Listen for all zone updates
        dispatcher_connect(hass, SIGNAL_RACHIO_ZONE_UPDATE,
                           self._handle_update)
Esempio n. 15
0
 def __init__(self, hass, name, addrep, default_attr, switchtype, inverted, autotoggle_delay):
     """Initialize the switch."""
     self._hass = hass
     self._name = name
     self._addrep = addrep
     self._default_attr = default_attr if default_attr != 'None' else None
     self._switchtype = switchtype
     self._inverted = inverted
     self._attributes = {}
     self._state = False
     self._autotoggle_delay = autotoggle_delay
     dispatcher_connect(hass, ZGT_SIGNAL_UPDATE.format(self._addrep),
                        self.update_attributes)
Esempio n. 16
0
    def __init__(self, hass, cl):
        """Initialize the Circadian Lighting sensor."""
        self._cl = cl
        self._name = 'Circadian Values'
        self._entity_id = 'sensor.circadian_values'
        self._state = self._cl.data['percent']
        self._unit_of_measurement = '%'
        self._icon = ICON
        self._hs_color = self._cl.data['hs_color']
        self._attributes = self._cl.data

        """Register callbacks."""
        dispatcher_connect(hass, CIRCADIAN_LIGHTING_UPDATE_TOPIC, self.update_sensor)
Esempio n. 17
0
    def test_simple_function_multiargs(self):
        """Test simple function (executor)."""
        calls = []

        def test_funct(data1, data2, data3):
            """Test function."""
            calls.append(data1)
            calls.append(data2)
            calls.append(data3)

        dispatcher_connect(self.hass, 'test', test_funct)
        dispatcher_send(self.hass, 'test', 3, 2, 'bla')
        self.hass.block_till_done()

        assert calls == [3, 2, 'bla']
Esempio n. 18
0
    def setup(self) -> None:
        """Run initial setup of the speaker."""
        self._entity_creation_dispatcher = dispatcher_connect(
            self.hass,
            f"{SONOS_ENTITY_CREATED}-{self.soco.uid}",
            self.async_handle_new_entity,
        )
        self._seen_dispatcher = dispatcher_connect(
            self.hass, f"{SONOS_SEEN}-{self.soco.uid}", self.async_seen)

        if battery_info := fetch_battery_info_or_none(self.soco):
            # Battery events can be infrequent, polling is still necessary
            self.battery_info = battery_info
            self._battery_poll_timer = self.hass.helpers.event.track_time_interval(
                self.async_poll_battery, BATTERY_SCAN_INTERVAL)
            dispatcher_send(self.hass, SONOS_CREATE_BATTERY, self)
Esempio n. 19
0
 def __init__(self, hass, cl):
     """Initialize the Circadian Lighting sensor."""
     self._cl = cl
     self._name = "Circadian Values"
     self._entity_id = "sensor.circadian_values"
     self._state = self._cl.data["percent"]
     self._unit_of_measurement = "%"
     self._icon = ICON
     self._hs_color = self._cl.data["hs_color"]
     self._attributes = {}
     self._attributes["colortemp"] = self._cl.data["colortemp"]
     self._attributes["rgb_color"] = self._cl.data["rgb_color"]
     self._attributes["xy_color"] = self._cl.data["xy_color"]
     """Register callbacks."""
     dispatcher_connect(hass, CIRCADIAN_LIGHTING_UPDATE_TOPIC,
                        self.update_sensor)
Esempio n. 20
0
def setup(hass, config):
    """Set up the Yeelight bulbs."""
    conf = config.get(DOMAIN, {})
    yeelight_data = hass.data[DATA_YEELIGHT] = {}

    def device_discovered(_, info):
        _LOGGER.debug("Adding autodetected %s", info['hostname'])

        device_type = info['device_type']

        name = "yeelight_%s_%s" % (device_type,
                                   info['properties']['mac'])
        ipaddr = info[CONF_HOST]
        device_config = DEVICE_SCHEMA({
            CONF_NAME: name,
            CONF_MODEL: device_type
        })

        _setup_device(hass, config, ipaddr, device_config)

    discovery.listen(hass, SERVICE_YEELIGHT, device_discovered)

    def update(_):
        for device in list(yeelight_data.values()):
            device.update()

    track_time_interval(
        hass, update, conf.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL)
    )

    def load_platforms(ipaddr):
        platform_config = hass.data[DATA_YEELIGHT][ipaddr].config.copy()
        platform_config[CONF_HOST] = ipaddr
        platform_config[CONF_CUSTOM_EFFECTS] = \
            config.get(DOMAIN, {}).get(CONF_CUSTOM_EFFECTS, {})
        load_platform(hass, LIGHT_DOMAIN, DOMAIN, platform_config, config)
        load_platform(hass, BINARY_SENSOR_DOMAIN, DOMAIN, platform_config,
                      config)

    dispatcher_connect(hass, DEVICE_INITIALIZED, load_platforms)

    if DOMAIN in config:
        for ipaddr, device_config in conf[CONF_DEVICES].items():
            _LOGGER.debug("Adding configured %s", device_config[CONF_NAME])
            _setup_device(hass, config, ipaddr, device_config)

    return True
Esempio n. 21
0
    def __init__(self, hass, name, ccb: ComfoConnectBridge) -> None:
        """Initialize the ComfoConnect fan."""

        self._ccb = ccb
        self._name = name

        # Ask the bridge to keep us updated
        self._ccb.comfoconnect.register_sensor(SENSOR_FAN_SPEED_MODE)

        def _handle_update(var):
            if var == SENSOR_FAN_SPEED_MODE:
                _LOGGER.debug("Dispatcher update for %s", var)
                self.schedule_update_ha_state()

        # Register for dispatcher updates
        dispatcher_connect(hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED,
                           _handle_update)
Esempio n. 22
0
def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the MySensors device scanner."""
    new_devices = mysensors.setup_mysensors_platform(
        hass, DOMAIN, discovery_info, MySensorsDeviceScanner,
        device_args=(see, ))
    if not new_devices:
        return False

    for device in new_devices:
        dev_id = (
            id(device.gateway), device.node_id, device.child_id,
            device.value_type)
        dispatcher_connect(
            hass, mysensors.SIGNAL_CALLBACK.format(*dev_id),
            device.update_callback)

    return True
Esempio n. 23
0
def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the MySensors device scanner."""
    new_devices = mysensors.setup_mysensors_platform(hass,
                                                     DOMAIN,
                                                     discovery_info,
                                                     MySensorsDeviceScanner,
                                                     device_args=(see, ))
    if not new_devices:
        return False

    for device in new_devices:
        dev_id = (id(device.gateway), device.node_id, device.child_id,
                  device.value_type)
        dispatcher_connect(hass, mysensors.SIGNAL_CALLBACK.format(*dev_id),
                           device.update_callback)

    return True
Esempio n. 24
0
    def test_simple_function(self):
        """Test simple function (executor)."""
        calls = []

        def test_funct(data):
            """Test function."""
            calls.append(data)

        dispatcher_connect(self.hass, 'test', test_funct)
        dispatcher_send(self.hass, 'test', 3)
        self.hass.block_till_done()

        assert calls == [3]

        dispatcher_send(self.hass, 'test', 'bla')
        self.hass.block_till_done()

        assert calls == [3, 'bla']
Esempio n. 25
0
    def __init__(self, hass, name, ccb: ComfoConnectBridge, sensor_type):
        """Initialize the ComfoConnect sensor."""
        self._ccb = ccb
        self._sensor_type = sensor_type
        self._sensor_id = SENSOR_TYPES[self._sensor_type][3]
        self._name = name

        # Register the requested sensor
        self._ccb.comfoconnect.register_sensor(self._sensor_id)

        def _handle_update(var):
            if var == self._sensor_id:
                _LOGGER.debug('Dispatcher update for %s.', var)
                self.schedule_update_ha_state()

        # Register for dispatcher updates
        dispatcher_connect(
            hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED, _handle_update)
    def __init__(self, hass, name, ccb: ComfoConnectBridge, sensor_type):
        """Initialize the ComfoConnect sensor."""
        self._ccb = ccb
        self._sensor_type = sensor_type
        self._sensor_id = SENSOR_TYPES[self._sensor_type][3]
        self._name = name

        # Register the requested sensor
        self._ccb.comfoconnect.register_sensor(self._sensor_id)

        def _handle_update(var):
            if var == self._sensor_id:
                _LOGGER.debug('Dispatcher update for %s.', var)
                self.schedule_update_ha_state()

        # Register for dispatcher updates
        dispatcher_connect(hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED,
                           _handle_update)
Esempio n. 27
0
    def __init__(self, hass, name, ccb: ComfoConnectBridge) -> None:
        """Initialize the ComfoConnect fan."""
        from pycomfoconnect import SENSOR_FAN_SPEED_MODE

        self._ccb = ccb
        self._name = name

        # Ask the bridge to keep us updated
        self._ccb.comfoconnect.register_sensor(SENSOR_FAN_SPEED_MODE)

        def _handle_update(var):
            if var == SENSOR_FAN_SPEED_MODE:
                _LOGGER.debug("Dispatcher update for %s", var)
                self.schedule_update_ha_state()

        # Register for dispatcher updates
        dispatcher_connect(
            hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED, _handle_update)
Esempio n. 28
0
    def test_simple_callback(self):
        """Test simple callback (async)."""
        calls = []

        @callback
        def test_funct(data):
            """Test function."""
            calls.append(data)

        dispatcher_connect(self.hass, 'test', test_funct)
        dispatcher_send(self.hass, 'test', 3)
        self.hass.block_till_done()

        assert calls == [3]

        dispatcher_send(self.hass, 'test', 'bla')
        self.hass.block_till_done()

        assert calls == [3, 'bla']
Esempio n. 29
0
    def test_simple_coro(self):
        """Test simple coro (async)."""
        calls = []

        @asyncio.coroutine
        def test_funct(data):
            """Test function."""
            calls.append(data)

        dispatcher_connect(self.hass, "test", test_funct)
        dispatcher_send(self.hass, "test", 3)
        self.hass.block_till_done()

        assert calls == [3]

        dispatcher_send(self.hass, "test", "bla")
        self.hass.block_till_done()

        assert calls == [3, "bla"]
Esempio n. 30
0
    def __init__(self, hass, name, addrep, light_type, manufacturer):
        """Initialize the switch."""
        self._hass = hass
        self._name = name
        self._addrep = addrep
        self._light_type = light_type
        self._attributes = {}
        self._command_address_part = "02" + addrep[:4] + "01" + addrep[4:]

        self._state = False
        self._brightness = None
        self._temperature = None
        self._available = True

        self._features = SUPPORTED_FEATURES
        if self._light_type == "dual-white":
            self._features |= SUPPORT_COLOR_TEMP

        dispatcher_connect(hass, ZGT_SIGNAL_UPDATE.format(self._addrep),
                           self.update_attributes)
Esempio n. 31
0
def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the Volvo tracker."""
    if discovery_info is None:
        return

    vin, _ = discovery_info
    vehicle = hass.data[DATA_KEY].vehicles[vin]

    def see_vehicle(vehicle):
        """Handle the reporting of the vehicle position."""
        host_name = vehicle.registration_number
        dev_id = 'volvo_{}'.format(slugify(host_name))
        see(dev_id=dev_id,
            host_name=host_name,
            gps=(vehicle.position['latitude'], vehicle.position['longitude']),
            icon='mdi:car')

    dispatcher_connect(hass, SIGNAL_VEHICLE_SEEN, see_vehicle)
    dispatcher_send(hass, SIGNAL_VEHICLE_SEEN, vehicle)

    return True
Esempio n. 32
0
    def test_simple_function_unsub(self):
        """Test simple function (executor) and unsub."""
        calls1 = []
        calls2 = []

        def test_funct1(data):
            """Test function."""
            calls1.append(data)

        def test_funct2(data):
            """Test function."""
            calls2.append(data)

        dispatcher_connect(self.hass, 'test1', test_funct1)
        unsub = dispatcher_connect(self.hass, 'test2', test_funct2)
        dispatcher_send(self.hass, 'test1', 3)
        dispatcher_send(self.hass, 'test2', 4)
        self.hass.block_till_done()

        assert calls1 == [3]
        assert calls2 == [4]

        unsub()

        dispatcher_send(self.hass, 'test1', 5)
        dispatcher_send(self.hass, 'test2', 6)
        self.hass.block_till_done()

        assert calls1 == [3, 5]
        assert calls2 == [4]

        # check don't kill the flow
        unsub()

        dispatcher_send(self.hass, 'test1', 7)
        dispatcher_send(self.hass, 'test2', 8)
        self.hass.block_till_done()

        assert calls1 == [3, 5, 7]
        assert calls2 == [4]
Esempio n. 33
0
def setup_scanner(hass, config, see, discovery_info=None):
    """Set up the Volvo tracker."""
    if discovery_info is None:
        return

    vin, _ = discovery_info
    vehicle = hass.data[DATA_KEY].vehicles[vin]

    def see_vehicle(vehicle):
        """Handle the reporting of the vehicle position."""
        host_name = vehicle.registration_number
        dev_id = 'volvo_{}'.format(slugify(host_name))
        see(dev_id=dev_id,
            host_name=host_name,
            gps=(vehicle.position['latitude'],
                 vehicle.position['longitude']),
            icon='mdi:car')

    dispatcher_connect(hass, SIGNAL_VEHICLE_SEEN, see_vehicle)
    dispatcher_send(hass, SIGNAL_VEHICLE_SEEN, vehicle)

    return True
Esempio n. 34
0
    def __init__(self, hass, host, port, password, config):
        """Init the Asterisk data object."""
        from asterisk_mbox import Client as asteriskClient
        self.hass = hass
        self.config = config
        self.messages = None
        self.cdr = None

        dispatcher_connect(self.hass, SIGNAL_MESSAGE_REQUEST,
                           self._request_messages)
        dispatcher_connect(self.hass, SIGNAL_CDR_REQUEST, self._request_cdr)
        dispatcher_connect(self.hass, SIGNAL_DISCOVER_PLATFORM,
                           self._discover_platform)
        # Only connect after signal connection to ensure we don't miss any
        self.client = asteriskClient(host, port, password, self.handle_data)
Esempio n. 35
0
    def __init__(self, hass, host, port, password, config):
        """Init the Asterisk data object."""
        from asterisk_mbox import Client as asteriskClient
        self.hass = hass
        self.config = config
        self.messages = None
        self.cdr = None

        dispatcher_connect(
            self.hass, SIGNAL_MESSAGE_REQUEST, self._request_messages)
        dispatcher_connect(
            self.hass, SIGNAL_CDR_REQUEST, self._request_cdr)
        dispatcher_connect(
            self.hass, SIGNAL_DISCOVER_PLATFORM, self._discover_platform)
        # Only connect after signal connection to ensure we don't miss any
        self.client = asteriskClient(host, port, password, self.handle_data)
Esempio n. 36
0
 def __init__(self, hass, config, port):
     """Initialize Axis Communications camera component."""
     super().__init__(config)
     self.port = port
     dispatcher_connect(
         hass, DOMAIN + '_' + config[CONF_NAME] + '_new_ip', self._new_ip)
Esempio n. 37
0
 def __init__(self, hass, controller):
     """Instantiate a new Rachio standby mode switch."""
     dispatcher_connect(hass, SIGNAL_RACHIO_CONTROLLER_UPDATE,
                        self._handle_any_update)
     super().__init__(controller, poll=False)
     self._poll_update(controller.init_data)