def dimmerState(path): if request.method == 'POST': data = request.form device = data['deviceId'] if (data['deviceType'] == 'dimmerLevel'): status = zp_st.getDeviceStatus('switch', device, 'state') if (status == 'on'): level = data['level'] zp_st.setDimmer(device, level) return Response(json.dumps({'error': 1})) if (data['deviceType'] == 'switch'): zp_st.toggleSwitch(device) status = zp_st.getDeviceStatus('switch', device, 'state') if (status == 'on'): status = 'off' else: status = 'on' return Response(json.dumps({'error': 1, 'switch': status})) else: device = unquote(path) state = zp_st.getDeviceStatus('dimmer', device, 'state') level = zp_st.getDeviceStatus('dimmer', device, 'level') results = {'state': state, 'level': level} return Response(json.dumps(results))
def powerState(path): if request.method == 'POST': return Response(json.dumps({'error': 0})) else: device = unquote(path) power = zp_st.getDeviceStatus('power', device, 'value') energy = zp_st.getDeviceStatus('power', device, 'energy') results = {'value': power, 'energy': energy} return Response(json.dumps(results))
def switchState(path): if request.method == 'POST': data = request.form device = data['deviceId'] zp_st.toggleSwitch(device) status = zp_st.getDeviceStatus('switch', device, 'state') if (status == 'on'): status = 'off' else: status = 'on' return Response(json.dumps({'error': 1, 'switch': status})) else: device = unquote(path) status = zp_st.getDeviceStatus('switch', device, 'state') results = {'switch': status} return Response(json.dumps(results))
def tempState(path): if request.method == 'POST': return Response(json.dumps({'error': 1})) else: device = unquote(path) temp = zp_st.getDeviceStatus('temperature', device, 'value') results = {'value': temp} return Response(json.dumps(results))
def motionState(path): if request.method == 'POST': return Response(json.dumps({'error': 0})) else: device = unquote(path) status = zp_st.getDeviceStatus('motion', device, 'state') results = {'state': status} return Response(json.dumps(results))
def humidityValue(path): if request.method == 'POST': return Response(json.dumps({'error': 0})) else: device = unquote(path) status = zp_st.getDeviceStatus('humidity', device, 'value') results = {'value': status} return Response(json.dumps(results))