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) {
|
_checkNewTrigger(trigger) {
|
||||||
const auxDevice = this.props.devices[trigger.device];
|
|
||||||
|
|
||||||
// Check for missing fields for creation
|
// Check for missing fields for creation
|
||||||
const error = {
|
const error = {
|
||||||
result: false,
|
result: false,
|
||||||
|
@ -271,6 +269,8 @@ class AutomationSaveModal extends Component {
|
||||||
case "rangeTrigger":
|
case "rangeTrigger":
|
||||||
if (!trigger.device || !trigger.operand || !trigger.value) return error;
|
if (!trigger.device || !trigger.operand || !trigger.value) return error;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("theoretically unreachable statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
const isNotDuplicate = !this.state.triggerList.some(
|
const isNotDuplicate = !this.state.triggerList.some(
|
||||||
|
@ -345,6 +345,8 @@ class AutomationSaveModal extends Component {
|
||||||
return "" + trigger.device + trigger.on;
|
return "" + trigger.device + trigger.on;
|
||||||
case "rangeTrigger":
|
case "rangeTrigger":
|
||||||
return "" + trigger.device + trigger.operand + trigger.value;
|
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 { connect } from "react-redux";
|
||||||
import { RemoteService } from "../../remote";
|
import { RemoteService } from "../../remote";
|
||||||
import "./Automations.css";
|
import "./Automations.css";
|
||||||
|
|
|
@ -4,10 +4,6 @@ import { RemoteService } from "../../remote";
|
||||||
import { Card, Segment, Header, Icon } from "semantic-ui-react";
|
import { Card, Segment, Header, Icon } from "semantic-ui-react";
|
||||||
|
|
||||||
class HostsPanel extends Component {
|
class HostsPanel extends Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Card.Group centered style={{ paddingTop: "3rem" }}>
|
<Card.Group centered style={{ paddingTop: "3rem" }}>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import Switcher from "./Switch";
|
||||||
import Videocam from "./Videocam";
|
import Videocam from "./Videocam";
|
||||||
import Curtains from "./Curtain";
|
import Curtains from "./Curtain";
|
||||||
import Thermostat from "./Thermostats";
|
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 { RemoteService } from "../../../remote";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import DeviceSettingsModal from "./DeviceSettingsModal";
|
import DeviceSettingsModal from "./DeviceSettingsModal";
|
||||||
|
@ -157,39 +157,35 @@ class Device extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
{
|
return (
|
||||||
return (
|
<Card style={{ height: this.props.tab === "Devices" ? "23em" : "27em" }}>
|
||||||
<Card
|
<Card.Content>
|
||||||
style={{ height: this.props.tab === "Devices" ? "23em" : "27em" }}
|
<Card.Header textAlign="center">
|
||||||
>
|
<Header as="h3">{this.deviceName}</Header>
|
||||||
<Card.Content>
|
{this.props.tab === "Scenes" ? (
|
||||||
<Card.Header textAlign="center">
|
<Header as="h4">{this.props.roomName}</Header>
|
||||||
<Header as="h3">{this.deviceName}</Header>
|
) : (
|
||||||
{this.props.tab === "Scenes" ? (
|
""
|
||||||
<Header as="h4">{this.props.roomName}</Header>
|
)}
|
||||||
) : (
|
</Card.Header>
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Card.Header>
|
|
||||||
|
|
||||||
<Card.Description style={centerComponent}>
|
<Card.Description style={centerComponent}>
|
||||||
{this.renderDeviceComponent()}
|
{this.renderDeviceComponent()}
|
||||||
</Card.Description>
|
</Card.Description>
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
<Card.Content extra>
|
<Card.Content extra>
|
||||||
{this.props.tab === "Devices"
|
{this.props.tab === "Devices"
|
||||||
? this.deviceDescription()
|
? this.deviceDescription()
|
||||||
: this.stateDescription()}
|
: this.stateDescription()}
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
{this.props.tab === "Devices" ? (
|
{this.props.tab === "Devices" ? (
|
||||||
<DeviceSettingsModal
|
<DeviceSettingsModal
|
||||||
ref={this.modalRef}
|
ref={this.modalRef}
|
||||||
id={this.props.stateOrDevice.id}
|
id={this.props.stateOrDevice.id}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ class Thermostats extends Component {
|
||||||
console.log(this.state);
|
console.log(this.state);
|
||||||
this.setMode = this.setMode.bind(this);
|
this.setMode = this.setMode.bind(this);
|
||||||
this.setTargetTemperature = this.setTargetTemperature.bind(this);
|
this.setTargetTemperature = this.setTargetTemperature.bind(this);
|
||||||
this.setTargetTemperature = this.setTargetTemperature.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setMode(mode) {
|
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() {
|
setTargetTemperature() {
|
||||||
this.saveTargetTemperature(this.state.targetTemperature);
|
this.saveTargetTemperature(this.state.targetTemperature);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import {
|
import { Menu, Grid, Responsive, Dropdown } from "semantic-ui-react";
|
||||||
Menu,
|
|
||||||
Button,
|
|
||||||
Grid,
|
|
||||||
Icon,
|
|
||||||
Responsive,
|
|
||||||
Dropdown,
|
|
||||||
} from "semantic-ui-react";
|
|
||||||
import HostModal from "../components/HostModal";
|
import HostModal from "../components/HostModal";
|
||||||
import { RemoteService } from "../remote";
|
import { RemoteService } from "../remote";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
|
Loading…
Reference in a new issue