-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from igor-panteleev/develop
Release 1.1.0
- Loading branch information
Showing
7 changed files
with
144 additions
and
8,194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/node_modules/ | ||
/.rpt2_cache/ | ||
/dist | ||
.idea | ||
.idea | ||
package-lock.json |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { PropertyValues } from "@lit/reactive-element"; | ||
import { HomeAssistant } from "custom-card-helpers"; | ||
import { QRCodeCardConfig } from "./types/types" | ||
import { SourceType } from "./models/source-type"; | ||
|
||
export function hasConfigOrAnyEntityChanged( | ||
watchedEntities: string[], | ||
changedProps: PropertyValues, | ||
forceUpdate: boolean, | ||
hass?: HomeAssistant, | ||
): boolean { | ||
if (changedProps.has("config") || forceUpdate) { | ||
return true; | ||
} | ||
const oldHass = changedProps.get("_hass") as HomeAssistant | undefined; | ||
return !oldHass || watchedEntities.some(entity => oldHass.states[entity] !== hass?.states[entity]); | ||
} | ||
|
||
export function getWatchedEntities(config: QRCodeCardConfig): string[] { | ||
const watchedEntities = new Set<string>(); | ||
|
||
switch (config.source) { | ||
case SourceType.ENTITY: | ||
watchedEntities.add(config.entity); | ||
break; | ||
|
||
// TODO: add support to use entities for WIFI QR code | ||
// case SourceType.WIFI: | ||
// if (config.ssid.hasOwnProperty("entity")) watchedEntities.add(config.ssid["entity"]); | ||
// if (config.password.hasOwnProperty("entity")) watchedEntities.add(config.password["entity"]); | ||
} | ||
|
||
return [...watchedEntities]; | ||
} |