示例#1
0
def login():

    global t

    try:
        t = Tado(username, password)

        if (lastMessage.find("Connection Error") != -1):
            printm(
                "Connection established, everything looks good now, continuing..\n"
            )

    except KeyboardInterrupt:
        printm("Interrupted by user.")
        sys.exit(0)

    except Exception as e:
        if (str(e).find("access_token") != -1):
            printm("Login error, check the username / password !")
            sys.exit(0)
        else:
            printm(
                str(e) + "\nConnection Error, retrying in " +
                str(errorRetringInterval) + " sec..")
            time.sleep(errorRetringInterval)
            login()
示例#2
0
def _mock_tado_climate_zone_from_fixture(filename):
    with patch("PyTado.interface.Tado._loginV2"), patch(
            "PyTado.interface.Tado.getMe"), patch(
                "PyTado.interface.Tado.getState",
                return_value=json.loads(load_fixture(filename)),
            ):
        tado = Tado("*****@*****.**", "mypassword")
        return tado.getZoneState(1)
示例#3
0
 def setup(self):
     """Connect to Tado and fetch the zones."""
     self.tado = Tado(self._username, self._password)
     self.tado.setDebugging(True)
     # Load zones and devices
     self.zones = self.tado.getZones()
     self.devices = self.tado.getMe()["homes"]
     self.device_id = self.devices[0]["id"]
示例#4
0
    def setup(self):
        """Connect to Tado and fetch the zones."""
        try:
            self.tado = Tado(self._username, self._password)
        except (RuntimeError, urllib.error.HTTPError) as exc:
            _LOGGER.error("Unable to connect: %s", exc)
            return False

        self.tado.setDebugging(True)

        # Load zones and devices
        self.zones = self.tado.getZones()
        self.devices = self.tado.getMe()["homes"]

        return True
示例#5
0
def setup(hass, config):
    """Set up of the Tado component."""
    username = config[DOMAIN][CONF_USERNAME]
    password = config[DOMAIN][CONF_PASSWORD]

    try:
        tado = Tado(username, password)
        tado.setDebugging(True)
    except (RuntimeError, urllib.error.HTTPError):
        _LOGGER.error("Unable to connect to mytado with username and password")
        return False

    hass.data[DATA_TADO] = TadoDataStore(tado)

    for component in TADO_COMPONENTS:
        load_platform(hass, component, DOMAIN, {}, config)

    return True
示例#6
0
def setup(hass, config):
    """Your controller/hub specific code."""
    username = config[DOMAIN][CONF_USERNAME]
    password = config[DOMAIN][CONF_PASSWORD]

    from PyTado.interface import Tado

    try:
        tado = Tado(username, password)
    except (RuntimeError, urllib.error.HTTPError):
        _LOGGER.error("Unable to connect to mytado with username and password")
        return False

    hass.data[DATA_TADO] = TadoDataStore(tado)

    for component in TADO_COMPONENTS:
        load_platform(hass, component, DOMAIN, {}, config)

    return True
示例#7
0
def getWeather():
    t = Tado(os.environ['TADO_EMAIL'], os.environ['TADO_PASS'])
    w = t.getWeather()
    return f"The temperature is {w['outsideTemperature']['celsius']}C and the sun is shining on Hillerød with {w['solarIntensity']['percentage']}% intensity"
示例#8
0
import warnings

bindir = os.path.dirname(os.path.realpath(__file__))
root = os.path.dirname(bindir)
libdir = os.path.join(root, 'lib')
sys.path.append(libdir)

from PyTado.interface import Tado
import private

mysql = pymysql.connect(host=os.getenv('MYSQL_HOST', private.mysql_host),
                        user=os.getenv('MYSQL_USER', private.mysql_user),
                        password=os.getenv('MYSQL_PASSWORD', private.mysql_password),
                        db=os.getenv('MYSQL_DATABASE', private.mysql_database))

api = Tado(private.username, private.password)

weather = api.getWeather()
outsideTemperature = weather["outsideTemperature"]["celsius"]

zones = {zone["name"]: zone["id"] for zone in api.getZones()}

for name in private.zones:
    zone = zones[name]
    state = api.getState(zone)

    # create new table
    with warnings.catch_warnings(), mysql.cursor() as cursor:
        # temperatures are < 100 with up to two digits past the comma --> DECIMAL(4,2)
        # percentages are <= 100 with only one digit past the comma --> DECIMAL(4,1)
        sql = """
 def __connect(self):
     username, password = c.get_credentials()
     self.__t = Tado(username, password)
示例#10
0
 def __init__(self, account, pwd):
     self.my_tado = Tado(account, pwd)