Example #1
0
def test_load_existing():
    test_cache_file = '.test'
    test_ip_address = 'test_address'
    test_user_name = 'test_user_name'
    api = HueApi()
    with pytest.raises(UninitializedException):
        api.load_existing(cache_file=test_cache_file)

    with open(test_cache_file, 'wb') as pickle_file:
        cache = {
            'bridge_ip_address': test_ip_address,
            'user_name': test_user_name,
        }
        pickle.dump(cache, pickle_file)
    api.load_existing(cache_file=test_cache_file)
    assert api.user_name == test_user_name
    assert api.bridge_ip_address == test_ip_address
    assert api.base_url == 'http://test_address/api/test_user_name'
    os.remove(test_cache_file)
Example #2
0
def test_defaults_dont_crash():
    api = HueApi()
    with pytest.raises(UninitializedException):
        api.load_existing()
Example #3
0
    })  #20 minutes * 60 sec/min * 10 100ms/s
    api.lights[3].set_state({
        'hue': bulb4,
        'sat': 255,
        'transitiontime': transitiontime
    })  #20 minutes * 60 sec/min * 10 100ms/s
    api.lights[4].set_state({
        'hue': bulb5,
        'sat': 255,
        'transitiontime': transitiontime
    })  #20 minutes * 60 sec/min * 10 100ms/s
    #transition time is number of seconds * 10, here it is 20 minutes


api = HueApi()
api.load_existing(cache_file='/home/pi/.apikey')
print("Key loaded")
sunAboutToSet = 0
sunAboutToRise = 0

#attempt immediate phasing for testing

sun = Sun(latitude, longitude)
denver = tz.gettz('America/Denver')
eveBool = 0
lateEveBool = 0
morningToAfternoonBool = 0
daytimeBool = 0

foundDefaultCount = 0
firstDefaultStateTime = 0
Example #4
0
    weather_key = r.json()["weather_key"]
    bridge_ip = r.json()["bridge_ip"]
    voice = r.json()["voice"]

_config()

#získání lokace pro počasí atd.
g = geocoder.ip("me")

#nastavení hue
api = HueApi()
try:
    api.create_new_user(bridge_ip)
    api.save_api_key(cache_file = "hue_token")
except:
    api.load_existing(cache_file = "hue_token")

api.fetch_lights()

#inicializace regnozicačních objektů
r = sr.Recognizer()
m = sr.Microphone()

#nastavení azure
speech_config = speechsdk.SpeechConfig(endpoint=azure_end, subscription=azure_key)
if(voice == "M"):
    speech_config.speech_synthesis_voice_name = "cs-CZ-AntoninNeural"
else:
    speech_config.speech_synthesis_voice_name = "cs-CZ-VlastaNeural"
speech_config.set_speech_synthesis_output_format(speechsdk.SpeechSynthesisOutputFormat(21))