mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-25 08:28:23 +01:00
http endpoint to retrieve sensor value added
This commit is contained in:
parent
7fc8bf84bc
commit
2d55410d4a
1 changed files with 23 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
from cbpi.api.dataclasses import Props, Sensor
|
||||
from aiohttp import web
|
||||
from cbpi.api import *
|
||||
import logging
|
||||
auth = False
|
||||
|
||||
class SensorHttpEndpoints():
|
||||
|
@ -207,3 +208,24 @@ class SensorHttpEndpoints():
|
|||
await self.controller.call_action(actor_id, data.get("name"), data.get("parameter"))
|
||||
|
||||
return web.Response(status=204)
|
||||
|
||||
@request_mapping(path="/{id}", method="GET", auth_required=False)
|
||||
async def get_value(self, request):
|
||||
"""
|
||||
|
||||
---
|
||||
description: Get Sensor Value
|
||||
tags:
|
||||
- Sensor
|
||||
parameters:
|
||||
- name: "id"
|
||||
in: "path"
|
||||
description: "Sensor ID"
|
||||
type: "string"
|
||||
required: true
|
||||
"""
|
||||
id = request.match_info['id']
|
||||
sensor_value = self.controller.get_sensor_value(id)
|
||||
logging.info(sensor_value)
|
||||
return web.json_response(data=sensor_value)
|
||||
|
||||
|
|
Loading…
Reference in a new issue