Hue scenes mimicked in Ha (and on Buttons, was Tiles)

Thanks ! Good job!

Thanks you too! I have a quick other question since I see that you developed the new custom-ui. Not sure where else to post this or to send a pm, but after updating this code no longer works for me:

customize_glob.yaml:

cover.*:
  templates:
    entity_picture: >
        if (state === 'closed') return '/local/venetian-blinds/light/blinds_00.png';
        if (attributes.current_position <= 25) return '/local/venetian-blinds/light/blinds_25.png';
        if (attributes.current_position <= 50) return '/local/venetian-blinds/light/blinds_50.png';
        if (attributes.current_position <= 75) return '/local/venetian-blinds/light/blinds_75.png';
        return '/local/venetian-blinds/light/blinds_100.png';

I can see a picture whenever I just add entity_picture: … but not with templates. Am I doing something wrong?

not sure about this one really, I had an issue with entity_picture lately. but it was solved, so I am sure we can still customize entity_pictures with a template

just for the sake of testing, what happens if you use an icon_template and use 4 different icons. To test if the ‘(attributes.current_position <= 25)’ is correct. You’re sure its an int and not a string? in which case it should be '(attributes.current_position|float <= 25). Still, I use the too below, so it shouldn’t be that.

I use this, but its entirely different, I know… using the state of another entity.

    cover.raamverduistering_stookhok:
      templates:
        icon: >
          if (entities['input_select.raamverduistering_stookhok'].state == 'Opening') return 'mdi:archive-arrow-up';
          if (entities['input_select.raamverduistering_stookhok'].state == 'Closing') return 'mdi:archive-arrow-down';
          if (attributes.current_position == 100) return 'mdi:window-shutter-open';
          if (state == 'closed') return 'mdi:window-shutter';
          return 'mdi:window-shutter-alert';
        icon_color: >
          if (entities['input_select.raamverduistering_stookhok'].state == 'Opening') return 'orange';
          if (entities['input_select.raamverduistering_stookhok'].state == 'Closing') return 'steelblue';
          if (attributes.current_position == 100) return 'gold';
          if (state == 'closed') return 'midnightblue';
          return 'green';

this works in my setting:

    sensor.dark_sky*icon*:
      templates:
        entity_picture: >
          return '/local/weather/icons/' + state + '.png';

I’ve tried this but nothing changes:

cover.*:
  templates:
    icon: >
      if (entities['person.nick'].state == 'home') return 'mdi:archive-arrow-up';
      else return 'mdi:window-shutter-alert';
      
cover.*:
  templates:
    entity_picture: >
          return '/local/venetian-blinds/light/blinds_00.png';

I think the problem is somewhere else, my config looks like this now:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

homeassistant:
  customize: !include customize.yaml
  customize_glob: !include customize_glob.yaml
  
frontend:
  themes: !include_dir_merge_named themes

    
lovelace:
  mode: storage
  resources: !include lovelace/resources/resources.yaml
  # Add yaml dashboards
  dashboards:
    nima-yaml:
      mode: yaml
      title: NiMa
      icon: mdi:home
      show_in_sidebar: true
      filename: nima.yaml  

And in my resources I have this:

  - type: module
    url: /hacsfiles/custom-ui/custom-ui.js

The custom-ui.js file is placed in /local/community/custom-ui/custom-ui.js

Wait, you’re saying none of the custom-ui settings have effect ?

In that case we best change to another thread and leave Hue here , as this strays too far off topic…

what thread? Is there a custom-ui thread

are you guys kidding? this whole thread should not exist… it’s a pain in the ass how HA handles Hue scenes … and it’s a shame …thought FHEM is outdated bs … but HA … omg … things are just not ready yet

Dear All

im new at HA , i used Domoticz for some years. but how to intergrate the hue scenes . ?
i do not now how., please describe step by step

it is all described in this topic above, which bit didn’t you understand?

Sorry , im new and i do not know where and how things work. i need more
detailed information

exactly how new are you here? I mean, you are aware one needs to create several backend entities first (input_select, groups, scripts, etc)
like:

input_select:

  hue_scenes:
    name: Select Hue Scenes
    icon: mdi:palette
    options:
      - Arctische dageraad
      - Savanne zonsondergang
      - Tropische schemering
      - Lentebloesem
      - Concentreren
      - Gedimd
      - Energie
      - Helder
      - Lezen
      - Nachtlampje
      - Ontspannen
      - 'Off'

script:
  button_set_hue_scene:
    alias: Button set Hue scene
    mode: restart
    sequence:
      service: input_select.select_option
      entity_id: input_select.hue_scenes
      data:
        option: >
          {{option}}

  set_hue_scene:
    alias: Set Hue scene
    mode: restart
    icon: mdi:power
    sequence:
      service: hue.hue_activate_scene
      data:
        group_name: >
          {{states('input_select.hue_groups')}}
        scene_name: >
          {{states('input_select.hue_scenes')}}

to be able to show these in the Lovelace frontend and interact with them?

type: vertical-stack
cards:

  - type: custom:button-card
    name: Set Hue scene
    template: button_default_title

  - type: horizontal-stack
    cards:

      - type: custom:decluttering-card
        template: set_hue_scene
        variables:
          - option: Arctische dageraad
          - entity_picture: /local/hue_scenes/arctic.png
          - name: Arctic
          - color: '#00d0a0'

      - type: custom:decluttering-card
        template: set_hue_scene
        variables:
          - option: Savanne zonsondergang
          - entity_picture: /local/hue_scenes/savanna.png
          - name: Savanna
          - color: '#ff7935'

and decluttering template:

card:
  type: custom:button-card
  template: button_picture_script_small
  entity_picture: '[[entity_picture]]'
  name: '[[name]]'
  tap_action:
    action: call-service
    service: script.button_set_hue_scene
    service_data:
      option: '[[option]]'
  state:
    - operator: template
      value: >
        [[[ return states['input_select.hue_scenes'].state == '[[option]]'; ]]]
      color: '[[color]]'
      styles:
        name:
          - color: var(--background-color-off)

important part: have Hue setup in your config, to have the groups, and interact with them?

so bottomline: first of all, read the documentation: https://www.home-assistant.io/integrations/hue/#using-hue-scenes-in-home-assistant

im just a week online with HA , so everything is now for me

well, tbh, everything is here, so maybe first try to get acquainted with HA in a broader sense, before plunging this deep.

start with a single service call of the hue.hue_activate_scene and a group you have available (check for the is_hue_group attribute on your lights.)

If you understand that, you can write that in a script, combined with an set of input_select s for the scene and the light groups. This will use templates to use the states of these input_selects and mold them into the script…

If all of that works, you can start adding them to your Lovelace config to show them in the frontend and manipulate them.

As said, its all in the above thread.

Hello this looks really good and just what im looking for, i am new to all this HA.
where abouts would i stick all the code for this?

1 Like

I also ask for the same, very new.

It’s for use in yaml-mode (please compare the documentation for further information). But you can also build it for ui-dashboard.

  1. Go to Settings —> Helper — > Add —> Dropdown, and fill in your data.

  2. Go to Settings —> Scripts — > Add, and transcript the above script codes.

  3. Go to your dashboard —> Edit — > Add Card —> Entity, and choose your new input_select entities and the executing script.

Is it possible to use the new dynamic scenes like this?

First, thanks for this great post!

@HorizonKane Make sure your lights are off when hitting the POST button in CLIP.
Do delete a scene browse to id in CLIP, e.g. /api/‘user id’/scenes/‘id you want to delete’ and hit DELETE button in CLIP.

Note that you can also specify a GroupScene instead of a list of Lights, then if you add or remove lights the Off scene gets automatically updated:
{
“name”:“Off”,
“type”:“GroupScene”,
“group”:“6”,
“recycle”:false}

I love this, very cool :slight_smile:

with the arrival of Hue api v2, I parked the above setup, and switched over to: