app: use range [0..255] for slider, send temperatures updates 13/7613/3
authorStephane Desneux <stephane.desneux@iot.bzh>
Wed, 14 Dec 2016 18:55:59 +0000 (18:55 +0000)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Thu, 15 Dec 2016 02:52:46 +0000 (02:52 +0000)
Change-Id: I020b2a1c14d09be99e4ecfe645915a666b7759ea
Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
app/HVAC.qml
app/api/Binding.qml

index f5cd76b..41cf7fa 100644 (file)
@@ -46,6 +46,9 @@ ApplicationWindow {
                     anchors.left: parent.left
                     anchors.right: parent.right
                     anchors.verticalCenter: parent.verticalCenter
+                    from: 0.0
+                    to: 255.0
+                    stepSize: 1.0
                     onValueChanged: {
                         binding.fanSpeed = value
                     }
@@ -72,6 +75,10 @@ ApplicationWindow {
                 }
                 HeatDegree {
                     enabled: leftSeat.headLevel > 0
+                    onCurrentItemChanged: {
+                        console.log("Left Temp changed",degree)
+                        binding.leftTemperature = degree
+                    }
                 }
             }
             ColumnLayout {
@@ -121,6 +128,10 @@ ApplicationWindow {
                 }
                 HeatDegree {
                     enabled: rightSeat.headLevel > 0
+                    onCurrentItemChanged: {
+                        console.log("Right Temp changed",degree)
+                        binding.rightTemperature = degree
+                    }
                 }
             }
         }
index 834bdf8..93da6f4 100644 (file)
@@ -25,6 +25,8 @@ WebSocket {
     property string statusString: "waiting..."
 
     property real fanSpeed: 0.0
+    property real leftTemperature: 21.0
+    property real rightTemperature: 21.0
 
     property Connections c : Connections {
         target: root
@@ -33,17 +35,28 @@ WebSocket {
             console.debug(JSON.stringify(json))
             sendTextMessage(JSON.stringify(json))
         }
+        onLeftTemperatureChanged: {
+            var json = [MessageId.call, '9999', 'hvac/set', {'LeftTemperature': leftTemperature}]
+            console.debug(JSON.stringify(json))
+            sendTextMessage(JSON.stringify(json))
+        }
+        onRightTemperatureChanged: {
+            var json = [MessageId.call, '9999', 'hvac/set', {'RightTemperature': rightTemperature}]
+            console.debug(JSON.stringify(json))
+            sendTextMessage(JSON.stringify(json))
+        }
     }
 
     onTextMessageReceived: {
         var json = JSON.parse(message)
         var request = json[2].request
         var response = json[2].response
+        console.log("HVAC Binding Message: ",message)
         switch (json[0]) {
         case MessageId.call:
             break
         case MessageId.retok:
-            root.statusString = request.info
+            root.statusString = request.status
             break
         case MessageId.reterr:
             root.statusString = "Bad return value, binding probably not installed"