Exemplo n.º 1
0
def simul_update_relsen():
    rs = m.Relsen.query.filter_by (device_id='labs1', relsen_id='POWER1').first()
    if (not rs):
        return {'error' : 'invalid device_id or relsen_id'}
    jupdate = {
        'device_id':'labs1', 'relsen_id':'POWER2',
        'relsen_name':'Table fan', 'relsen_type': 'Fan',
        'room_name':'Grandpa\'s room', 'room_type': 'Dining room', 'group_name':'Basement',
        'schedule': [["10:00","11:30"],["17:20","18:45"]], 
        'repeat':False
    }
    r.update_relsen (jupdate)
    return {'result' : 'relsen {}/{} updated'.format(jupdate['device_id'], jupdate['relsen_id'])}    
Exemplo n.º 2
0
def simul_update_relsen():
    rs = m.Relsen.query.filter_by(device_id='labs1',
                                  relsen_id='POWER1').first()
    if (not rs):
        return {'error': 'invalid device_id or relsen_id'}
    jupdate = {
        'device_id': 'labs1',
        'relsen_id': 'POWER1',
        'relsen_name': 'Table fan',
        'relsen_type': 'Fan',
        'room_name': 'Grandpa\'s room',
        'room_type': 'Dining room',
        'group_name': 'Basement',
        'schedule': json.dumps({"schedule": [[10.0, 11.30]]}),
        'repeat': False
    }
    r.update_relsen(jupdate)
    return {'result': 'relsen labs1.POWER1 updated'}
Exemplo n.º 3
0
def clear_timers_route():
    if SIMULATION_MODE:
        return ({'error' : 'in simulation mode'})  
    devid = request.args.get('device_id')
    if (not devid):
        return ({'error' : 'device_id is required'})
    rsid = request.args.get('relsen_id')
    if (not rsid):
        return ({'error' : 'relsen_id is required'})        
    clear_timers (devid, rsid)  # clear from Tasmota
    jrelsen = {'device_id':devid, 'relsen_id':rsid, 'schedule':[], 'repeat':False}  # [["10:10","20:20"]]
    print (jrelsen)
    res = r.update_relsen (jrelsen)  # remove from database
    print (res)
    return ({'result' : 'timer schedules of device cleared'})