#C.A.F.E. So close. Yet....

1 messages Β· Page 1 of 1 (latest)

elfin sleet
#

May i pick you brains?

I came across C.A.F.E. and i like it. I think it will help with a more stable home, but I have been using node-red a lot and use a lot of custom functions using javascript.

Since CAFE does not suit this according to the docs, would it make sense to use both and migrate the automations that are fitting for CAFE to CAFE whilst keeping node-red for the more complex automations?

I see a few benefits, those are; less overhead, 'critical' automations running more natively not depending on another service, less socket traffic, keeping my preferred way of working in visual flows which makes it more easy to migrate exisiting flows too.

But since its still in beta, i wonder if i might be making a mistake thinking my more critical automations will be more stable.

Let me know your thoughts.

https://fezvrasta.github.io/cafe/#/

#

I see many of my questions answer themself if i just keep reading. Nevertheless, i would love to hear your experiences

winged bay
#

But I see a lot of potential

elfin sleet
#

Well, when reading more, i noticed its only writing the yaml for you, basically, so even if the integration fails, the normal automations are handled natively by home assistant after deployment.

#

which is awesome, im installing it now, ill convert some simple automations and see where it goes.

elfin sleet
#

Since im not familiar with how home assistant automations work, this might still be a challenge xD
How do i wait for all motion sensor to turn off before turning the lights off.
Im going to have to read up on native automations i guess.

Node red just has a single node that allow for either on and off action on the starter node, you can take action on either and i have yet to find a similar option in C.A.F.E.

#

Or should i create double state change nodes, one for on, one for off.

white dust
#

Maybe provide a link?

elfin sleet
frosty siren
elfin sleet
# frosty siren triggers: - every motion sensor going to off Conditions: - all motions sensors a...

Yeah i get that, thats just basic if-then-else. But the way to approach lights or areas registering people and making sure the light wont turn off before they left is quite different i suppose.

I think the biggest difference is in the fact you trigger on specific payloads directly, so you define multiple triggers instead of getting a single trigger for * state and deciding later what to do with it.

#

which makes sense, its just different from the 8 years ive been doing things in node-red

#

@frosty siren How would you go about making an automation that turns on a light when any of a set/group of binary sensor hits. Then wait for them ALL to be off for 15 seconds before turning the lights back off?

Especially the 'then' part is something im not sure about.

white dust
#

make a group of your binary_sensor entities

#

then it's easy

#

two triggers, one that triggers when the group turns on, and one that triggers when the group turns off for 15s

elfin sleet
#

Yeah when i typed group it dawned on me. I just never needed them because node-red is more quickly to select many and then re-use them within the same flow

frosty siren
#

Yeah, first I wanted to say:

description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.occupancy_1
    from:
      - "off"
      - "on"
    id: motion
  - trigger: state
    entity_id:
      - binary_sensor.occupancy_2
    from:
      - "off"
      - "on"
    id: motion
  - trigger: state
    entity_id:
      - binary_sensor.occupancy_1
    from:
      - "on"
      - "off"
    id: no motion
    for:
      hours: 0
      minutes: 0
      seconds: 15
  - trigger: state
    entity_id:
      - binary_sensor.occupancy_2
    from:
      - "on"
      - "off"
    id: no motion
    for:
      hours: 0
      minutes: 0
      seconds: 15
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - motion
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.foobar
            data: {}
      - conditions:
          - condition: trigger
            id:
              - no motion
          - condition: state
            entity_id: binary_sensor.occupancy_1
            state:
              - "off"
          - condition: state
            entity_id: binary_sensor.occupancy_2
            state:
              - "off"
        sequence:
          - action: light.turn_off
            metadata: {}
            target:
              entity_id: light.foobar
            data: {}
elfin sleet
#

Does home assistant have states for, for example, room activity?

frosty siren
#

But group is even easier πŸ˜„

white dust
elfin sleet
frosty siren
#

no, as the group will stay on while any of the members is still on πŸ˜„

elfin sleet
#

Sorry, wrong reply

frosty siren
#

or did you mean the automation?

elfin sleet
#

i was trying to reply to your automation

frosty siren
#

haha, then no, because in the condition you check that every sensor is off. If not, it will not do anything

elfin sleet
#

Ah alright, so its including all conditions ok

frosty siren
#

Conditions are AND by default πŸ™‚

elfin sleet
#

Ok, that might make more sense when working on it now

#

So it makes sense to make an automation for either state, occupation an no-occupation seperately

#

Instead of making it wait-for

#

because thats kinda how i made my flows now, but it somehow makes less sense in this context

white dust
frosty siren
#

Waiting is indeed best done outside the automation. But if you make 2 or 1 combined is a matter of preference (mostly). Combining is a bit more complex at fist but if things are linked I prefer a single automation.

elfin sleet
#

YEah so that would be for the 'no-occupation' state, then make a separate one for the occupied state

#

E.a. now i have this. I would be split into 2

frosty siren
#

I did a combined an made a "hard split" with a choose depending on what the trigger was (motion or no-motion)

elfin sleet
#

Yeah i think that's what CAFE will create too. because this is a single automation, that allows for multiple triggers

#

Ill create it and share the yaml so you can see πŸ™‚

frosty siren
elfin sleet
#

Does home assistant automatically dynamically create a sensor for the occupation of a room when you assign the area to the devices?

#

Or do i need to create each group myself manually.

elfin sleet
frosty siren
#

Then you just have something like:

description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.occupancy_group
    from:
      - "off"
      - "on"
    id: Turn on
  - trigger: state
    entity_id:
      - binary_sensor.occupancy_group
    from:
      - "on"
      - "off"
    id: Turn off
    for:
      hours: 0
      minutes: 0
      seconds: 15
  - trigger: state
    entity_id:
      - binary_sensor.badkamerdeur
    to:
      - "on"
    from:
      - "off"
    id: Turn on
  - trigger: state
    entity_id:
      - binary_sensor.woonkamerdeur
    to:
      - "on"
    from:
      - "off"
    id: Turn on
  - trigger: state
    entity_id:
      - binary_sensor.voordeur
    to:
      - "on"
    from:
      - "off"
    id: Turn on
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Turn on
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.foobar
            data: {}
      - conditions:
          - condition: trigger
            id:
              - Turn off
        sequence:
          - action: light.turn_off
            metadata: {}
            target:
              entity_id: light.foobar
            data: {}
elfin sleet
#

Yeah exactly

frosty siren
#

Adding the doors to a group makes less sense. As you probably want to turn on the lights if the voordeur opens even if the badkamerdeur was left open. So you're really interested in every state change

elfin sleet
#

Yeah exactly, ill work that out, thats similar to how i work in node red now

#

But does HA create dynamic groups for entities like motion sensors that you assigned to a room?

#

That would be great

#

motion.roomname

#

or idk, something useful

frosty siren
#

(one thing no left out is that a door opens but no motion was detected. That will turn the light on but never turn it off. Can be added πŸ˜„

#

No, that you'll have to do yourself.

elfin sleet
#

Yeah, my automations now account for very specific things too, if you only open a door, it will light for 15s. If you trigger a motion sensor it will be 1m 15s

elfin sleet
#

I guess ill end up using node-red to dynamically assign room states based on room sensors and use those for my automations πŸ˜‚

frosty siren
#

To turn off the light again when there is no motion within 15 sec after opening a door:

description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.occupancy_group
    from:
      - "off"
      - "on"
    id: Turn on
  - trigger: state
    entity_id:
      - binary_sensor.occupancy_group
    from:
      - "on"
      - "off"
    id: Turn off
    for:
      hours: 0
      minutes: 0
      seconds: 15
  - trigger: state
    entity_id:
      - binary_sensor.badkamerdeur
      - binary_sensor.woonkamerdeur
      - binary_sensor.voordeur
    to:
      - "on"
    from:
      - "off"
    id: Turn on
  - trigger: state
    entity_id:
      - binary_sensor.badkamerdeur
      - binary_sensor.woonkamerdeur
      - binary_sensor.voordeur
    to:
      - "on"
    from:
      - "off"
    id: Check motion
    for:
      hours: 0
      minutes: 0
      seconds: 15
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - motion
        sequence:
          - action: light.turn_on
            metadata: {}
            target:
              entity_id: light.foobar
            data: {}
      - conditions:
          - condition: trigger
            id:
              - no motion
        sequence:
          - action: light.turn_off
            metadata: {}
            target:
              entity_id: light.foobar
            data: {}
      - conditions:
          - condition: trigger
            id:
              - Check motion
          - condition: state
            entity_id: binary_sensor.occupancy_group
            state:
              - "off"
        sequence:
          - action: light.turn_off
            metadata: {}
            target:
              entity_id: light.foobar
            data: {}
frosty siren
elfin sleet
#

Can it do that dynamically using a helper?

frosty siren
#

Why do you need it to be dynamic?

elfin sleet
#

I used home-assistant mainly as a mainframe all my automations and templating is done in node-red lol.

#

Why not, when i replace a device, all i have to do is assign it a room and it will run within my automations

#

without having to go and change the helper

frosty siren
#

That's why I would just name the device the same and all keeps on working πŸ˜„

elfin sleet
#

YEah but what if you just add a device, or exchange it with another model and test-run it next to the old etc

frosty siren
#

(could be done dynamic with a template helper if you would really like)

elfin sleet
#

Sounds interesting, can you use jinja in helpers?

frosty siren
#

A template sensor is a helper that uses jinja, so yes

elfin sleet
#

I am in control, i can see what devices are assigned to a room, its just automated

#

neat

frosty siren
#

let me think of a template

#
{% set area = 'Hall' %}
{% set entities = area_entities(area) |select('match', '^binary.sensor\.') |list |default([]) %}
{% set detected = states
   | selectattr('entity_id', 'in', entities)
   | selectattr('attributes.device_class', 'eq', 'occupancy')
   | selectattr('state', 'eq', 'on')
   | list
   | count > 0
%}
{{ detected }}

Would be true if any motion device in an area is detecting motion

elfin sleet
frosty siren
#

So if you add that to a template binary_sensor and also give it the device class of occupancy it would do the job. Only DON'T add the template sensor to the area as that would create a feedback loop πŸ˜„

elfin sleet
#

Hehe yeah

elfin sleet
# frosty siren So if you add that to a template binary_sensor and also give it the device class...

Hey, wanna help me out some more?

I now want to integrate the dimmer override i have in node-red.

When someone adjusts the light, the automation will be halted for as long as there are people, when nobody is there anymore, it should wait 15 minutes before returning to the automated state.

When entering a sequence, now push and rotate, it will reset to the automation state instantly and give a short visual cue.

#

How would i approach this best?

sick gazelle
#

Hi, I am new to Home Assistant and coding. What flow chart software are you using? It appears to easy to visulize the steps necessary. Thanks for assist.

pallid flume
split atlas
#

How are you getting the "background" to help lay it out?

frosty siren
#

I'm not great at reading NR. Do you trigger on change of brightness?

elfin sleet
elfin sleet
elfin sleet
# frosty siren I'm not great at reading NR. Do you trigger on change of brightness?

The triggers are simply a collection of binary sensors (motion / contact).

The flow might be hard to follow, i tried to make it better by grouping items hehe.

The first part is just the motion sensor part. Just before the ligt turn on at the end, there is an intercept node that will only allow messages trough if a certain condition is met, in this case that condition is set by the dimmer part below.

The second part is the dimmer control, it will do normal lighting actions, but also send a trigger message to the other flow to stop the automation until there is no more motion detected for 15minutes.

I found this to be great to be able to control the light but resume the automation when manual control is no longer needed.

#

Whilst typing this i thought it might be possible to disable the entire lighting automation with an action.
That would make a similar setup possible at least.

frosty siren
#

Yeah, was mainly looking at what you now see as a "manual change".

I always advise against automating the disable/enable of an automation. I would always advise to just make a toggle helper (input_boolean) and add that as condition to the automation. That way you always have a ultimate manual override to disable the automation when needed.

So yeah, you could make an automation to detect brightness change and set the helper. Could also all be integrated into a single automation if you want