mirror of
				https://github.com/USA-RedDragon/badnest.git
				synced 2025-10-31 04:33:19 +00:00 
			
		
		
		
	Use the global set of credentials across thermostat and camera
This commit is contained in:
		| @@ -16,3 +16,17 @@ CONFIG_SCHEMA = vol.Schema( | ||||
|     }, | ||||
|     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.const import CONF_EMAIL, CONF_PASSWORD | ||||
| from .api import NestCameraAPI | ||||
| from .const import DOMAIN | ||||
|  | ||||
|  | ||||
| @@ -19,12 +20,13 @@ async def async_setup_platform(hass, | ||||
|                                config, | ||||
|                                async_add_entities, | ||||
|                                discovery_info=None): | ||||
|     """Set up a Foscam IP Camera.""" | ||||
|     from .api import NestCameraAPI | ||||
|  | ||||
|     """Set up a Nest Camera.""" | ||||
|     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 = [] | ||||
|   | ||||
| @@ -29,6 +29,7 @@ from homeassistant.const import ( | ||||
| ) | ||||
|  | ||||
| from .api import NestThermostatAPI | ||||
| from .const import DOMAIN | ||||
|  | ||||
| NEST_MODE_HEAT_COOL = "range" | ||||
| NEST_MODE_ECO = "eco" | ||||
| @@ -60,14 +61,17 @@ async def async_setup_platform(hass, | ||||
|                                config, | ||||
|                                async_add_entities, | ||||
|                                discovery_info=None): | ||||
|     """Set up a Foscam IP Camera.""" | ||||
|     nest = NestThermostatAPI(config.get(CONF_EMAIL), config.get(CONF_PASSWORD)) | ||||
|     """Set up the Nest climate device.""" | ||||
|     nest = NestThermostatAPI( | ||||
|         hass.data[DOMAIN][CONF_EMAIL], | ||||
|         hass.data[DOMAIN][CONF_PASSWORD] | ||||
|     ) | ||||
|  | ||||
|     async_add_entities([ShittyNestClimate(nest)]) | ||||
|  | ||||
|  | ||||
| class ShittyNestClimate(ClimateDevice): | ||||
|     """Representation of a demo climate device.""" | ||||
|     """Representation of a Nest climate device.""" | ||||
|  | ||||
|     def __init__(self, api): | ||||
|         """Initialize the thermostat.""" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user