Need help to translate in yaml

this is how it looks, but in the info there is that number.
I named all scripts with the Alias to the human Text, don’t know why some scripts have such numbers!

where can i rename them?

Go to Developer Tools > States, enter script in the “Filter entities” field. The underlines names it shows represent the entity_id of each script.

Screenshot from 2021-11-28 11-37-17

Notice that the first script’s entity_id is script.1627221957315 but its name is “toggle_two_switches”. If I look in Configuration > Scripts, it appears as “toggle_two_switches”.

Screenshot from 2021-11-28 11-41-57

i renamed the scriptes in the script.yaml (before your post) , now they are with the right names.

the automation look like this but doesn’ work:

alias: Partyraum Licht an aus
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.partyraum_lichtschalter
    from: 'off,on'
    to: 'on,off'
condition: []
action:
  - service: >-
      {{ 'script.partyraumbeleuchtung_default' if trigger.to_state.state == 'on'
      else 'script.partyraumbeleuchtung_standby'}}
    data: {}
mode: single

when i start the script manually they work.
I also restarted HA.

That’s good news.

The from and to have incorrect values:

They should be lists:

    from: ['off', 'on']
    to: ['on', 'off']

However, that not your fault. If you are using the Script Editor, it automatically changes a list to a string of comma-separated items. It’s a bug.

Try this format and see if the Script Editor leaves it undisturbed or converts it improperly:

    from:
      - 'off'
      - 'on'
    to:
      - 'on'
      - 'off'

the editor makes it like this:

    from:
      - 'off'
      - 'on'
    to: 'on,off'

but it works

Glad to hear it.

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.

thank you very much!

At the side of the Lightswitch there is a little switch for turning on all lamps to 100% (9x 7W LED)
the automation for this mode is easy and works.

But how can i start a timer of 15min. when the entity partyraum_pir toggles from off to on?
With this i want to turn on 2 Lamps (call a script) only if the Lightswitch is off.

This should help you get started. It starts a 15-minute timer when the binary_sensor changes state from off to on.

alias: example 1
trigger:
  - platform: state
    entity_id: binary_sensor.partyraum_pir
    from: 'off'
    to: 'on'
action:
  - service: timer.start
    target:
      entity_id: timer.your_timer
    data:
      duration: '00:15:00'

What do you want to happen when the timer finishes counting down 15 minutes? Call a script?

yes, after 15min script.partyraumbeleuchtung_standby should be called.
purpuse is to act like a motion detector if someone goes into the room.

entity_id: timer.your_timer

do i have to define this before? can i use other name like partyraum_timer?

alias: Partyraum_timer
trigger:
  - platform: state
    entity_id: binary_sensor.partyraum_pir
    from: 'off'
    to: 'on'
action:
  - service: timer.start
    target:
      entity_id: timer.partyraum_timer
    data:
      duration: '00:00:15'   

i get an error message: Message malformed: extra keys not allowed @ data[‘trigger’]

I have tried to make a new script. or does it have to go into configuration.yaml?

The example I posted is an automation, not a script.

If you attempt to put the automation’s code into a script, you will get the error message:

extra keys not allowed @ data[‘trigger’]

because trigger is not a valid option for a script.

ok, as an automation i get following error message:
There was an error converting to YAML: YAMLException: unacceptable kind of an object to dump [object Undefined]

Obviously you made a mistake with wherever you put the automation. However, I can’t guess what you did based on that error message.

well, that error accurs when i trie to use the yaml editor.
If i write it with notepad into automation.yaml and reload it, it is ok.

But: the state is alwas on! I can see in the log that it have been often triggered, but it never turnt to off state!
for testing i set the time to 15sec.

The state of what is on?

You do realize that the example I posted for you simply starts a timer, right? That’s all it does and nothing more.

You have to add an automation that does something (like calls a script to turn off the two lights) when the timer finishes.

alias: 'example 2'
trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.partyraum_timer
action:
  - service: script.your_script

Hi, i got it running (and learning thanx to your help!):

In configuration.yaml:

timer:
  partyraum_timer:
    duration: '00:00:15'    

In Automation.yaml:

- id: '1638036241709'
  alias: Partyraum Licht voll
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.partyraum_lichtschalter_full
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: script.partyraumbeleuchtung_voll
    data: {}
  mode: single
- id: '1638036310682'
  alias: Partyraum Licht voll aus
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.partyraum_lichtschalter_full
    from: 'on'
    to: 'off'
  condition: []
  action:
  - service: script.partyraumbeleuchtung_default
    data: {}
  mode: single
  alias: Partyraum Licht an aus
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.partyraum_lichtschalter
    from:
    - 'off'
    - 'on'
    to:
    - 'on'
    - 'off'
  condition: []
  action:
  - service: '{{ ''script.partyraumbeleuchtung_default'' if trigger.to_state.state
      == ''on'' else ''script.partyraumbeleuchtung_standby''}}'
    data: {}
  mode: single
  alias: Partyraum_timer
  trigger:
  - platform: state
    entity_id: binary_sensor.partyraum_pir
    from: 'off'
    to: 'on'
  action:
  - service: timer.start
    target:
      entity_id: timer.partyraum_timer
    data:
      duration: 00:00:30
  alias: Partyraum_Timer_End
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.partyraum_timer
  action:
  - service: script.partyraumbeleuchtung_standby
  alias: Partyraum_Timer_Start
  trigger:
  - platform: event
    event_type: timer.started
    event_data:
      entity_id: timer.partyraum_timer
  action:
  - service: script.partyraumbeleuchtung_motion

One thing about this motion detection must be combined with the Licht an aus:
The (alias) Partyraum_timer must be only allowed if the binary_sensor.partyraum_lichtschalter is off!
EDIT: I could manage to get also this to work:

- id: '1638123705921'
  alias: Partyraum_timer
  trigger:
  - platform: state
    entity_id: binary_sensor.partyraum_pir
    from: 'off'
    to: 'on'
  condition:
  - condition: state
    entity_id: binary_sensor.partyraum_lichtschalter
    state: 'off'
  action:
  - service: timer.start
    target:
      entity_id: timer.partyraum_timer
    data:
      duration: 00:05:00
  mode: single

i am wondering why can i not define brightness values in % in the sript?

sequence:
  - service: light.turn_on
    target:
      entity_id: light.partyraum_lampe1
    data:
      brightness: 30

i can only use values from 0 to 255 but not von 0% to 100%. it gives me an error if i replace values with %!

Now only the very last step is to do:
If person Wolfram and person Sabine are away, turn off the light completely(call a script.partyraumbeleuchtung_aus).

Use the brightness_pct option.

sequence:
  - service: light.turn_on
    target:
      entity_id: light.partyraum_lampe1
    data:
      brightness_pct: 30

For more information, refer to the documentation for service light.turn_on.

ahh, ok, thanks!

I am trieng to get this with the home/away get working, but the away_timer don’t start:

in configuration.yaml i have:

timer:
  partyraum_timer:
    duration: '00:00:15'    
  partyraum_away_timer:
    duration: '00:00:15'    

in auomation i have:

- id: '1638192620614'
  alias: Partyraum_away_timer
  description: ''
  trigger:
  - platform: state
    entity_id: device_tracker.wolfram_handy
    to: 'off'
  condition:
  - condition: state
    entity_id: binary_sensor.partyraum_lichtschalter
    state: 'off'
  action:
  - service: timer.start
    target:
      entity_id: timer.partyraum_away_timer
    data:
      duration: 00:01:00
  mode: single
  alias: Partyraum_Away_Timer_End
  description: ''
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.partyraum_away_timer
  condition: []
  action:
  - service: script.partyraumbeleuchtung_aus
  mode: single

is the systax correct for this:

    entity_id: device_tracker.wolfram_handy
    to: 'off'

Change this:

  - platform: state
    entity_id: device_tracker.wolfram_handy
    to: 'off'

to this:

  - platform: state
    entity_id: device_tracker.wolfram_handy
    to: 'not_home'

For more information, refer to Device Tracker States

thanx, that works.
Can i also use 2 entity_id’s? like this:

- platform: state
    entity_id: device_tracker.wolfram_handy
    to: 'not_home'
    entity_id: device_tracker.sabine_handy
    to: 'not_home'

goal is to start the timer when none of both are at home