Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use scenes from Hue #35

Open
barryvdh opened this issue Dec 16, 2023 · 8 comments · Fixed by #72
Open

Use scenes from Hue #35

barryvdh opened this issue Dec 16, 2023 · 8 comments · Fixed by #72
Assignees

Comments

@barryvdh
Copy link

I have a lot of scenes in Hue. Is it possible to get the scenes from there?

The scene does have brightness setting:

I think that roughly matches (if the temperature in lights is 0-255 instead of 0-100?)
image

What I do now is create a template that calls the scene, but shows the state from your scene.

type: grid
cards:
  - type: custom:mushroom-template-card
    entity: switch.helder_stateful_scene
    tap_action:
      action: call-service
      service: scene.turn_on
      target:
        entity_id:
          - scene.helder
        device_id: []
        area_id: []
    icon: hue:scene-bright
    primary: Helder
    multiline_secondary: true
    secondary: '{{  bool(states(entity)) | iif(''Aan'', ''Uit'')}}'
    icon_color: '{{ iif(bool(states(entity)), ''orange'', ''grey'') }}'

Which now calls the scene I created in HA, but that wouldn't be necessary in that case. But not sure how reliable it is.

(I used the call-service instead of the toggle because that seemed more reliable, to force the state even if already active)

@mattmon
Copy link

mattmon commented Jan 18, 2024

+1
The hue integration doesn’t fully sync scenes with HA, though does expose services to interact with them. Having the ability to determine which hue scene is active, per area, would be awesome.

@hugobloem
Copy link
Owner

I am happy to work on this but unfortunately, I don't have any Hue hardware. Does Hue provide any state information itself? Or any information as to what Lights are triggered by a scene?

@barryvdh
Copy link
Author

I don't think so. I think it does map to a group, which can be used for the current value though.

@hugobloem
Copy link
Owner

Hmm, but there is no way of knowing what the values of the group are when the state is active...?

@barryvdh
Copy link
Author

No, only by checking the brightness, similar to this automation.

What I currently do is is a helper, which is basically looping through all the states from Hue which have a certain Room as attribute, and match the first one in range. (There is a conversion bug in the Hue automation I think, hence the 100->255)

{%- for state in states
  | selectattr('domain', 'eq', 'scene')
  | selectattr('attributes.group_type', 'eq', 'room')
  | selectattr('attributes.group_name', 'eq', 'Living Room')
  | selectattr("attributes.brightness", 'defined')
  -%}
  {%if (state_attr('light.living_room', 'brightness') - state.attributes.brightness/100*255) | abs | int < 5 %}
    {{state.entity_id }}
    {% break %}
  {%endif %}
{%- endfor -%}

@JoernBerkefeld
Copy link

To add to that:

  • Brightness==null means device is off
  • Brightness==255 means 100%
  • Brightness==0 means 1%

@hugobloem
Copy link
Owner

I am going to see whether it is possible to learn the scenes from Hue. That is, manually select what lights are in a scene, activate a scene, and then learn what state the lights are in when the scene is active. This will be more experimental, and I will see how far I get along.

Note that I don't have a Hue bridge so I will be testing this using virtual devices. If I get it working on that I might ask one of you to test it out using the Hue bridge.

@hugobloem hugobloem self-assigned this Mar 23, 2024
@hugobloem hugobloem linked a pull request Apr 7, 2024 that will close this issue
@hugobloem hugobloem reopened this Apr 7, 2024
@hugobloem
Copy link
Owner

I have created a first proof of concept to learn non-HA scenes. It is available in 1.3.0b0. Please try it out and report whether it is working or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants