Ejemplo n.º 1
0
    def test_successful_authentication(self):
        response_data = load_fixture("auth_success.json")
        responses.add(responses.POST,
                      config.AUTH_URL,
                      status=200,
                      body=json.dumps(response_data),
                      content_type="application/json")

        api = NuHeat("*****@*****.**", "secure-password")
        self.assertIsNone(api._session_id)
        api.authenticate()
        self.assertEqual(api._session_id, response_data.get("SessionId"))
Ejemplo n.º 2
0
    def test_authentication_error(self):
        response_data = load_fixture("auth_error.json")
        responses.add(responses.POST,
                      config.AUTH_URL,
                      status=200,
                      body=json.dumps(response_data),
                      content_type="application/json")

        api = NuHeat("*****@*****.**", "secure-password")
        with self.assertRaises(Exception) as _:
            api.authenticate()
            self.assertIsNone(api._session_id)
Ejemplo n.º 3
0
from nuheat import NuHeat

# Initalize an API session with your login credentials
api = NuHeat("https://www.mythermostat.info/api", "<email>", "<pwd>")
api.authenticate()

thermostat = api.get_thermostat("<serial>")

current = thermostat.celsius
target = thermostat.target_celsius

heating = thermostat.heating
online = thermostat.online
serial = thermostat.serial_number
Ejemplo n.º 4
0
 def test_init_with_session(self):
     existing_session_id = "passed-session"
     api = NuHeat("*****@*****.**", "secure-password",
                  existing_session_id)
     self.assertEqual(api._session_id, existing_session_id)
     api.authenticate()