def load_device_by(device_id: int) -> Device:
    sql = 'SELECT * FROM device WHERE device_id={}'.format(device_id)
    return load_one(sql, cast_device)
def load_device_with_status_by(device_id: int) -> [DeviceWithStatus]:
    sql = "SELECT device.*, ds.status FROM device JOIN device_status ds on device.device_id = ds.device_id WHERE ds.device_id={}".format(
        device_id)
    return load_one(sql, cast_device_with_status)
Beispiel #3
0
def load_current_sensor_data(sensor: Sensor = None) -> SensorData:
    sensor_filter = 'WHERE sensor_id={}'.format(sensor.id) if sensor else ''
    sql = 'SELECT * FROM sensor_data {} ORDER BY published_time DESC LIMIT 1'.format(
        sensor_filter)
    return load_one(sql, cast_sensor_data)
Beispiel #4
0
def load_sensor_by(sensor_id) -> Sensor:
    sql = 'SELECT * FROM sensor WHERE sensor_id={}'.format(sensor_id)
    return load_one(sql, cast_sensor)
def load_group_by(group_id: str) -> Group:
    sql = "SELECT * FROM device_group WHERE group_id='{}'".format(group_id)
    return load_one(sql, cast_group)
def load_device_status_by(device_id) -> DeviceStatus:
    sql = 'SELECT * FROM device_status WHERE device_id={}'.format(device_id)
    return load_one(sql, cast_device_status)