Skip to content

Commit

Permalink
Merge pull request #131 from cgiesche/streamdeck-homeassistant-111
Browse files Browse the repository at this point in the history
Re-Added changes from @Grayda
  • Loading branch information
cgiesche committed Jan 27, 2023
2 parents c2899f5 + ea667f5 commit 3ffc938
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/PluginComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ export default {
changedContexts.forEach(context => {
try {
if(stateMessage.last_updated != null) stateMessage.attributes["last_updated"] = new Date(stateMessage.last_updated).toLocaleTimeString();
if(stateMessage.last_changed != null) stateMessage.attributes["last_changed"] = new Date(stateMessage.last_changed).toLocaleTimeString();
if (stateMessage.last_updated != null) stateMessage.attributes["last_updated"] = new Date(stateMessage.last_updated).toLocaleTimeString();
if (stateMessage.last_changed != null) stateMessage.attributes["last_changed"] = new Date(stateMessage.last_changed).toLocaleTimeString();
updateContextState(context, entity, stateMessage);
} catch (e) {
Expand All @@ -197,12 +197,20 @@ export default {
const buttonImage = this.buttonImageFactory.createButton(entityConfig);
if (contextSettings.useStateImagesForOnOffStates) {
if (stateObject.state === "on") {
this.$SD.setState(currentContext, 1);
} else if (stateObject.state === "playing") {
this.$SD.setState(currentContext, 1);
} else {
this.$SD.setState(currentContext, 0);
switch (stateObject.state) {
case "on":
case "playing":
case "open":
case "opening":
case "home":
case "locked":
case "active":
console.log("Setting state of " + currentContext + " to 1")
this.$SD.setState(currentContext, 1);
break;
default:
console.log("Setting state of " + currentContext + " to 0")
this.$SD.setState(currentContext, 0);
}
} else {
setButtonSVG(buttonImage, currentContext)
Expand Down

0 comments on commit 3ffc938

Please sign in to comment.