Switch bad functions

hello team,

please,
i have configured this simple swith on /off for manualy usage.
to put on when i’m away, and off when i’m inside house.
i dont understand why, when in put it : on, after 10 seconds in came back automaticaly off…

switch:
    - platform: template
    switches:
      maison_on_off:
        friendly_name: "maison_on_off"
        value_template: "{{ is_state_attr('switch.maison_on_off', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.maison_on_off
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.maison_on_off

thanks for help
Bruno

First of all; please format your code. (Look at the top of the page)
Second; I think you’ll need a input boolean.

thanks a lot,
thats the simplest solution

its ok with input_boolean

and i have modified the post, to put code correctly. sorry

configuration.yaml:

input_boolean:
  notify_home:
    name: maison
    initial: off
    icon: mdi:home-assistant

and for automation.yaml:

  condition:
  - condition: state
    entity_id: input_boolean.notify_maison
    state: 'on'
  action:

Any reason to not use the switch.toggle service for this?

@anon34565116 Are you talking about the first post?
That template switch will never work, because it is calling itself. So switch.toggle wouldn’t work either…

OK. The whole logic looked like a lot of work trying to duplicate an existing service