Struggling with a variety of topics

erm…where exactly are you copy/pasting from/into??

i hope the 3 little dots in the upper right corner of the automation editor —> goto yaml mode
and not in automations.yaml??

(just asking as i see in your pasted code every time:

and that piece of code does not belong here🤔)

I get errors if I try to remove the code you mention! I also no clue of any 3 little dots in the upper right corner of the automation editor, there is nothing like that on my screen. I’m I using a different setup here?

error

If I was to copy and past from from your code to Studio Code Serer it first use Notepad and then in to the the automations.yaml in Studio Code

I’ve also just tried using Notepad++ to copy your code and getting this error though it seemed to go into the Automations.yaml file better and had fewer errors so might be a mistake on my behalf in the code!

  alias: Turn on Desk Lamp
  description: ''
  trigger:
  - platform: state
    entity_id:
    - binary_sensor.lumi_lumi_motion_ac02_motion
    to: 'on'
    - platform: state
    id: "off"
    entity_id:
      - binary_sensor.lumi_lumi_motion_ac02_motion
    to: "off"
    for:
      hours: 0
      minutes: 3
      seconds: 0
  condition:
  - condition: time
    after: 09:00:00
    before: '20:00:00'
  action:
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.desk_lamp_bulb
  mode: single
- id: '1693220799421'
  alias: Turn off Desk Lamp
  description: ''
  trigger: []
  condition: []
  action: []
  mode: single

Its triggered now but still no light coming on though. I know you mention there was code at the bottom to remove but I get errors doing that and you are using kitchen lights instead of Desk Lamp which is also a switch to turn a bulb on but I keep the switch turn on all of the time for that to work.

I also seem to now keep losing connections to Home Assistant why I do not like copying code as it always seems to mess me up.

Your screenshot shows the automation has only one trigger.

The YAML code for the same automation shows two triggers … but the first one is not indented correctly.

Is the indentation mistake actually in your YAML code or is that just a copying error when you pasted it into the forum post? If the mistake is real then it may explain why the screenshot shows only one trigger.

Then I guess this would make your life a lot easier…
It allows you to switch between the visual editor and yaml.

visual editor:


(please ignore the 'undefined reading, as it is because I used your entities, which do not exists in my setup)

yaml mode:

No need to edit any file, no need to restart either… :thinking:

And yes…you have the 3 dots, they show in your screenshot earlier:

1 Like

So what you do:

  1. Copy the automation I posted:
alias: Turn on/off Desk Lamp on motion between 09:00 and 18:00 and off after 3min without motion
description: ""
mode: restart
trigger:
  - platform: state
    id: "on"
    entity_id:
      - binary_sensor.lumi_lumi_motion_ac02_motion
    to: "on"
  - platform: state
    id: "off"
    entity_id:
      - binary_sensor.lumi_lumi_motion_ac02_motion
    to: "off"
    for:
      hours: 0
      minutes: 3
      seconds: 0
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - "on"
          - condition: time
            after: "09:00:00"
            before: "18:00:00"
        sequence:
          - service: light.turn_on
            data:
              brightness_pct: 60
            target:
              entity_id: light.kithcen_led_2
    default:
      - service: light.turn_off
        data: {}
        target:
          entity_id: llight.kithcen_led_2
  1. open the automation page
  2. click ‘create automation’
  3. click the 3 dots, select ‘Edit in YAML’
  4. select all text and delete it
  5. paste the automation you copied earlier in item 1
  6. click the 3 dots, select ‘Edit in visual editor’ to switch back to visual mode

You are not supposed to edit automation.yaml by hand…use the automation editor instead.

And no personal offence, but you are not listening to us; if you want us to help you, you need to.
Otherwise it is pointless to give you suggestion, and it just becomes a waste of time…

Applogise if this sound like a rand… but we are now 28 post futher and we accomplised not much :face_with_raised_eyebrow:

2 Likes

Images would help me more than text as I find it hard to fully understand where or what you mean when I see nothing to what you say on my screen! I understand what you are meaning and trying to do but my options do not come up like yours do and I must have a different way Im unsure of as I know nothing in HA

Its frustrates me when this happens and also when files vanish and then come back on 30 mins later or errors don’t show up until 10 mins later

I manually did your code in a text editor to make sure I was getting it right, but in this process there is more chances it will be wrong with trying to do it this way and yes your way would be better if I know how too. if I see image of what you are explaining I would then know where to go or what to look for properly instead of me guessing and making things worse or in most cases better :slight_smile: It cant really be much worse when not working.

Thanks!

Maybe 4 post would be better too for me, but maybe you get on my PC and you will see straight away it’s different than your setup! And does silly things! We can soon remove a lot of this post once we figure the issues but so far the issues are the same not working, but we do now after 28 post have light on but no light off :upside_down_face: :thinking:

My Applogise if this sounds like a rand back to you

But unless you explain properly I will never know! If I see a video I follow it to the book and most o the time it works but like all things what one person computer show is different on another!

what is an Automation Page?

This is an example your asking me to open an Automation Page so to me I have 3 places to look so which is it or where to go to?

1:

2:

3:

It’s also great you are helping me so don’t take this as Im having a go at you Im not!

I just cannot follow your instructions and yes its frustrating I know even more so for me as I have nothing working and spent time and money to do this to help rather than it being harder.

I have no choice on this as with my conditions I want things as easy as possible but also safe as possible which so far it pretty good 28 posts might be 30 now Im not counting! better than 50 years getting from a zx81 :thinking: :rofl: don’t think any of us want that again do we :slight_smile: what more I learn and understand helps others get setup too as I tend to help back too when I can! And I know its hard when you cannot see the other person’s screen! Sorry for being a pain on not getting this right but I will eventually! Thanks for your time and Patients with me too!

Your option 4: I have never seen any 2. click the 3 dots, select ‘yaml mode’ to open?

None of the above… :smiley:

Yes !! That is the one I ment :smiley:

And my mistake… it should have been ‘Edit in YAML’

Updated my post

1 Like

So where Im I pasting any code in this? There is no where to do this, all it does it take me to where I was before in Visual Studio code.

This Automation does not remove my last code either as Im in a New one made!

Its the code that’s wrong for not turn the light off after the given time that’s not working on this Automation so again I see nothing I was doing wrong before apart from the code being wrong :slight_smile:

Just use right mouse button:

Not wrong, but very hard…
With this you can switch back and forth between YAML and visual editor :wink:

But this video might help if it is right or now how I have done it

Big thank you too. Hope you like the video so you no need to keep repeating yourself to me now :upside_down_face: :thinking: :rofl: :rofl: :blue_heart: :blue_heart: :blue_heart:

How to edit YAML in Home Assistant to Turn on off Desk Lamp on motion sensor go off after 2min

And Documents to go with it! To Follow at:
How to edit YAML in Home Assistant to Turn on/off Desk Lamp on motion sensor go off after 2min of no motion

I think with this video your code and me making a few changes, the solution is solved! I will remove some of the posts I think now Is not really needed but it is to a learner like me! :slight_smile:

Thanks and I like your images too would of been great back at post-5 :rofl: :muscle:

Code Used and Fully Working Now: By Aceindy, & Dave at The Diabeticway

alias: >-
  Turn on/off Desk Lamp on motion between 09:00 and 18:00 and off after 3min
  without motion
description: ""
trigger:
  - platform: state
    id: "on"
    entity_id:
      - binary_sensor.lumi_lumi_motion_ac02_motion
    to: "on"
  - platform: state
    id: "off"
    entity_id:
      - binary_sensor.lumi_lumi_motion_ac02_motion
    to: "off"
    for:
      hours: 0
      minutes: 2
      seconds: 0
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - "on"
          - condition: time
            after: "09:00:00"
            before: "18:00:00"
        sequence:
          - service: light.turn_on
            data:
              brightness_pct: 60
            target:
              entity_id: light.desk_lamp_bulb
    default:
      - service: light.turn_off
        data: {}
        target:
          entity_id: light.desk_lamp_bulb
mode: restart

Seen as I have done this setup on a Desk Lamp can anyone recommend a good one to replace my 20-year-old one please, and to be Zigbee compatible? I do like my lamp but it’s falling to bits now! SO, would something similar be great as a link too? I’ve looked for a while now and never really seen one similar!

1 Like

Glad it works now, and glad to be off assistance :wink:

I just hope you know now there is a better way than you used to use.

And for the lamp; just get an Ikea-tradfri, they are good and cheap :wink:

Yes seems a better way and more control of it all too but takes a while to get used to doing it and without people like your self a lot harder to do thank you so much!

I be busy now doing the all home to this way :upside_down_face: :rofl: and then trying to get iPad display to come on as a sensor detects me so this will also help with that later question I will be asking!

I also did a small Word file to share which I will add to the tube video to make things easier for me as I was not thinking to do this video but its taken me months to use it in this way and I’m sure it will help many more people thanks to you!

I also updated the video and no IKea around me to pop into but I will take a look Thanks for that too.

How to edit YAML in Home Assistant to Turn on off Desk Lamp on motion sensor go off after 2min

And Documents to go with it! To Follow at:
How to edit YAML in Home Assistant to Turn on/off Desk Lamp on motion sensor go off after 2min of no motion

Let me know if you want permission to edit the Doc file but message me on that if you do!

I’ve also noticed I see no Conditions to change to Sun by not using the editor but its not showing up the one you made in the code why Is this and how do I correct it?

At a guess do I just change the code from Time to Sun or is there more to it?

It is realy there:


below state and above template
the sun icon :sunny:

Yes I know I saw it there but will it mess the other up that is already in the code? As they don’t seem to be syncing to each other from the editor? As you are showing there is how I did it before but we moved to do it code way did we not :slight_smile:

Just tried an got both now in the code so how do I stop it from using the time can I add symbols at from to stop it from reading that code?