From 2d5a661140b60073b8d833ed78dc71287ad4edcc Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Mon, 3 Dec 2018 18:44:40 +0100 Subject: Binding.qml: hack to receive update event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit receive event to update UI, just done for fanspeed, should be done in this way, hvac send a command to hvac service and updates itself when receiving the event Change-Id: I9b787a601d695cce29ad8e8cc2faef8d28eda468 Signed-off-by: Clément Bénier --- app/api/Binding.qml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/api/Binding.qml b/app/api/Binding.qml index 2d88087..f483b94 100644 --- a/app/api/Binding.qml +++ b/app/api/Binding.qml @@ -28,12 +28,14 @@ WebSocket { property real leftTemperature: 21.0 property real rightTemperature: 21.0 property string language: "en_US" + property int nbFanSpeed : 0 property Connections c : Connections { target: root onFanSpeedChanged: { var json = [MessageId.call, '9999', 'hvac/set', {'FanSpeed': fanSpeed}] console.debug(JSON.stringify(json)) + nbFanSpeed++ sendTextMessage(JSON.stringify(json)) } onLeftTemperatureChanged: { @@ -76,10 +78,26 @@ WebSocket { root.statusString = "Bad return value, binding probably not installed" break case MessageId.event: - if (json[1] == "hvac/language") + if (json[1] == "hvac/language") { console.log("HVAC event received: ",json[2]) root.language = json[2].data root.statusString = "Language changed to "+language + } else if (json[1] == "hvac/update") { + console.log("HVAC event update received: ", json[2]) + console.log(json[2].data.LeftTemperature) + if(json[2].data.LeftTemperature) { + console.log("THATS COOL:::", json[2].data) + binding = leftTemperature = json[2].data.LeftTemperature + } else if (json[2].data.FanSpeed) { + console.log("FANSPEED :: ", json[2].data.FanSpeed) + if(nbFanSpeed > 0) + nbFanSpeed-- + if(nbFanSpeed == 0) + binding.fanSpeed = json[2].data.FanSpeed + } else { + console.log("THATS NOT COOL!!!!!!!!!!!!!!!!") + } + } break } } -- cgit 1.2.3-korg