Total Complexity | 5 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | |||
2 | import backend.fcmutils as utils |
||
3 | import backend.fcmservice |
||
4 | from backend.fcmcache import CacheKeys |
||
5 | from domain.sensors import Sensor, SensorValue |
||
6 | |||
7 | class SensorService(backend.fcmservice.BaseService): |
||
8 | def __init__(self, config, cache): |
||
9 | super().__init__(config, cache) |
||
10 | self.sensor = Sensor('controller', 'DHT22', 'controller') |
||
11 | |||
12 | def knownsensors(self): |
||
13 | dknownsensors = self.__cache.gethashset(CacheKeys.knownsensors) |
||
14 | if dknownsensors is not None and dknownsensors: |
||
15 | return utils.deserializelist_withschema(SensorValueSchema(), list(dknownsensors.values())) |
||
|
|||
16 | return None |
||
17 | |||
18 | def addknownsensor(self, sensorvalue): |
||
19 | val = utils.jsonserialize(SensorValueSchema(), sensorvalue) |
||
20 | self.__cache.putinhashset(CacheKeys.knownsensors, sensorvalue.sensorid, val) |
||
21 | |||
22 |