mirror of
https://github.com/fmtr/haco.git
synced 2026-12-04 22:00:13 -05:00
Implement Response object
This commit is contained in:
parent
afa30b72b4
commit
08097f816c
5 changed files with 39 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ import typing
|
|||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
from haco import tools, constants
|
||||
from haco import tools, constants, callback
|
||||
|
||||
DEVICE = 'development-eth'
|
||||
CONTROL = 'DEVELOPMENT-DEHUMIDIFIER'
|
||||
|
|
@ -108,10 +108,15 @@ class Platform:
|
|||
payload_str = message.payload.decode('utf-8')
|
||||
payload = self.deserialize(payload_str)
|
||||
|
||||
output_raw = self.get_callback_output(payload)
|
||||
response = self.get_callback_output(payload)
|
||||
|
||||
output = self.serialize(self.convert_out(output_raw))
|
||||
if type(response) is not callback.Response:
|
||||
response = callback.Response(value=response)
|
||||
|
||||
if not response.send:
|
||||
return 'DO_NOT_SEND'
|
||||
|
||||
output = self.serialize(self.convert_out(response.value))
|
||||
return output
|
||||
|
||||
def get_callback_output(self, data):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue