def start_zigbee(): spi = init() client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect(('52.25.165.62', 80)) print 'Connected to SmartThings endpoint' global zigbeeStatus while True: message = client_socket.recv(4096) data = json.loads(message) if zigbeeStatus == False: print 'Ignoring Zigbee message since zigbee_status is', zigbeeStatus continue led = data['display_name'] value = data['value'] print led, 'is', value if led == 'LED #1': if value == 'on': set_led_on(spi) setWinkLightbulbState(True) if value == 'off': set_led_off(spi) setWinkLightbulbState(False)
from engine import Game import writer from example_game import states, achievements if __name__ == '__main__': game = Game(states, achievements) writer.init(100) while not game.over: game.step() game.test_achievements() writer.print_game_over() input() game.save_and_quit()