fix turn on/off thermostat
This commit is contained in:
parent
3ca1f519b6
commit
6ecfe9653d
1 changed files with 145 additions and 142 deletions
|
@ -20,8 +20,7 @@ class Thermostats extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
targetTemperature: this.props.device.targetTemperature,
|
targetTemperature: this.props.device.targetTemperature,
|
||||||
internalSensorTemperature: this.props.device
|
internalSensorTemperature: this.props.device.internalSensorTemperature,
|
||||||
.internalSensorTemperature,
|
|
||||||
mode: this.props.device.mode,
|
mode: this.props.device.mode,
|
||||||
measuredTemperature: this.props.device.measuredTemperature,
|
measuredTemperature: this.props.device.measuredTemperature,
|
||||||
useExternalSensors: this.props.device.useExternalSensors,
|
useExternalSensors: this.props.device.useExternalSensors,
|
||||||
|
@ -59,9 +58,14 @@ class Thermostats extends Component {
|
||||||
if (this.state.timeout) {
|
if (this.state.timeout) {
|
||||||
clearTimeout(this.state.timeout);
|
clearTimeout(this.state.timeout);
|
||||||
}
|
}
|
||||||
|
console.log(mode);
|
||||||
|
|
||||||
//i came to the conclusion that is not possible to set 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 = () => {
|
onClickDevice = () => {
|
||||||
|
@ -112,8 +116,7 @@ class Thermostats extends Component {
|
||||||
timeout: setTimeout(() => {
|
timeout: setTimeout(() => {
|
||||||
this.saveInternalSensorTemperature(newTemp);
|
this.saveInternalSensorTemperature(newTemp);
|
||||||
this.setState({
|
this.setState({
|
||||||
internalSensorTemperature: this.state
|
internalSensorTemperature: this.state.internalSensorTemperature,
|
||||||
.internalSensorTemperature,
|
|
||||||
timeout: null,
|
timeout: null,
|
||||||
});
|
});
|
||||||
}, 100),
|
}, 100),
|
||||||
|
@ -165,8 +168,8 @@ class Thermostats extends Component {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
slider
|
slider
|
||||||
style={toggle}
|
style={toggle}
|
||||||
// TODO Manage the state here
|
// TODO Manage the state hereconsole.log("CHANGE", val.checked)
|
||||||
onChange={(e, val) => console.log("CHANGE", val.checked)}
|
onChange={(e, val) => this.setMode(val.checked)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<span style={targetTemperature}>
|
<span style={targetTemperature}>
|
||||||
|
|
Loading…
Reference in a new issue