On/off switch in Lovelace

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).

Dear Chris,

Thank you for all your support on how I should do things. But the fact is that your not very helpful in getting my problem solved. This discussion has taken a lot of time and I have other things to do that study home assistant. I will sort out my problem by reading in this forum. I thought to ask you tech guys since I thought it would not be a hard thing for guys in this forum to get me a quick answer, but I was wrong in stead of this you are lecturing me to go and learn Home Assistant programming. I thought the idea for this forum was to help people sort things out. I was wrong.

In the mean time I made a input boolean and going to figure it out by myself on how I can get this boolean to turn on the light and turn off the automation to turn off the light when no detection takes place. When switch off the boolean, turn of the light and turn on the automation again. .

Please read the introduction and point (1) here.

This forum is not a helpdesk

The people here don’t work for Home Assistant, that’s an open source project. We are volunteering our free time to help others. Not all topics may get an answer, never mind one that helps you solve your problem.

:one: Search

It’s not unlikely that your question has been asked, and answered, already. If you search the forum, you may find it and save yourself a lot of time.

Now, it may not be a perfect answer to your question, but it should get you close enough to start.

In fact, please read the whole thing and this too.

Sorry to have bothered you. I’ll make sure it won’t happen again.

4 Likes

Nice discussion! Love it

@snhnic I spent maybe hundreds hours by reading the docs and all the guys above answering you helped me tremendously. Try to be nice. It’s hard to understand HA but when you change the dark rabbit hole into enlihten one, you will realize what jewel you just found and what amazing work they done. You are not expected to be programming anything. Wishing you great journey!

1 Like

The reaction of Vahaldor is a far better approach than the other reactions. :slight_smile:

In my defense. It did read a lot about Home Assistant. It’s not a very friendly solution for home automation as far as I can see. I did spent a lot of time reading about it. I manage to get a lot of stuff working on my server, again I’m not a programmer, but proud to get the things done the way I like. I’m willing to learn as you all can see (I did get the code in like you asked), but really think the tone could be nicer, mine perhaps aswell. I don’t have an attitude @ all, I just like to say what I think.

The funny thing is that I sorted my problem and now have things working the way I want to.

Sorry to say that I now have a lot of coding for what I still believe could have been done with a script, it was nice when someone took the time to read the code (not formatted the right way, but seamless easy for you to put in the right formatting, what I could not - only way seems to click on </> -) instead of lecturing me.

Now I have ended up with 4 automatons and one input boolean, that I use to get the light on and off manually.

So okay it’s not a helpdesk. I don’t think I get your definition of a helpdesk. Okay in my question your right, since there is no help. Happy enough there are lot’s of others that have asked questions in this forum (with the right formatting :slight_smile: ) so I was able to get answers. So many thanks to all the other help seekers that got the answers.

Well let’s leave it with this and have a happy day. Again no hard feelings, but let us look in the mirror before judging. It;s all in the eye of the beholder.

Sorry to open an old thread but I have a similar situation and wanted to share some insight.

I had some success using “set_state” instead of “service.lights.turn_x”. This seems to modify reported state without it firing a changed state event. This was using appdeamon so your experience might vary.

On a similar and maybe relevant topic:
I have a similar system that has lights, movement sensors and a manual override.
The manual override is momentary with two buttons, on and off.
When there are two buttons it is very clear what you want the system to do.

My existing lovelace interface uses a pushbutton. The problem with a single pushbutton is that it does not know your real intention. All it can do is invert the existing state. This is kind of the reason I am looking through this thread.

Just found this momentary switch in HACS which might help out:
hass-momentary github

/Matt

Will have a look at this. Thnks