#Automations and scenes

1 messages · Page 1 of 1 (latest)

oblique bronze
#

Hi everyone.

I'm currently migrating from Hue bride to Z2M and starting to mimic the "automations" I had in the Hue app as well with my Friends of Hue switch.

The behaviour I had before the migration was that the switch's on-button turned on the lights in different scenes depending on if the time was 7-20, 20-23 and 23-07. This has been quite easy to set up... in one room.

Is it really true that I have to create 3 scenes for every room that I have lights in? Ideally I thought I somehow could define a scene with "X brightness, X color temperature" and then reuse this scene around in the ecosystem.

rare lily
#

honestly this is kind of why i don't use scenes much. in HA they are for capturing "current state of these particular entities" - they are not good for being generic in the way you want them to

#

for this I'd use a script - pass it a list of entities and it applies the right state to them

#

bit more manual to set up, but much more reusable

oblique bronze
#

Alright, I'll have a look into scripts a bit more then 🙂 Would I have a script for each room then - or could I pass a list of light entities as a variable to one script and it could handle it for me?

#

Oh, you basically wrote that in your second message. Sorry 😄

rare lily
#

yeah - it's called "fields" in scripts, you need to click the dots in the top right corner to activate them

oblique bronze
#

Thanks a lot. Have to gain some confidence in this, as it is not as straight forward as I thought. I want to give a list of lights, but when I use that list as target I get errors.

But I'll search for some examples on the web. I can't be the only one 😄

rare lily
#

That's how it should work, wanna paste your code?

#

Click "view in YAML" and then you should be able to copy into here - paste between 2 sets of ``` to make it look like code rather than bullet points because that gets unbearable very fast

oblique bronze
#

I think this should be enough to showcase my issue:

common_light_scene:
  sequence:
    - if:
        - alias: Hvis lyset er slukket
          condition: not
          conditions:
            - alias: Kontrollér om lyset er tændt
              condition: state
              state: "on"
              entity_id: {{ lights }}
      then:
        - choose:
            - conditions:
                - condition: time
                  after: 07:00:00
                  before: "20:00:00"
              sequence:
                - action: light.turn_on
                  metadata: {}
                  data:
                    kelvin: 3000
                    brightness_pct: 90
                  target:
                    entity_id: {{ lights }}
        ...
        ...

  fields:
    lights:
      selector:
        entity:
          multiple: true
      required: true
      name: Lights
      description: The lights you want to control with the script.
#

I get the Incorrect type error wherever I put {{ lights }}

rare lily
#

Ah yeah - issue with single line templates - you need to put " around them

#

"{{lights}}"

oblique bronze
#

Feeling stupid, but it’s also late 😄 It seems to not work for the very first condition (checks whether the light is off or not). If I hardcode my light entity there, it works, if I use the field value it doesn’t really do anything

rare lily
#

Yeah you have to use a template condition there

#

Awkward if lights can be a list though

oblique bronze
#

Thank you very much for your help so far! Will look into the template condition tomorrow 🙂

Hm… if it’s not a group?

#

Let’s say I have 3 groups of lights in my kitchen (since I have), and I want to control two of them instead of the entire room

rare lily
#

It's doable. I just can't remember how and it's too late to think hard. If you get stuck tomorrow shout and I'll try to help