fix turn on/off thermostat

This commit is contained in:
britea 2020-04-24 23:34:01 +02:00
parent 3ca1f519b6
commit 6ecfe9653d

View File

@ -20,8 +20,7 @@ class Thermostats extends Component {
super(props);
this.state = {
targetTemperature: this.props.device.targetTemperature,
internalSensorTemperature: this.props.device
.internalSensorTemperature,
internalSensorTemperature: this.props.device.internalSensorTemperature,
mode: this.props.device.mode,
measuredTemperature: this.props.device.measuredTemperature,
useExternalSensors: this.props.device.useExternalSensors,
@ -59,9 +58,14 @@ class Thermostats extends Component {
if (this.state.timeout) {
clearTimeout(this.state.timeout);
}
console.log(mode);
//i came to the conclusion that is not possible to set mode.
this.mode = "HEATING";
//this.mode = "HEATING";
const turnOn = mode;
this.props
.saveDevice({ ...this.props.device, turnOn })
.catch((err) => console.error("regular light update error", err));
}
onClickDevice = () => {
@ -112,8 +116,7 @@ class Thermostats extends Component {
timeout: setTimeout(() => {
this.saveInternalSensorTemperature(newTemp);
this.setState({
internalSensorTemperature: this.state
.internalSensorTemperature,
internalSensorTemperature: this.state.internalSensorTemperature,
timeout: null,
});
}, 100),
@ -165,8 +168,8 @@ class Thermostats extends Component {
<Checkbox
slider
style={toggle}
// TODO Manage the state here
onChange={(e, val) => console.log("CHANGE", val.checked)}
// TODO Manage the state hereconsole.log("CHANGE", val.checked)
onChange={(e, val) => this.setMode(val.checked)}
/>
<span style={targetTemperature}>