Simple toogle switch for presence

(I’m 5 hour+ looking for a solution, look at a lot of webpage, including the HA input boolean page, But, their examples aren’t fully explain the content. Why their isn’t a simple solution like “if entity is on then, else”)

Hi,
I want to create a simple on/off button (and/or if possible simply passing a tag) as a detection presence switch.

My script IN + OUT work but I would like to get only a simple switch on two state.
The same could apply for my heating (off = night, on = day).

Thank you

1 Like

Just create an input Boolean for each person, and then use whatever detection rules you want to set that input Boolean as on.

I do this because I use homekit for presence detection (that her than exposing ha to the internet and using that all or waiting for a device to hit the WiFi)

But as well as the homekit detection, the mobile app and WiFi detection can also be used. So there can be up to 3 factors to set the presence for a person.

This isn’t really an answer…
I have a Toggle switch made by the helper but it doing nothing.

I need the structure of the code and some explanation.

I just want something like :

Switch ON :
light on, Climate on, notification Off

Switch state is off :
Light off, climate off, notification On

I can’t find a solution without a trigger, I can’t find the way to just say “state off - entity presence”
Why there isn’t a “Choose” directly
or a if boolen switch state is Off
8h+ now

And I realise how many simple on/off I wan’t, and the only way I can find is using two script which take place.

1 Like

I am doing something similar to determine if my Jeep is in the garage. There is an ESP8266-01 in the jeep that wakes every two minutes, and if it’s in the garage, it will connect to the WiFi. I detect that state in an automation and set a helper entity to true.

I use the toggle type which is input_boolean.entity_name

You can use an entity card on the front-end or a service call to set the value: Input boolean: Turn off (or on).

Hi
please be more specific, add picture, code, ect
Explain like i’m five …


firefox_hjsYmHSmry

I want the change of stade of the switch as the trigger

Read automation and state triggers.

As far as I can tell you want to do stuff when your presence Boolean is on. And other things when off

So it’s the trigger of an automation. If not then I really don’t understand what you are trying to do.

That’s because there isn’t one. An automation or script needs something to start it. That would be a trigger.
The easiest that I can see from your description is to use the state of the switch as the trigger.

Even your physical wall switch does nothing - until you hit the switch (= trigger).

As the others told you before: You need HA and your input_boolean to tell when it shall toggle. You do this by using automations.

It would be helpful if you post your script code and describe how you detect presence (device tracker, occupancy rules, snsors etc.).

You just need two automations for the start of your journey.

  1. On: Your input boolean is the trigger for your “I’m home” automation and actions are light, heating and whatever. Of course you need a separate automations or scene that triggers the input boolean.

  2. Off: The off-state triggers all things to reverse and lights and stuff go off.

After that you can combine both automations with a template.

If you insist in using a manuel trigger (NFC or similar) you’re done. But why not use a device tracker (person) as the trigger?

Example for “on”:

alias: MembershipExcel is home
description: turns on light if MembershipExcel's input boolean is set to 'on'
mode: single
trigger:
  - platform: state
    entity_id: input_boolean.membershipexcel
    from: 'off'
    to: 'on'
condition: []
action:
  - service: light.toggle
    data: {}
    target:
      entity_id: light.somewhereinthe house