Merge branch '87-fix-thermostat' into 'dev'

fix thermostat

Closes #87

See merge request sa4-2020/the-sanmarinoes/frontend!102
This commit is contained in:
Andrea Brites Marto 2020-04-28 10:51:07 +02:00
commit 7135ddc588
2 changed files with 38 additions and 37 deletions

View file

@ -72,18 +72,20 @@ class Light extends Component {
.saveDevice({ ...this.props.stateOrDevice, on }) .saveDevice({ ...this.props.stateOrDevice, on })
.catch((err) => console.error("regular light update error", err)); .catch((err) => console.error("regular light update error", err));
} else { } else {
this.props if (this.props.device.kind === "regularLight") {
.updateState( this.props
{ .updateState(
id: this.props.stateOrDevice.id, {
on: on, id: this.props.stateOrDevice.id,
sceneId: this.props.stateOrDevice.sceneId, on: on,
}, sceneId: this.props.stateOrDevice.sceneId,
this.props.stateOrDevice.kind },
) this.props.stateOrDevice.kind
.then((res) => { )
console.log(res); .then((res) => {
}); console.log(res);
});
}
} }
}; };
@ -117,10 +119,15 @@ class Light extends Component {
.saveDevice({ ...this.props.stateOrDevice, intensity }) .saveDevice({ ...this.props.stateOrDevice, intensity })
.catch((err) => console.error("regular light update error", err)); .catch((err) => console.error("regular light update error", err));
} else { } else {
this.props.updateState( console.log("CIAOOOOOOOOO", this.props.stateOrDevice);
{ id: this.props.stateOrDevice.id, intensity: intensity }, this.props
this.props.stateOrDevice.kind .updateState(
); { id: this.props.stateOrDevice.id, intensity: intensity },
this.props.stateOrDevice.kind
)
.then((res) => {
console.log(res, this.props.stateOrDevice.kind);
});
} }
}; };

View file

@ -106,7 +106,7 @@ class NewDevice extends Component {
switch: "New switch", switch: "New switch",
buttonDimmer: "New button dimmer", buttonDimmer: "New button dimmer",
knobDimmer: "New knob dimmer", knobDimmer: "New knob dimmer",
securityCamera: "New security camera" securityCamera: "New security camera",
}; };
if (this.state.deviceName === "") { if (this.state.deviceName === "") {
@ -118,13 +118,13 @@ class NewDevice extends Component {
switch (this.state.typeOfDevice) { switch (this.state.typeOfDevice) {
//trying to make securityCamera work //trying to make securityCamera work
//case "securityCamera": //case "securityCamera":
// data.path="/security_camera_videos/security_camera_1.mp4"; // data.path="/security_camera_videos/security_camera_1.mp4";
// data.on=false; // data.on=false;
//break; //break;
//trying to make thermostat work //trying to make thermostat work
case "thermostat": case "thermostat":
data.targetTemperature=0; data.targetTemperature = 0;
data.measuredTemperuature=0; data.measuredTemperature = 0;
break; break;
case "dimmableLight": case "dimmableLight":
data.intensity = 0; data.intensity = 0;
@ -157,16 +157,10 @@ class NewDevice extends Component {
render() { render() {
const deviceOptions = [ const deviceOptions = [
//stuff //stuff
{key:"thermostat", { key: "thermostat", text: "Thermostat", value: "thermostat", image: {} },
text:"Thermostat", { key: "curtains", text: "Curtain", value: "curtains", image: {} },
value:"thermostat", //stuff ends
image:{}},
{key:"curtains",
text:"Curtain",
value:"curtains",
image:{}},
//stuff ends
{ {
key: "light", key: "light",
text: "Normal Light", text: "Normal Light",
@ -210,11 +204,11 @@ class NewDevice extends Component {
image: { avatar: true, src: "/img/plusMinus.svg" }, image: { avatar: true, src: "/img/plusMinus.svg" },
}, },
{ {
key: "securityCamera", key: "securityCamera",
text: "Security Camera", text: "Security Camera",
value: "securityCamera", value: "securityCamera",
image: { avatar: true, src: "/img/plusMinus.svg" }, image: { avatar: true, src: "/img/plusMinus.svg" },
} },
]; ];
const sensorOptions = [ const sensorOptions = [
{ {