forked from platypush/platypush
[light.hue] [UI] Better support for group scenes.
This commit is contained in:
parent
2d8f4196e1
commit
ae0dfb08bc
2 changed files with 17 additions and 9 deletions
|
@ -30,8 +30,17 @@ export default {
|
||||||
name: "Light",
|
name: "Light",
|
||||||
components: {Group, Groups},
|
components: {Group, Groups},
|
||||||
mixins: [Utils, Panel],
|
mixins: [Utils, Panel],
|
||||||
emits: ['group-toggle', 'light-toggle', 'set-light', 'set-group', 'select-scene', 'start-animation', 'stop-animation',
|
emits: [
|
||||||
'refresh', 'light-changed'],
|
'group-toggle',
|
||||||
|
'light-changed',
|
||||||
|
'light-toggle',
|
||||||
|
'refresh',
|
||||||
|
'select-scene',
|
||||||
|
'set-group',
|
||||||
|
'set-light',
|
||||||
|
'start-animation',
|
||||||
|
'stop-animation',
|
||||||
|
],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
lights: {
|
lights: {
|
||||||
|
@ -65,10 +74,6 @@ export default {
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
|
||||||
pluginName: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
initialGroup: {
|
initialGroup: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
},
|
},
|
||||||
|
@ -140,7 +145,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
...animations,
|
...animations,
|
||||||
...Object.entries(this.animations?.lights || {}).reduce((obj, [lightId, animation]) => {
|
...Object.entries(this.animations?.lights || {}).reduce((obj, [lightId, animation]) => {
|
||||||
const group = Object.values(self.groupsByLight[lightId])?.[0]
|
const group = Object.values(self.groupsByLight[lightId] || {})?.[0]
|
||||||
if (group) {
|
if (group) {
|
||||||
if (animation && group.id != null) {
|
if (animation && group.id != null) {
|
||||||
if (!obj[group.id])
|
if (!obj[group.id])
|
||||||
|
@ -244,4 +249,4 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -67,7 +67,10 @@ export default {
|
||||||
|
|
||||||
async getScenes() {
|
async getScenes() {
|
||||||
return Object.entries(await this.request('light.hue.get_scenes'))
|
return Object.entries(await this.request('light.hue.get_scenes'))
|
||||||
.filter((scene) => !scene[1].recycle && scene[1].type.toLowerCase() === 'lightscene')
|
.filter((scene) =>
|
||||||
|
!scene[1].recycle &&
|
||||||
|
['lightscene', 'groupscene'].includes(scene[1].type.toLowerCase())
|
||||||
|
)
|
||||||
.reduce((obj, [id, scene]) => {
|
.reduce((obj, [id, scene]) => {
|
||||||
obj[id] = scene
|
obj[id] = scene
|
||||||
return obj
|
return obj
|
||||||
|
|
Loading…
Reference in a new issue