Remove the googlehome integration (#26035)

This commit is contained in:
Joakim Sørensen 2019-08-20 19:54:54 +02:00 committed by Paulus Schoutsen
parent 7fd53ac912
commit d96edea6e2
7 changed files with 0 additions and 306 deletions

View File

@ -241,7 +241,6 @@ omit =
homeassistant/components/google_cloud/tts.py
homeassistant/components/google_maps/device_tracker.py
homeassistant/components/google_travel_time/sensor.py
homeassistant/components/googlehome/*
homeassistant/components/gpmdp/media_player.py
homeassistant/components/gpsd/sensor.py
homeassistant/components/greeneye_monitor/*

View File

@ -104,7 +104,6 @@ homeassistant/components/gntp/* @robbiet480
homeassistant/components/google_cloud/* @lufton
homeassistant/components/google_translate/* @awarecan
homeassistant/components/google_travel_time/* @robbiet480
homeassistant/components/googlehome/* @ludeeus
homeassistant/components/gpsd/* @fabaff
homeassistant/components/group/* @home-assistant/core
homeassistant/components/gtfs/* @robbiet480

View File

@ -1,118 +0,0 @@
"""Support Google Home units."""
import logging
import asyncio
import voluptuous as vol
from homeassistant.const import CONF_DEVICES, CONF_HOST
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
_LOGGER = logging.getLogger(__name__)
DOMAIN = "googlehome"
CLIENT = "googlehome_client"
NAME = "GoogleHome"
CONF_DEVICE_TYPES = "device_types"
CONF_RSSI_THRESHOLD = "rssi_threshold"
CONF_TRACK_ALARMS = "track_alarms"
CONF_TRACK_DEVICES = "track_devices"
DEVICE_TYPES = [1, 2, 3]
DEFAULT_RSSI_THRESHOLD = -70
DEVICE_CONFIG = vol.Schema(
{
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_DEVICE_TYPES, default=DEVICE_TYPES): vol.All(
cv.ensure_list, [vol.In(DEVICE_TYPES)]
),
vol.Optional(CONF_RSSI_THRESHOLD, default=DEFAULT_RSSI_THRESHOLD): vol.Coerce(
int
),
vol.Optional(CONF_TRACK_ALARMS, default=False): cv.boolean,
vol.Optional(CONF_TRACK_DEVICES, default=True): cv.boolean,
}
)
CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
{vol.Required(CONF_DEVICES): vol.All(cv.ensure_list, [DEVICE_CONFIG])}
)
},
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass, config):
"""Set up the Google Home component."""
hass.data[DOMAIN] = {}
hass.data[CLIENT] = GoogleHomeClient(hass)
for device in config[DOMAIN][CONF_DEVICES]:
hass.data[DOMAIN][device["host"]] = {}
if device[CONF_TRACK_DEVICES]:
hass.async_create_task(
discovery.async_load_platform(
hass, "device_tracker", DOMAIN, device, config
)
)
if device[CONF_TRACK_ALARMS]:
hass.async_create_task(
discovery.async_load_platform(hass, "sensor", DOMAIN, device, config)
)
return True
class GoogleHomeClient:
"""Handle all communication with the Google Home unit."""
def __init__(self, hass):
"""Initialize the Google Home Client."""
self.hass = hass
self._connected = None
async def update_info(self, host):
"""Update data from Google Home."""
from googledevices.api.connect import Cast
_LOGGER.debug("Updating Google Home info for %s", host)
session = async_get_clientsession(self.hass)
device_info = await Cast(host, self.hass.loop, session).info()
device_info_data = await device_info.get_device_info()
self._connected = bool(device_info_data)
self.hass.data[DOMAIN][host]["info"] = device_info_data
async def update_bluetooth(self, host):
"""Update bluetooth from Google Home."""
from googledevices.api.connect import Cast
_LOGGER.debug("Updating Google Home bluetooth for %s", host)
session = async_get_clientsession(self.hass)
bluetooth = await Cast(host, self.hass.loop, session).bluetooth()
await bluetooth.scan_for_devices()
await asyncio.sleep(5)
bluetooth_data = await bluetooth.get_scan_result()
self.hass.data[DOMAIN][host]["bluetooth"] = bluetooth_data
async def update_alarms(self, host):
"""Update alarms from Google Home."""
from googledevices.api.connect import Cast
_LOGGER.debug("Updating Google Home bluetooth for %s", host)
session = async_get_clientsession(self.hass)
assistant = await Cast(host, self.hass.loop, session).assistant()
alarms_data = await assistant.get_alarms()
self.hass.data[DOMAIN][host]["alarms"] = alarms_data

View File

@ -1,80 +0,0 @@
"""Support for Google Home Bluetooth tacker."""
from datetime import timedelta
import logging
from homeassistant.components.device_tracker import DeviceScanner
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.util import slugify
from . import CLIENT, DOMAIN as GOOGLEHOME_DOMAIN, NAME
_LOGGER = logging.getLogger(__name__)
DEFAULT_SCAN_INTERVAL = timedelta(seconds=10)
async def async_setup_scanner(hass, config, async_see, discovery_info=None):
"""Validate the configuration and return a Google Home scanner."""
if discovery_info is None:
_LOGGER.warning("To use this you need to configure the 'googlehome' component")
return False
scanner = GoogleHomeDeviceScanner(
hass, hass.data[CLIENT], discovery_info, async_see
)
return await scanner.async_init()
class GoogleHomeDeviceScanner(DeviceScanner):
"""This class queries a Google Home unit."""
def __init__(self, hass, client, config, async_see):
"""Initialize the scanner."""
self.async_see = async_see
self.hass = hass
self.rssi = config["rssi_threshold"]
self.device_types = config["device_types"]
self.host = config["host"]
self.client = client
async def async_init(self):
"""Further initialize connection to Google Home."""
await self.client.update_info(self.host)
data = self.hass.data[GOOGLEHOME_DOMAIN][self.host]
info = data.get("info", {})
connected = bool(info)
if connected:
await self.async_update()
async_track_time_interval(
self.hass, self.async_update, DEFAULT_SCAN_INTERVAL
)
return connected
async def async_update(self, now=None):
"""Ensure the information from Google Home is up to date."""
_LOGGER.debug("Checking Devices on %s", self.host)
await self.client.update_bluetooth(self.host)
data = self.hass.data[GOOGLEHOME_DOMAIN][self.host]
info = data.get("info")
bluetooth = data.get("bluetooth")
if info is None or bluetooth is None:
return
google_home_name = info.get("name", NAME)
for device in bluetooth:
if (
device["device_type"] not in self.device_types
or device["rssi"] < self.rssi
):
continue
name = "{} {}".format(self.host, device["mac_address"])
attributes = {}
attributes["btle_mac_address"] = device["mac_address"]
attributes["ghname"] = google_home_name
attributes["rssi"] = device["rssi"]
attributes["source_type"] = "bluetooth"
if device["name"]:
attributes["name"] = device["name"]
await self.async_see(dev_id=slugify(name), attributes=attributes)

View File

@ -1,12 +0,0 @@
{
"domain": "googlehome",
"name": "Googlehome",
"documentation": "https://www.home-assistant.io/components/googlehome",
"requirements": [
"googledevices==1.0.2"
],
"dependencies": [],
"codeowners": [
"@ludeeus"
]
}

View File

@ -1,91 +0,0 @@
"""Support for Google Home alarm sensor."""
from datetime import timedelta
import logging
from homeassistant.const import DEVICE_CLASS_TIMESTAMP
from homeassistant.helpers.entity import Entity
import homeassistant.util.dt as dt_util
from . import CLIENT, DOMAIN as GOOGLEHOME_DOMAIN, NAME
SCAN_INTERVAL = timedelta(seconds=10)
_LOGGER = logging.getLogger(__name__)
ICON = "mdi:alarm"
SENSOR_TYPES = {"timer": "Timer", "alarm": "Alarm"}
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the googlehome sensor platform."""
if discovery_info is None:
_LOGGER.warning("To use this you need to configure the 'googlehome' component")
return
await hass.data[CLIENT].update_info(discovery_info["host"])
data = hass.data[GOOGLEHOME_DOMAIN][discovery_info["host"]]
info = data.get("info", {})
devices = []
for condition in SENSOR_TYPES:
device = GoogleHomeAlarm(
hass.data[CLIENT], condition, discovery_info, info.get("name", NAME)
)
devices.append(device)
async_add_entities(devices, True)
class GoogleHomeAlarm(Entity):
"""Representation of a GoogleHomeAlarm."""
def __init__(self, client, condition, config, name):
"""Initialize the GoogleHomeAlarm sensor."""
self._host = config["host"]
self._client = client
self._condition = condition
self._name = None
self._state = None
self._available = True
self._name = "{} {}".format(name, SENSOR_TYPES[self._condition])
async def async_update(self):
"""Update the data."""
await self._client.update_alarms(self._host)
data = self.hass.data[GOOGLEHOME_DOMAIN][self._host]
alarms = data.get("alarms")[self._condition]
if not alarms:
self._available = False
return
self._available = True
time_date = dt_util.utc_from_timestamp(
min(element["fire_time"] for element in alarms) / 1000
)
self._state = time_date.isoformat()
@property
def state(self):
"""Return the state."""
return self._state
@property
def name(self):
"""Return the name."""
return self._name
@property
def device_class(self):
"""Return the device class."""
return DEVICE_CLASS_TIMESTAMP
@property
def available(self):
"""Return the availability state."""
return self._available
@property
def icon(self):
"""Return the icon."""
return ICON

View File

@ -560,9 +560,6 @@ google-cloud-pubsub==0.39.1
# homeassistant.components.google_cloud
google-cloud-texttospeech==0.4.0
# homeassistant.components.googlehome
googledevices==1.0.2
# homeassistant.components.google_travel_time
googlemaps==2.5.1