2021-01-22 23:25:20 +01:00
|
|
|
from cbpi.controller.basic_controller import BasicController
|
2021-01-24 22:14:57 +01:00
|
|
|
import logging
|
2019-01-01 15:35:35 +01:00
|
|
|
|
2021-01-22 23:25:20 +01:00
|
|
|
class SensorController(BasicController):
|
2018-11-01 21:25:42 +01:00
|
|
|
def __init__(self, cbpi):
|
2021-01-22 23:25:20 +01:00
|
|
|
super(SensorController, self).__init__(cbpi, "sensor.json")
|
2021-01-24 22:14:57 +01:00
|
|
|
self.update_key = "sensorupdate"
|
|
|
|
|
|
|
|
def create_dict(self, data):
|
|
|
|
try:
|
|
|
|
instance = data.get("instance")
|
|
|
|
state = state=instance.get_state()
|
|
|
|
except Exception as e:
|
2021-01-30 22:29:33 +01:00
|
|
|
logging.error("Faild to create sensor dict {} ".format(e))
|
2021-01-24 22:14:57 +01:00
|
|
|
state = dict()
|
|
|
|
|
|
|
|
return dict(name=data.get("name"), id=data.get("id"), type=data.get("type"), state=state,props=data.get("props", []))
|
|
|
|
|