Fixed warning and merge in thermostats
This commit is contained in:
parent
74a5e49776
commit
f6f46918c6
6 changed files with 35 additions and 86 deletions
|
@ -255,8 +255,6 @@ class AutomationSaveModal extends Component {
|
|||
}
|
||||
|
||||
_checkNewTrigger(trigger) {
|
||||
const auxDevice = this.props.devices[trigger.device];
|
||||
|
||||
// Check for missing fields for creation
|
||||
const error = {
|
||||
result: false,
|
||||
|
@ -271,6 +269,8 @@ class AutomationSaveModal extends Component {
|
|||
case "rangeTrigger":
|
||||
if (!trigger.device || !trigger.operand || !trigger.value) return error;
|
||||
break;
|
||||
default:
|
||||
throw new Error("theoretically unreachable statement");
|
||||
}
|
||||
|
||||
const isNotDuplicate = !this.state.triggerList.some(
|
||||
|
@ -345,6 +345,8 @@ class AutomationSaveModal extends Component {
|
|||
return "" + trigger.device + trigger.on;
|
||||
case "rangeTrigger":
|
||||
return "" + trigger.device + trigger.operand + trigger.value;
|
||||
default:
|
||||
throw new Error("theoretically unreachable statement");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { Component, useState, useEffect } from "react";
|
||||
import React, { Component } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { RemoteService } from "../../remote";
|
||||
import "./Automations.css";
|
||||
|
|
|
@ -4,10 +4,6 @@ import { RemoteService } from "../../remote";
|
|||
import { Card, Segment, Header, Icon } from "semantic-ui-react";
|
||||
|
||||
class HostsPanel extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Card.Group centered style={{ paddingTop: "3rem" }}>
|
||||
|
|
|
@ -7,7 +7,7 @@ import Switcher from "./Switch";
|
|||
import Videocam from "./Videocam";
|
||||
import Curtains from "./Curtain";
|
||||
import Thermostat from "./Thermostats";
|
||||
import { Segment, Grid, Header, Button, Icon, Card } from "semantic-ui-react";
|
||||
import { Header, Button, Icon, Card } from "semantic-ui-react";
|
||||
import { RemoteService } from "../../../remote";
|
||||
import { connect } from "react-redux";
|
||||
import DeviceSettingsModal from "./DeviceSettingsModal";
|
||||
|
@ -157,39 +157,35 @@ class Device extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
{
|
||||
return (
|
||||
<Card
|
||||
style={{ height: this.props.tab === "Devices" ? "23em" : "27em" }}
|
||||
>
|
||||
<Card.Content>
|
||||
<Card.Header textAlign="center">
|
||||
<Header as="h3">{this.deviceName}</Header>
|
||||
{this.props.tab === "Scenes" ? (
|
||||
<Header as="h4">{this.props.roomName}</Header>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Card.Header>
|
||||
return (
|
||||
<Card style={{ height: this.props.tab === "Devices" ? "23em" : "27em" }}>
|
||||
<Card.Content>
|
||||
<Card.Header textAlign="center">
|
||||
<Header as="h3">{this.deviceName}</Header>
|
||||
{this.props.tab === "Scenes" ? (
|
||||
<Header as="h4">{this.props.roomName}</Header>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Card.Header>
|
||||
|
||||
<Card.Description style={centerComponent}>
|
||||
{this.renderDeviceComponent()}
|
||||
</Card.Description>
|
||||
</Card.Content>
|
||||
<Card.Content extra>
|
||||
{this.props.tab === "Devices"
|
||||
? this.deviceDescription()
|
||||
: this.stateDescription()}
|
||||
</Card.Content>
|
||||
{this.props.tab === "Devices" ? (
|
||||
<DeviceSettingsModal
|
||||
ref={this.modalRef}
|
||||
id={this.props.stateOrDevice.id}
|
||||
/>
|
||||
) : null}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
<Card.Description style={centerComponent}>
|
||||
{this.renderDeviceComponent()}
|
||||
</Card.Description>
|
||||
</Card.Content>
|
||||
<Card.Content extra>
|
||||
{this.props.tab === "Devices"
|
||||
? this.deviceDescription()
|
||||
: this.stateDescription()}
|
||||
</Card.Content>
|
||||
{this.props.tab === "Devices" ? (
|
||||
<DeviceSettingsModal
|
||||
ref={this.modalRef}
|
||||
id={this.props.stateOrDevice.id}
|
||||
/>
|
||||
) : null}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ class Thermostats extends Component {
|
|||
console.log(this.state);
|
||||
this.setMode = this.setMode.bind(this);
|
||||
this.setTargetTemperature = this.setTargetTemperature.bind(this);
|
||||
this.setTargetTemperature = this.setTargetTemperature.bind(this);
|
||||
}
|
||||
|
||||
setMode(mode) {
|
||||
|
@ -88,43 +87,6 @@ class Thermostats extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
setTargetTemperature(newTemp) {
|
||||
if (this.state.timeout) {
|
||||
clearTimeout(this.state.timeout);
|
||||
}
|
||||
|
||||
this.setState({
|
||||
newTemp,
|
||||
timeout: setTimeout(() => {
|
||||
this.saveTargetTemperature(newTemp);
|
||||
this.setState({
|
||||
targetTemperature: this.state.targetTemperature,
|
||||
timeout: null,
|
||||
});
|
||||
}, 100),
|
||||
});
|
||||
}
|
||||
|
||||
saveTargetTemperature(targetTemperature) {
|
||||
if (this.props.tab === "Devices") {
|
||||
this.props
|
||||
.saveDevice({
|
||||
...this.props.device,
|
||||
turnOn: this.props.device.mode !== "OFF",
|
||||
targetTemperature,
|
||||
})
|
||||
.catch((err) => console.error("thermostat update error", err));
|
||||
} else {
|
||||
this.props.updateState(
|
||||
{
|
||||
id: this.props.stateOrDevice.id,
|
||||
targetTemperature: targetTemperature,
|
||||
},
|
||||
this.props.stateOrDevice.kind
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
setTargetTemperature() {
|
||||
this.saveTargetTemperature(this.state.targetTemperature);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
import React, { Component } from "react";
|
||||
import {
|
||||
Menu,
|
||||
Button,
|
||||
Grid,
|
||||
Icon,
|
||||
Responsive,
|
||||
Dropdown,
|
||||
} from "semantic-ui-react";
|
||||
import { Menu, Grid, Responsive, Dropdown } from "semantic-ui-react";
|
||||
import HostModal from "../components/HostModal";
|
||||
import { RemoteService } from "../remote";
|
||||
import { connect } from "react-redux";
|
||||
|
|
Loading…
Reference in a new issue