ioBroker.hue
ioBroker.hue copied to clipboard
Code error for Scene-operations main.ts line 489
In the current source code of /src/main.js of commit aa7c8fb has a code-error in line 489 which prohibits changes of scenes for light-groups.
The reference to the lightScene is not found.
Current code
const sceneObj = await this.getObjectAsync(
${channelId}.scene_${commands.scene.toLowerCase()});
it needs to be changed at least to
const sceneObj = await this.getObjectAsync(
${this.namespace}.lightScenes.scene_${commands.scene.toLowerCase()});
or better with replacing "lightScenes" with the dynamic object-group-namespace.
I don't get it, feel free to create an PR. For me the scenes start properly
You are showing the scenes for a "room". I do not have rooms. Under the hue-instance I do see all objects listed (lights and lightgroups mixed). I am migrating from hue-extended, so I am not familiar with the regular and the legacy-data-structure yet. Do you use the legacy one?
I only see the scenes under hue.0.lightScenes
Legacy just adds a useless device object in between instance and first channel. So this should not make a difference.
Can you show me the light scenes folder
To avoid confusion, I am on beta adapter-version 3.10.1
issue still persists after latest update to 3.10.2.
Your example above shows a scene-example for a group scene. When polling the Bridge info and creating the scene-objects, you do differntiate between group-scenes and global scenes (https://github.com/iobroker-community-adapters/ioBroker.hue/blob/0012c509c794526e23f18ae2571a4342c32878ec/src/main.ts#L2136). I am using global scenes, you are just handling group scenes in the code for the command-handling.
Sorry but what you are writing does not seem right from code perspective or you see something which I do not see. Group scenes are handled in a way that they are created at the corresponding group, else they are created at lightScenes
.
https://github.com/iobroker-community-adapters/ioBroker.hue/blob/21194ae683ccb73b26bb2e03108ad1cbcc06f118/src/main.ts#L2161-L2190
And the state change handling is implemented for every dp starting with scene_
like the ones in your lightScenes
channel does.
https://github.com/iobroker-community-adapters/ioBroker.hue/blob/21194ae683ccb73b26bb2e03108ad1cbcc06f118/src/main.ts#L256-L273
You should also see the corresponding log message Started scene: ...
. Please re-check, maybe something has changed with the scenes
API but code-wise it looks correct.
Hi @foxriver76 : I think the misunderstanding is about how these scene get triggered.
I am NOT changing the state of a scene datapoint. I am issueing a command in order to set a certain scene to a group of lights. The scene is not defined as a group scene for this group, but as a global scene.
Following example for the data structure:
- hue.0.Wohzimmer.* --> the light-group I want to control
- hue.0.lightScenes.scene_tagesbeleuchtung --> the scene I want to set for the light
- hue.0.Wohzimmer.command --> datapoint I am writing to with the value {"scene": "tagesbeleuchtung","transitiontime": 4}
This code here
https://github.com/iobroker-community-adapters/ioBroker.hue/blob/21194ae683ccb73b26bb2e03108ad1cbcc06f118/src/main.ts#L490-L497
can only handle a scene handed over in the command, which is a scene within the scope of the light/group I want to change. It refers to ${channelId}.scene_${commands.scene.toLowerCase()}
.
If you want to set a global scene, which is not defined in the scope of the light/group, but as a global scene under the lightScenes folder, you would need to refer to another namespace, which is ${this.namespace}.lightScenes.scene_${commands.scene.toLowerCase()}
Okay, maybe I do not fully understand which kind of scene this is. AFAIR there were scenes corresponding to a group and the Light Scenes which you can create and also define which lights are connected to the scene https://github.com/peter-murray/node-hue-api/blob/typescript/docs/scenes.md#createscene
So I am not aware how we can set a scene to lights not correlated to the specific scene by its configuration. But if you have a setup running, please feel free to create a PR.
I am afraid I do not know how PRs work and how to interact. If you want a quick fix, which still favours group-scenes over global scenes, new line 492ff would be:
var sceneObj = await this.getObjectAsync(`${channelId}.scene_${commands.scene.toLowerCase()}`); if(sceneObj === null){sceneObj = await this.getObjectAsync(`${this.namespace}.lightScenes.scene_${commands.scene.toLowerCase()}`);}
And you have tested that this works as expected? ;-)
yes, but only by modifying the code directly in the node_modules folder :P
@foxriver76 I created a PR for this