Create custom entity with toggle switch

I would like to create a toggle switch on a dashboard to set an entity (vacation) on or off.
I want to use that custom entity in a condition for automations.
I’m a bit lost what to create for this.

I would agree with burning here, a boolean will fit the bill nicely.
I don’t think you want a ‘toggle’ as a toggle always returns to off, so how would you tell if vacation mode was activated or not ? (you’d need a separate sensor to display it)

Edit: AND a separate entity to store the state, all done efficiently with the input boolean

I have created the input boolean, placed it on a lovelace card.
I can turn it on or off.
But i’m trying to use it in a automation and it is not working.

Input boolean config

input_boolean:
  vacation_mode_jeroen:
    name: Vacation
    icon: mdi:beach

automation config

  condition:
    condition: and
    conditions:
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: state
        entity_id: input_boolean.vacation_mode_jeroen
        state: 'off'

I read this as …
You have a trigger - which I presume you are happy with and works
You have an action - which I presume you are happy with and works
And you have now inserted a condition which requires it to be a weekday and for the input boolean to be off

Why is it called vacation mode and yet requires to be off to enable something to work ?
(could be correct, I’m just checking your assumtions)

1 Like

Your assumptions are correct. The trigger, action and weekday condition was working correctly.
Now i’m in vacation and i don’t want the action triggered.
So only if vacation mode is off, and it’s a weekday, then I want to set on heating and lights in my office.
I set the vacation mode on in a lovelace card.
But it still triggers the action.

In which case, what you have looks good

I’m an old scholl yaml guy so I’d write it a bit differently (but yours looks compliant) : -

automation:
  - alias: au_light_patio_door_opens
    mode: single
    max_exceeded: silent
    trigger:
      - platform: state
        entity_id: binary_sensor.neo_drwinsen_ptiodr_sensor
        from: 'off'
        to: 'on'
    condition:
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: state
        entity_id: input_boolean.vacation_mode_jeroen
        state: 'off'
    action:
      - service: light.turn_on
        entity_id: light.fibdim2_ptio_level

for example.
Have you reloaded your automations ?
Have you actually triggered your trigger ? (just manually running the automation bypasses the triggers AND the conditions)
What doesn’t work ?

Oh, I just manually ran the automation, i tought it used triggers and conditions.
That will be the cause then.

What does ? (how are you triggering this ?)

Edit cross post

Is there a possibility to try an automation with conditions?

Create another input boolean
(I always have a couple hanging around)
Insert one of them into the trigger section so it will trigger on this or that
Reload
Test
Success – > remove the extra trigger
Failure --> dubug and try again