[light.hue] [UI] Better support for group scenes.

This commit is contained in:
Fabio Manganiello 2024-12-03 01:37:40 +01:00
parent 2d8f4196e1
commit ae0dfb08bc
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 17 additions and 9 deletions

View file

@ -30,8 +30,17 @@ export default {
name: "Light",
components: {Group, Groups},
mixins: [Utils, Panel],
emits: ['group-toggle', 'light-toggle', 'set-light', 'set-group', 'select-scene', 'start-animation', 'stop-animation',
'refresh', 'light-changed'],
emits: [
'group-toggle',
'light-changed',
'light-toggle',
'refresh',
'select-scene',
'set-group',
'set-light',
'start-animation',
'stop-animation',
],
props: {
lights: {
@ -65,10 +74,6 @@ export default {
default: () => {},
},
pluginName: {
type: String,
},
initialGroup: {
type: [Number, String],
},
@ -140,7 +145,7 @@ export default {
return {
...animations,
...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 (animation && group.id != null) {
if (!obj[group.id])
@ -244,4 +249,4 @@ export default {
}
}
}
</style>
</style>

View file

@ -67,7 +67,10 @@ export default {
async getScenes() {
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]) => {
obj[id] = scene
return obj