mirror of
https://github.com/USA-RedDragon/badnest.git
synced 2025-01-31 08:10:49 +00:00
Use the global set of credentials across thermostat and camera
This commit is contained in:
parent
c35f2633b9
commit
025e72ddeb
@ -16,3 +16,17 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
},
|
},
|
||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(hass, config):
|
||||||
|
"""Set up the badnest component."""
|
||||||
|
if config.get(DOMAIN) is not None:
|
||||||
|
email = config[DOMAIN].get(CONF_EMAIL)
|
||||||
|
password = config[DOMAIN].get(CONF_PASSWORD)
|
||||||
|
else:
|
||||||
|
email = None
|
||||||
|
password = None
|
||||||
|
|
||||||
|
hass.data[DOMAIN] = {CONF_EMAIL: email, CONF_PASSWORD: password}
|
||||||
|
|
||||||
|
return True
|
||||||
|
@ -6,6 +6,7 @@ from homeassistant.util.dt import utcnow
|
|||||||
from homeassistant.components.camera import Camera, SUPPORT_ON_OFF
|
from homeassistant.components.camera import Camera, SUPPORT_ON_OFF
|
||||||
|
|
||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||||
|
from .api import NestCameraAPI
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
@ -19,12 +20,13 @@ async def async_setup_platform(hass,
|
|||||||
config,
|
config,
|
||||||
async_add_entities,
|
async_add_entities,
|
||||||
discovery_info=None):
|
discovery_info=None):
|
||||||
"""Set up a Foscam IP Camera."""
|
"""Set up a Nest Camera."""
|
||||||
from .api import NestCameraAPI
|
|
||||||
|
|
||||||
hass.data[DATA_KEY] = dict()
|
hass.data[DATA_KEY] = dict()
|
||||||
|
|
||||||
api = NestCameraAPI(config.get(CONF_EMAIL), config.get(CONF_PASSWORD))
|
api = NestCameraAPI(
|
||||||
|
hass.data[DOMAIN][CONF_EMAIL],
|
||||||
|
hass.data[DOMAIN][CONF_PASSWORD]
|
||||||
|
)
|
||||||
|
|
||||||
# cameras = await hass.async_add_executor_job(nest.get_cameras())
|
# cameras = await hass.async_add_executor_job(nest.get_cameras())
|
||||||
cameras = []
|
cameras = []
|
||||||
|
@ -29,6 +29,7 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from .api import NestThermostatAPI
|
from .api import NestThermostatAPI
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
NEST_MODE_HEAT_COOL = "range"
|
NEST_MODE_HEAT_COOL = "range"
|
||||||
NEST_MODE_ECO = "eco"
|
NEST_MODE_ECO = "eco"
|
||||||
@ -60,14 +61,17 @@ async def async_setup_platform(hass,
|
|||||||
config,
|
config,
|
||||||
async_add_entities,
|
async_add_entities,
|
||||||
discovery_info=None):
|
discovery_info=None):
|
||||||
"""Set up a Foscam IP Camera."""
|
"""Set up the Nest climate device."""
|
||||||
nest = NestThermostatAPI(config.get(CONF_EMAIL), config.get(CONF_PASSWORD))
|
nest = NestThermostatAPI(
|
||||||
|
hass.data[DOMAIN][CONF_EMAIL],
|
||||||
|
hass.data[DOMAIN][CONF_PASSWORD]
|
||||||
|
)
|
||||||
|
|
||||||
async_add_entities([ShittyNestClimate(nest)])
|
async_add_entities([ShittyNestClimate(nest)])
|
||||||
|
|
||||||
|
|
||||||
class ShittyNestClimate(ClimateDevice):
|
class ShittyNestClimate(ClimateDevice):
|
||||||
"""Representation of a demo climate device."""
|
"""Representation of a Nest climate device."""
|
||||||
|
|
||||||
def __init__(self, api):
|
def __init__(self, api):
|
||||||
"""Initialize the thermostat."""
|
"""Initialize the thermostat."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user