def get_device_feature(uuid, feature_id, logical=None): url = '/devices/' + uuid + '/features/' + str(feature_id) if isinstance(logical, int): req = ZermApi().get(endpoint=url, params={'logical': logical}) else: req = ZermApi().get(endpoint=url) data = req.json() return Response(status=data["status"], message=data["message"], url=data["uri"], data=data["results"])
def get_device_features(uuid, sensor=None): url = '/devices/' + uuid + '/features' if isinstance(sensor, bool): req = ZermApi().get(endpoint=url, params={'sensor': sensor}) else: req = ZermApi().get(endpoint=url) data = req.json() return Response(status=data["status"], message=data["message"], url=data["uri"], data=data["results"])
def find_by_id(id): req = ZermApi().get(endpoint='/rooms/' + str(id)) data = req.json() return Response(status=data["status"], message=data["message"], url=data["uri"], data=data["results"])
def find_by_uuid(uuid): req = ZermApi().get(endpoint='/devices/' + uuid) data = req.json() return Response(status=data["status"], message=data["message"], url=data["uri"], data=data["results"])
def set_device_feature_state(uuid, feature_id, value=0, logical=None): url = '/devices/' + uuid + '/features/' + str(feature_id) + '/states' if isinstance(logical, int): req = ZermApi().put(endpoint=url, params={ 'value': value, 'logical': logical }) else: req = ZermApi().put(endpoint=url, params={'value': value}) data = req.json() return Response(status=data["status"], message=data["message"], url=data["uri"], data=data["results"])
def get_device_feature_states(uuid, feature_id, limit=10): url = '/devices/' + uuid + '/features/' + str(feature_id) + '/states' req = ZermApi().get(endpoint=url, params={'limit': limit}) data = req.json() return Response(status=data["status"], message=data["message"], url=data["uri"], data=data["results"])
def reset_device_states(uuid): url = '/devices/' + uuid + '/states/reset' req = ZermApi().put(endpoint=url) data = req.json() return Response(status=data["status"], message=data["message"], url=data["uri"], data=data["results"])
def find_all(): req = ZermApi().get(endpoint='/units') data = req.json() return Response(status=data["status"], message=data["message"], url=data["uri"], data=data["results"])
# # ZermApi-python-client : A Python client library for ZermApi (https://api.zermthings.fr) # Copyright (c) 2018 SCION Gael (https://www.gael67350.eu) # # -*- coding: utf-8 -*- from zermapi.ZermApi import ZermApi UUID = "3e6f2591-dd00-4f35-92ca-ea2336811444" SECRET = "a336ff50f88c7df768ab4e05be0e3963" # Instantiation of the main class api = ZermApi(UUID, SECRET) # List all homes r = api.homes().find_all() print(r.data) # Get the room with id=1 r = api.rooms().find_by_id(1) print(r.data) # List all devices r = api.devices().find_all() print(r.data) # Get the device with uuid=bf26791d-ff9b-4755-935f-166fd82f33f0 r = api.devices().find_by_uuid("bf26791d-ff9b-4755-935f-166fd82f33f0") print(r.data) # Reset device state with uuid=bf26791d-ff9b-4755-935f-166fd82f33f0