Switch turns instantly off

Hallo,

i want to do the following:

if my RTV is off, i press my switch and it turns on.
iif its on and i press my switch, it turns off.

The problem is, that if its off and i press the switch, it turns on and then off.

How do i fix this?

YAML for turn on:
alias: HZ WZ an Tag 20°C
description: “”
trigger:

  • device_id: d49f7bfad074352924a1e21eddeeecf2
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: remote_button_short_press
    condition:
  • condition: state
    entity_id: climate.lumi_lumi_airrtc_agl001_thermostat
    state: “off”
  • condition: state
    entity_id: climate.lumi_lumi_airrtc_agl001_thermostat_2
    state: “off”
  • condition: state
    entity_id: schedule.tag
    state: “on”
  • type: is_not_open
    condition: device
    device_id: 60f69bbd9ad28a9a0b78d12c316ab776
    entity_id: aa84ee2d0d423b30e66f57531dbec8d8
    domain: binary_sensor
    action:
  • service: climate.turn_on
    data: {}
    target:
    area_id: wohnzimmer
  • service: climate.set_temperature
    data:
    temperature: 20
    target:
    area_id: wohnzimmer
    mode: single

Yaml for off:
alias: HK WZ aus Tag/Nacht
description: “”
trigger:

  • device_id: d49f7bfad074352924a1e21eddeeecf2
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: remote_button_short_press
    condition:
  • condition: state
    entity_id: binary_sensor.lumi_lumi_airrtc_agl001_calibrated
    state: “on”
    for:
    hours: 0
    minutes: 0
    seconds: 0
    enabled: true
  • condition: state
    entity_id: binary_sensor.lumi_lumi_airrtc_agl001_calibrated_2
    state: “on”
    for:
    hours: 0
    minutes: 0
    seconds: 0
    enabled: true
    action:
  • service: climate.turn_off
    data: {}
    target:
    area_id: wohnzimmer
    mode: single

Thanks for helping

Please post your code in preformatted text (</> in the toolbar). Very hard to read otherwise.

Perhaps as you are using the same trigger for both automations so both begin to run when you press the button. Because it is initially off the condition for turn on is satisfied so it turns on. The turn off automation may be waiting for the climate to be turned on and so when first automation turns it on then the condition is satisfied for the rest of turn off automation to continue and turn it off.

  Use a helper toggle instead? Then call the service of Input Boolean: Toggle

No need for 2 automations.