On/off switch in Lovelace

I like to have an normal on/off switch in lovelace that make the light go on and when activated turn off again. But my automation turns it off again when there is no motion. How can I achieve that when pushed on in lovelace it stays on untill I pushed it off again. Some override the no motion automation .


alias: Detect no motion on patio turn off light
description: ‘’
trigger:

  • platform: state
    entity_id: binary_sensor.camera_patio_motion
    from: ‘on’
    to: ‘off’
    condition: []
    action:
  • type: turn_off
    device_id: eb57cda6b656e777857e9408197a3b2f
    entity_id: light.dimmable_light_28
    domain: light
    mode: single

Please:

  1. Properly format your code
  2. Show the full code of the automation
  3. Also show the code of the automation that turns the light on

Don’t know how to do that. If I need to study before I can ask a question. Pffff.
And this is the automation.

‘’’
alias: Detect motion on patio turn on light
description:
trigger:

  • platform: state
    entity_id: binary_sensor.camera_patio_motion
    from: off
    to: on
    condition: []
    action:
  • device_id: dbc313e75cc72b985ef376c2b2cf821e
    domain: mobile_app
    type: notify
    message: Motion detected on Patio
    data:
    push:
    sound: Notification_Haptic.caf
    title:
  • type: turn_on
    device_id: eb57cda6b656e777857e9408197a3b2f
    entity_id: light.dimmable_light_28
    domain: light
    brightness_pct: 50
    mode: single
    ‘’’

Hmmm, strange attitude

1 Like

“Properly format the code”: quite simple. Put reverse single quotes (the key next the 1) like this ``` before and after the code. Then it looks like this:

# zoom lighting on & off
- alias: 'zoom lighting on'
  trigger:
    platform: state
    entity_id: input_boolean.zoom_lighting
    to: 'on'
  action:
    - service: script.turn_on
      target:
        entity_id: script.zoom_lighting_on

Why do we request that you do that?

  1. It makes it easier for us to read and thus help you debug it.
  2. It means you can just copy and paste the code and it should be indented correctly
1 Like

Sorry to disturb you laziness.
See How to help us help you - or How to ask a good question - Configuration - Home Assistant Community (home-assistant.io) point 11.

And you still didn’t include the full automations.
Ah no, your automations are just unreadable because of not being formatted

How can you expect people to help you when you won’t help us? Entitled much?

Sorry but I tried it but if your not willing to help me unless I format thing properly. Well delete my post and I will learn your rules and ask again if I get the right way to ask. Something are easy for U guys… not for me. Strange attitude??? Well guess that’s me.

It’s not a matter of rules. It’s just that YAML code is unreadable if not formatted.

If you can’t learn the difference between a back tick ` and a quote ‘ then I’m not sure how you’ll get home assistant working. You’re really make a big deal out of nothing. Use 3 backticks before your code and after and it will be formatted.

This is a back tick `

1 Like

It’s not that we are not willing, it’s that we cant help you unless you format it.

Spacing is very important in YAML and without formatting your post properly we can’t see that.

1 Like

I’m not willing with that attitude.

That’s usually the first step.

as it seems you are all taking the time to tell me I’m not formatting the way you want me to do code. It’s a simple code, not very long. Perhaps someone is willing to help me instead of burning me to the ground, telling me about my attitude. I like to delete my question, please if not for the code tell me how to delete this. By the way I did try the ‘’’ it just did not work, perhaps some PC settings.

It doesn’t matter how simple it is. If it looks like this we can’t help you:

So read this, edit your post instead of complaining and then maybe someone will help you.

Spacing is critical in YAML, and if you just throw the code on the page then it’ll look ugly and nobody will know if the problem is because of spacing. We need you to use code blocks and appropriate markup.

For example, this is easy to read and it is obvious if the spacing is correct:

# Turn off lights when everybody leaves the house
  - alias: 'Rule 2 - Away Mode'
    trigger:
      platform: state
      entity_id: group.all_devices
      to: 'not_home'
    action:
      service: light.turn_off
      entity_id: group.all_lights

This however, not so much:

Turn off lights when everybody leaves the house

  • alias: ‘Rule 2 - Away Mode’
    trigger:
    platform: state
    entity_id: group.all_devices
    to: ‘not_home’
    action:
    service: light.turn_off
    entity_id: group.all_lights

Full details are in that link , but in brief you wrap your block in three backticks (```)

And in case it’s not obvious, you can edit your posts by clicking on the “pencil” button.

Edit, enclose you code between 3 back ticks, done.

I like to have an normal on/off switch in lovelace that make the light go on and when activated turn off again. But my automation turns it off again when there is no motion. How can I achieve that when pushed on in lovelace it stays on untill I pushed it off again. Some override the no motion automation .

below my automation detect motion turn on light and when no motion trun off light. Hope I did it right.

By the way I now used </> in the edit from edge, when I do the suggested ‘’’ the formatting does not work. Perhaps something to be aware of before burning people who do not program for a living or don’t do this very often. Just saying we are not all the best. Sorry if it seems an attitude, but I did try to do it the way suggested, it just did not work,

alias: Detect motion on patio turn on light
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.camera_patio_motion
    from: 'off'
    to: 'on'
condition: []
action:
  - device_id: dbc313e75cc72b985ef376c2b2cf821e
    domain: mobile_app
    type: notify
    message: Motion detected on Patio
    data:
      push:
        sound: Notification_Haptic.caf
    title: ''
  - type: turn_on
    device_id: eb57cda6b656e777857e9408197a3b2f
    entity_id: light.dimmable_light_28
    domain: light
    brightness_pct: 50
mode: single

And the automation section to turn the light off again

alias: Detect no motion on patio turn off light
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.camera_patio_motion
    from: 'on'
    to: 'off'
condition: []
action:
  - type: turn_off
    device_id: eb57cda6b656e777857e9408197a3b2f
    entity_id: light.dimmable_light_28
    domain: light
mode: single

You were using quotes not backticks. It’s a different symbol. On a US-English keyboard it is between the [Tab] and [Esc] keys.

This question has been asked many times and there a a lot of search results with different solutions you should read. https://community.home-assistant.io/search?q=motion%20light%20manual%20

Well that’s just the thing. Before I can get to my problem I’m way of to read and read and read how to ask a question. But after all this still no solution to my original problem. For you as an moderator it is an easy thing, but as I already told I’m not doing this on a daily basis. I’m not a programmer and have no intention to become one. I just want to have some automation in my home without the Chinese to see if I turn on a light. The reason I come to this forum to get some help achieving this. I hope you get my point of view,

There are at least half a dozen solutions to your problem in that search link I posted.

No hard feelings or anything, but the point of this forum is not to create your HA config on your behalf.
You are supposed to read and study and learn how HA is working so that you can tailor it to your requirements.

If you’re not ready to read the abundant documentation and search the forum for similar questions and answers, HA will stay obscure to you and you will have a really hard time getting somewhere.

Sorry to tell you, but automations are basically programs…
If you hate it, maybe check Node Red, it’s a more graphical way to build tour automations (but still, you will have a lot to learn).