Ejemplo n.º 1
0
#!/usr/bin/python3.5
import time
import datetime
import api
import plot

print(datetime.datetime.now())

with open("../access_token", "r") as fd:
    access_token = fd.readline()

c = api.Connection(access_token)
v = c.vehicles[0]

for kk, vv in v.items():
    print("{}:----{}".format(kk, vv))

print('[WAKE_UP]')
v.wake_up()

print("[VEHICLE]")
veh = v.data_request('vehicle_state')
for kk, vv in veh.items():
    print("{}:----{}".format(kk, vv))

print("[CHARGE]")
cha = v.data_request('charge_state')
for kk, vv in cha.items():
    print("{}:----{}".format(kk, vv))

print("[CLIMATE]")
Ejemplo n.º 2
0
#!/usr/bin/env python

import api
import config

all_channels = {}

def after_connect(con, channels):
    for channel_info in channels:
        chan = con.join(channel_info["name"], lambda channel: channel.add_chat_listener(lambda message, nick=con.nick: on_chat(message, nick)), channel_info.get("key", ""))
        all_channels[con.host + "/" + chan.name] = chan
        all_channels[con.host + ":" + str(con.port) + "/" + chan.name] = chan

def on_chat(message, own_name):
    if not message.sender == own_name:
        print "Received " + str(message)
        for module in config.used_modules:
            module.on_chat(message)

for server in config.servers:
    connection = api.Connection(server["nick"], server["host"], server["port"])
    connection.connect(lambda con, channels = server["channels"]: after_connect(con, channels))

for module in config.used_modules:
    module.channels = all_channels
    module.init()