Merge branch '85-thermostat-fix-2' into 'dev'

thermostat fix

Closes #85

See merge request sa4-2020/the-sanmarinoes/frontend!100
This commit is contained in:
Andrea Brites Marto 2020-04-27 19:27:49 +02:00
commit 1d1fbe335e
4 changed files with 66 additions and 57 deletions

View File

@ -80,12 +80,14 @@ class NewSceneDevice extends Component {
const availableDevices = [];
this.props.devices.forEach((e) => {
if (!Object.keys(this.state.sceneDevices).find((d) => e.id === d)) {
if (e.flowType === "OUTPUT") {
availableDevices.push({
key: e.id,
text: e.name,
value: e.id,
});
}
}
});
return (
<Modal

View File

@ -3,7 +3,7 @@
width: 20rem;
font-family: "Lato";
position: absolute;
margin-top: 32%;
margin-top: 27%;
margin-left: 50%;
transform: translate(-50%, -50%);
}

View File

@ -31,7 +31,7 @@ export const targetTemperature = {
marginTop: "20%",
marginLeft: "50%",
transform: "translate(-50%,-50%)",
fontSize: "3.5rem",
fontSize: "2rem",
fontWeight: "bold",
color: "#646464",
};
@ -48,9 +48,9 @@ export const slider = {
export const stateTagContainer = {
textAlign: "center",
position: "absolute",
width: "4rem",
height: "1rem",
marginTop: "40%",
//width: "3rem",
height: "2rem",
marginTop: "35%",
marginLeft: "50%",
transform: "translate(-50%,-50%)",
padding: "0.5rem 4rem",

View File

@ -64,6 +64,7 @@ class Thermostats extends Component {
//i came to the conclusion that is not possible to set mode.
//this.mode = "HEATING";
const turnOn = mode;
console.log(turnOn);
if (this.props.tab === "Devices") {
this.props
.saveDevice({ ...this.props.stateOrDevice, turnOn })
@ -92,9 +93,14 @@ class Thermostats extends Component {
//It seems to work
saveTargetTemperature(targetTemperature) {
const turn = this.props.stateOrDevice.mode !== "OFF" ? true : false;
if (this.props.tab === "Devices") {
this.props
.saveDevice({ ...this.props.stateOrDevice, targetTemperature })
.saveDevice({
...this.props.stateOrDevice,
targetTemperature,
turnOn: turn,
})
.catch((err) => console.error("thermostat update error", err));
} else {
this.props.updateState(
@ -174,6 +180,7 @@ class Thermostats extends Component {
<h3 style={deviceName}>{this.props.stateOrDevice.name}</h3>
<div style={line}></div>
<Checkbox
checked={this.props.stateOrDevice.mode !== "OFF" ? true : false}
slider
style={toggle}
// TODO Manage the state hereconsole.log("CHANGE", val.checked)