summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-12-03 18:44:40 +0100
committerClément Bénier <clement.benier@iot.bzh>2018-12-03 18:44:40 +0100
commit2d5a661140b60073b8d833ed78dc71287ad4edcc (patch)
tree79bd06efc5755604a8210806adc77ecc8aac43dc
parentf4cb3ec807e23788299f9bf1d9c323ff5690aafd (diff)
Binding.qml: hack to receive update eventsandbox/benierc/eventupdate
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 <clement.benier@iot.bzh>
-rw-r--r--app/api/Binding.qml20
1 files changed, 19 insertions, 1 deletions
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
}
}