diff --git a/smart-hut/src/components/dashboard/devices/Light.js b/smart-hut/src/components/dashboard/devices/Light.js index dc0c4f5..2a62ea9 100644 --- a/smart-hut/src/components/dashboard/devices/Light.js +++ b/smart-hut/src/components/dashboard/devices/Light.js @@ -72,10 +72,18 @@ class Light extends Component { .saveDevice({ ...this.props.stateOrDevice, on }) .catch((err) => console.error("regular light update error", err)); } else { - this.props.updateState( - { id: this.props.sceneState.id, on: on }, - this.props.sceneState.kind - ); + this.props + .updateState( + { + id: this.props.sceneState.id, + on: on, + sceneId: this.props.sceneState.sceneId, + }, + this.props.sceneState.kind + ) + .then((res) => { + console.log(res); + }); } }; diff --git a/smart-hut/src/remote.js b/smart-hut/src/remote.js index 466ccc8..06de6c9 100644 --- a/smart-hut/src/remote.js +++ b/smart-hut/src/remote.js @@ -386,7 +386,7 @@ export const RemoteService = { return Endpoint.put(url, {}, data) .then((res) => { - dispatch(actions.stateUpdate(res.data)); + dispatch(actions.stateSave(res.data)); return res.data; }) .catch((err) => { diff --git a/smart-hut/src/store.js b/smart-hut/src/store.js index 0e91ef8..c632ef4 100644 --- a/smart-hut/src/store.js +++ b/smart-hut/src/store.js @@ -164,9 +164,6 @@ function reducer(previousState, action) { newState = update(newState, change); - break; - case "STATE_UPDATE": - //update the state break; case "DEVICES_UPDATE": change = null; @@ -295,7 +292,12 @@ function reducer(previousState, action) { sceneStates: { [action.sceneState.id]: { $set: action.sceneState } }, }; - if (previousState.scenes[action.sceneState.sceneId]) { + if ( + !previousState.scenes[action.sceneState.sceneId].sceneStates[ + action.sceneState.id + ] + ) { + console.log("Ciao"); change.scenes = { [action.sceneState.sceneId]: { sceneStates: {