From 0b840e7f8ea434d9a1e68128bbb477f68a680c9c Mon Sep 17 00:00:00 2001 From: britea Date: Tue, 28 Apr 2020 10:48:07 +0200 Subject: [PATCH] fix thermostat --- .../src/components/dashboard/devices/Light.js | 39 +++++++++++-------- .../components/dashboard/devices/NewDevice.js | 36 +++++++---------- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/smart-hut/src/components/dashboard/devices/Light.js b/smart-hut/src/components/dashboard/devices/Light.js index 1415c5c..54af2e7 100644 --- a/smart-hut/src/components/dashboard/devices/Light.js +++ b/smart-hut/src/components/dashboard/devices/Light.js @@ -72,18 +72,20 @@ class Light extends Component { .saveDevice({ ...this.props.stateOrDevice, on }) .catch((err) => console.error("regular light update error", err)); } else { - this.props - .updateState( - { - id: this.props.stateOrDevice.id, - on: on, - sceneId: this.props.stateOrDevice.sceneId, - }, - this.props.stateOrDevice.kind - ) - .then((res) => { - console.log(res); - }); + if (this.props.device.kind === "regularLight") { + this.props + .updateState( + { + id: this.props.stateOrDevice.id, + on: on, + sceneId: this.props.stateOrDevice.sceneId, + }, + this.props.stateOrDevice.kind + ) + .then((res) => { + console.log(res); + }); + } } }; @@ -117,10 +119,15 @@ class Light extends Component { .saveDevice({ ...this.props.stateOrDevice, intensity }) .catch((err) => console.error("regular light update error", err)); } else { - this.props.updateState( - { id: this.props.stateOrDevice.id, intensity: intensity }, - this.props.stateOrDevice.kind - ); + console.log("CIAOOOOOOOOO", this.props.stateOrDevice); + this.props + .updateState( + { id: this.props.stateOrDevice.id, intensity: intensity }, + this.props.stateOrDevice.kind + ) + .then((res) => { + console.log(res, this.props.stateOrDevice.kind); + }); } }; diff --git a/smart-hut/src/components/dashboard/devices/NewDevice.js b/smart-hut/src/components/dashboard/devices/NewDevice.js index d150a50..7897c9e 100644 --- a/smart-hut/src/components/dashboard/devices/NewDevice.js +++ b/smart-hut/src/components/dashboard/devices/NewDevice.js @@ -106,7 +106,7 @@ class NewDevice extends Component { switch: "New switch", buttonDimmer: "New button dimmer", knobDimmer: "New knob dimmer", - securityCamera: "New security camera" + securityCamera: "New security camera", }; if (this.state.deviceName === "") { @@ -118,13 +118,13 @@ class NewDevice extends Component { switch (this.state.typeOfDevice) { //trying to make securityCamera work //case "securityCamera": - // data.path="/security_camera_videos/security_camera_1.mp4"; - // data.on=false; - //break; + // data.path="/security_camera_videos/security_camera_1.mp4"; + // data.on=false; + //break; //trying to make thermostat work case "thermostat": - data.targetTemperature=0; - data.measuredTemperuature=0; + data.targetTemperature = 0; + data.measuredTemperature = 0; break; case "dimmableLight": data.intensity = 0; @@ -157,16 +157,10 @@ class NewDevice extends Component { render() { const deviceOptions = [ - //stuff - {key:"thermostat", - text:"Thermostat", - value:"thermostat", - image:{}}, - {key:"curtains", - text:"Curtain", - value:"curtains", - image:{}}, - //stuff ends + //stuff + { key: "thermostat", text: "Thermostat", value: "thermostat", image: {} }, + { key: "curtains", text: "Curtain", value: "curtains", image: {} }, + //stuff ends { key: "light", text: "Normal Light", @@ -210,11 +204,11 @@ class NewDevice extends Component { image: { avatar: true, src: "/img/plusMinus.svg" }, }, { - key: "securityCamera", - text: "Security Camera", - value: "securityCamera", - image: { avatar: true, src: "/img/plusMinus.svg" }, - } + key: "securityCamera", + text: "Security Camera", + value: "securityCamera", + image: { avatar: true, src: "/img/plusMinus.svg" }, + }, ]; const sensorOptions = [ {