fixed scenes, add multiple states
This commit is contained in:
parent
9d8524c7c9
commit
6db8e928f1
4 changed files with 42 additions and 28 deletions
|
@ -62,8 +62,10 @@ class NewSceneDevice extends Component {
|
|||
}
|
||||
|
||||
createState() {
|
||||
const device = this.props.devices.filter(
|
||||
(e) => this.state.devicesAttached[0] === e.id
|
||||
for (let i = 0; i < this.state.devicesAttached.length; i++) {
|
||||
console.log("DIOPORCO", i, this.state.devicesAttached[i]);
|
||||
let device = this.props.devices.filter(
|
||||
(e) => this.state.devicesAttached[i] === e.id
|
||||
);
|
||||
let data = {
|
||||
sceneId: this.props.activeScene,
|
||||
|
@ -73,6 +75,7 @@ class NewSceneDevice extends Component {
|
|||
this.props
|
||||
.saveState(data)
|
||||
.catch((err) => console.error("error in creating state", err));
|
||||
}
|
||||
this.resetState();
|
||||
}
|
||||
|
||||
|
|
|
@ -179,10 +179,12 @@ class Device extends React.Component {
|
|||
? this.deviceDescription()
|
||||
: this.stateDescription()}
|
||||
</Card.Content>
|
||||
{this.props.tab === "Devices" ? (
|
||||
<DeviceSettingsModal
|
||||
ref={this.modalRef}
|
||||
id={this.props.stateOrDevice.id}
|
||||
/>
|
||||
) : null}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class Thermostats extends Component {
|
|||
.catch((err) => console.error("thermostat update error", err));
|
||||
} else {
|
||||
this.props.updateState(
|
||||
{ id: this.props.stateOrDevice.id, turnOn: turnOn },
|
||||
{ id: this.props.stateOrDevice.id, on: turnOn },
|
||||
this.props.stateOrDevice.kind
|
||||
);
|
||||
}
|
||||
|
@ -186,19 +186,20 @@ class Thermostats extends Component {
|
|||
// TODO Manage the state hereconsole.log("CHANGE", val.checked)
|
||||
onChange={(e, val) => this.setMode(val.checked)}
|
||||
/>
|
||||
|
||||
<span style={targetTemperature}>
|
||||
{this.props.stateOrDevice.targetTemperature}ºC
|
||||
{this.props.device.targetTemperature}ºC
|
||||
</span>
|
||||
{this.props.activeTab === "Devices" ? (
|
||||
<input
|
||||
type="range"
|
||||
min="0"
|
||||
max="40"
|
||||
className="slider-css"
|
||||
value={this.props.stateOrDevice.targetTemperature}
|
||||
value={this.props.device.targetTemperature}
|
||||
onChange={(event) => this.handleChange(event.target.value)}
|
||||
id="targetTemperature"
|
||||
/>
|
||||
) : null}
|
||||
<div style={stateTagContainer}>
|
||||
<span style={stateTag}>{this.props.stateOrDevice.mode}</span>
|
||||
</div>
|
||||
|
@ -215,6 +216,14 @@ const mapStateToProps = (state, ownProps) => ({
|
|||
return state.sceneStates[ownProps.id];
|
||||
}
|
||||
},
|
||||
get device() {
|
||||
if (state.active.activeTab === "Devices") {
|
||||
return state.devices[ownProps.id];
|
||||
} else {
|
||||
return state.devices[state.sceneStates[ownProps.id].deviceId];
|
||||
}
|
||||
},
|
||||
activeTab: state.activeTab,
|
||||
});
|
||||
|
||||
const ThermostatContainer = connect(
|
||||
|
|
|
@ -423,7 +423,7 @@ export const RemoteService = {
|
|||
updateState: (data, type) => {
|
||||
return (dispatch) => {
|
||||
let url;
|
||||
if (data.on) {
|
||||
if (data.on !== undefined) {
|
||||
url = "/switchableState";
|
||||
} else {
|
||||
url = "/dimmableState";
|
||||
|
|
Loading…
Reference in a new issue