TV automation cover closes and than opens again

Hi There,

I have an automation which closes the roller cover then the TV goes on and the sun is down. This is working, but when the cover is successfully closed, it opens 2 seconds later and I didn’t understand why.

The cover itself is upside down, so I have to configure a oposide cover, maybe it has something to do with it.

- platform: template
  covers:
      cover_r_reversed:
        friendly_name: "Cover R Reversed"
        unique_id: '0a7476cc-d6c1-40ba-8ae1-606518c3497f'
        position_template: "{{ 100 - state_attr('cover.rollo_links_abdeckung', 'current_position') | int(100) }}"
        open_cover:
          service: cover.close_cover
          data: {}
          target:
            entity_id: cover.rollo_links_abdeckung
        close_cover:
          service: cover.open_cover
          data: {}
          target:
            entity_id: cover.rollo_links_abdeckung
        stop_cover:
          service: cover.stop_cover
          data: {}
          target:
            entity_id: cover.rollo_links_abdeckung
        set_cover_position:
          service: cover.set_cover_position
          data:
            position: "{{100-position}}"
            entity_id: cover.rollo_links_abdeckung
        icon_template: >-
          {% if is_state('cover.rollo_links_abdeckung', 'closed') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}type or paste code here

here is the automation:

alias: WZ_LG_ALL
description: LED_ an, wenn Fernseher an und dunkel genug, ebenso an oder aus
triggers:
  - device_id: 6407885e3f139143853a499f71a829a6
    domain: media_player
    entity_id: 03267e1e11a0e658ffe6b6d62d3f3b16
    type: turned_off
    for:
      hours: 0
      minutes: 2
      seconds: 0
    trigger: device
    id: aus
  - event: sunset
    trigger: sun
    id: Sonnenuntergang
  - device_id: 6407885e3f139143853a499f71a829a6
    domain: media_player
    entity_id: 03267e1e11a0e658ffe6b6d62d3f3b16
    type: turned_on
    trigger: device
    id: ein
  - entity_id:
      - media_player.lg_webos_smart_tv
    to: "on"
    trigger: state
    enabled: false
conditions: []
actions:
  - alias: TV eingeschaltet nach Sonnenuntergang
    if:
      - condition: device
        device_id: 6407885e3f139143853a499f71a829a6
        domain: media_player
        entity_id: 03267e1e11a0e658ffe6b6d62d3f3b16
        type: is_on
      - condition: sun
        after: sunset
      - condition: trigger
        id:
          - ein
    then:
      - type: turn_on
        device_id: ca4e5316b533db506f6309bf2b39bbce
        entity_id: b065d706fda21de56ce96959a80f7318
        domain: switch
      - action: cover.close_cover
        metadata: {}
        data: {}
        target:
          entity_id: cover.wohnzimmer_links_blind_reversed
  - alias: TV aus
    if:
      - condition: device
        device_id: 6407885e3f139143853a499f71a829a6
        domain: media_player
        entity_id: 03267e1e11a0e658ffe6b6d62d3f3b16
        type: is_off
      - condition: trigger
        id:
          - aus
    then:
      - type: turn_off
        device_id: ca4e5316b533db506f6309bf2b39bbce
        entity_id: b065d706fda21de56ce96959a80f7318
        domain: switch
  - alias: TV eingeschaltet, Sonne geht unter
    if:
      - condition: device
        device_id: 6407885e3f139143853a499f71a829a6
        domain: media_player
        entity_id: 03267e1e11a0e658ffe6b6d62d3f3b16
        type: is_on
      - condition: or
        conditions:
          - condition: sun
            after: sunset
          - condition: sun
            before: sunrise
      - condition: trigger
        id:
          - Sonnenuntergang
    then:
      - type: turn_on
        device_id: ca4e5316b533db506f6309bf2b39bbce
        entity_id: b065d706fda21de56ce96959a80f7318
        domain: switch
      - action: cover.close_cover
        metadata: {}
        data: {}
        target:
          entity_id: cover.wohnzimmer_links_blind_reversed
mode: parallel
max: 10

here is the trace:

{
  "trace": {
    "last_step": "action/2/if/condition/2",
    "run_id": "4703816adb3345740f33243906ec6585",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2025-02-22T18:09:36.501112+00:00",
      "finish": "2025-02-22T18:09:38.581049+00:00"
    },
    "domain": "automation",
    "item_id": "1703001442014",
    "trigger": "state of media_player.lg_webos_smart_tv",
    "trace": {
      "trigger/2": [
        {
          "path": "trigger/2",
          "timestamp": "2025-02-22T18:09:36.501304+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.lg_all",
              "state": "on",
              "attributes": {
                "id": "1703001442014",
                "last_triggered": "2025-02-22T16:33:14.677107+00:00",
                "mode": "parallel",
                "current": 0,
                "max": 10,
                "friendly_name": "WZ_LG_ALL"
              },
              "last_changed": "2025-02-22T16:17:03.448089+00:00",
              "last_reported": "2025-02-22T16:33:14.680172+00:00",
              "last_updated": "2025-02-22T16:33:14.680172+00:00",
              "context": {
                "id": "01JMQ830XMERW22ABKP1H60R2S",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "ein",
              "idx": "2",
              "alias": null,
              "platform": "device",
              "entity_id": "media_player.lg_webos_smart_tv",
              "from_state": {
                "entity_id": "media_player.lg_webos_smart_tv",
                "state": "off",
                "attributes": {
                  "source_list": [
                    "Live TV"
                  ],
                  "assumed_state": true,
                  "device_class": "tv",
                  "friendly_name": "LG webOS Smart TV",
                  "supported_features": 24381
                },
                "last_changed": "2025-02-22T16:16:54.800102+00:00",
                "last_reported": "2025-02-22T16:16:54.800102+00:00",
                "last_updated": "2025-02-22T16:16:54.800102+00:00",
                "context": {
                  "id": "01JMQ7540G1PTF8R1JQ7MWNYD9",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "media_player.lg_webos_smart_tv",
                "state": "on",
                "attributes": {
                  "source_list": [
                    "ARD Mediathek",
                    "ARTE",
                    "Amazon Alexa",
                    "Apps",
                    "CHILI",
                    "DAZN",
                    "Disney+",
                    "GigaBlue Set-Top-Box",
                    "HDMI 2",
                    "HDMI 3",
                    "HDMI 4",
                    "Home Dashboard",
                    "Joyn",
                    "Kunstgalerie",
                    "LG Channels",
                    "Live TV",
                    "Media Player",
                    "Netflix",
                    "Prime Video",
                    "Public Value",
                    "Rakuten TV",
                    "Shop Time",
                    "Smart IPTV",
                    "Sport-Alarm",
                    "Webbrowser",
                    "YouTube",
                    "ZDFmediathek",
                    "Zattoo - TV Streaming",
                    "o2.tv",
                    "waipu.tv"
                  ],
                  "volume_level": 0.12,
                  "is_volume_muted": false,
                  "source": "GigaBlue Set-Top-Box",
                  "sound_output": "tv_speaker",
                  "assumed_state": true,
                  "device_class": "tv",
                  "friendly_name": "LG webOS Smart TV",
                  "supported_features": 24381
                },
                "last_changed": "2025-02-22T18:09:36.492147+00:00",
                "last_reported": "2025-02-22T18:09:36.505273+00:00",
                "last_updated": "2025-02-22T18:09:36.492147+00:00",
                "context": {
                  "id": "01JMQDKF7CZ1JTNYDHGJNY7E81",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of media_player.lg_webos_smart_tv"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2025-02-22T18:09:36.501816+00:00",
          "changed_variables": {
            "context": {
              "id": "01JMQDKF7NHA276YQP4ZR1Z229",
              "parent_id": "01JMQDKF7CZ1JTNYDHGJNY7E81",
              "user_id": null
            }
          },
          "result": {
            "choice": "then"
          }
        }
      ],
      "action/0/if": [
        {
          "path": "action/0/if",
          "timestamp": "2025-02-22T18:09:36.501985+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/if/condition/0": [
        {
          "path": "action/0/if/condition/0",
          "timestamp": "2025-02-22T18:09:36.502064+00:00",
          "result": {
            "result": true,
            "state": "on",
            "wanted_state": "on"
          }
        }
      ],
      "action/0/if/condition/1": [
        {
          "path": "action/0/if/condition/1",
          "timestamp": "2025-02-22T18:09:36.502192+00:00",
          "result": {
            "wanted_time_after": "2025-02-22T16:33:14.674100+00:00",
            "result": true
          }
        }
      ],
      "action/0/if/condition/2": [
        {
          "path": "action/0/if/condition/2",
          "timestamp": "2025-02-22T18:09:36.502804+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/then/0": [
        {
          "path": "action/0/then/0",
          "timestamp": "2025-02-22T18:09:36.503228+00:00"
        }
      ],
      "action/0/then/1": [
        {
          "path": "action/0/then/1",
          "timestamp": "2025-02-22T18:09:36.505643+00:00",
          "result": {
            "params": {
              "domain": "cover",
              "service": "close_cover",
              "service_data": {},
              "target": {
                "entity_id": [
                  "cover.wohnzimmer_links_blind_reversed"
                ]
              }
            },
            "running_script": false
          }
        }
      ],
      "action/0/then/1/0": [
        {
          "path": "action/0/then/1/0",
          "timestamp": "2025-02-22T18:09:36.506960+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "cover.wohnzimmer_links_blind_reversed",
              "state": "open",
              "attributes": {
                "current_position": 100,
                "icon": "mdi:blinds-open",
                "friendly_name": "Cover R Reversed",
                "supported_features": 15
              },
              "last_changed": "2025-02-22T18:10:40.863059+00:00",
              "last_reported": "2025-02-22T18:10:40.863059+00:00",
              "last_updated": "2025-02-22T18:10:40.863059+00:00",
              "context": {
                "id": "01JMQDNE2XM40B2APGSJM7NG0Y",
                "parent_id": null,
                "user_id": null
              }
            }
          },
          "result": {
            "params": {
              "domain": "cover",
              "service": "open_cover",
              "service_data": {},
              "target": {
                "entity_id": [
                  "cover.rollo_links_abdeckung"
                ]
              }
            },
            "running_script": false
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2025-02-22T18:09:38.579039+00:00"
        }
      ],
      "action/1/if": [
        {
          "path": "action/1/if",
          "timestamp": "2025-02-22T18:09:38.579211+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/1/if/condition/0": [
        {
          "path": "action/1/if/condition/0",
          "timestamp": "2025-02-22T18:09:38.579291+00:00",
          "result": {
            "result": false,
            "state": "on",
            "wanted_state": "off"
          }
        }
      ],
      "action/2": [
        {
          "path": "action/2",
          "timestamp": "2025-02-22T18:09:38.579508+00:00"
        }
      ],
      "action/2/if": [
        {
          "path": "action/2/if",
          "timestamp": "2025-02-22T18:09:38.579627+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/2/if/condition/0": [
        {
          "path": "action/2/if/condition/0",
          "timestamp": "2025-02-22T18:09:38.579698+00:00",
          "result": {
            "result": true,
            "state": "on",
            "wanted_state": "on"
          }
        }
      ],
      "action/2/if/condition/1": [
        {
          "path": "action/2/if/condition/1",
          "timestamp": "2025-02-22T18:09:38.579807+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/2/if/condition/1/conditions/0": [
        {
          "path": "action/2/if/condition/1/conditions/0",
          "timestamp": "2025-02-22T18:09:38.579868+00:00",
          "result": {
            "wanted_time_after": "2025-02-22T16:33:14.674100+00:00",
            "result": true
          }
        }
      ],
      "action/2/if/condition/2": [
        {
          "path": "action/2/if/condition/2",
          "timestamp": "2025-02-22T18:09:38.580504+00:00",
          "result": {
            "result": false
          }
        }
      ]
    },
    "config": {
      "id": "1703001442014",
      "alias": "WZ_LG_ALL",
      "description": "LED_ an, wenn Fernseher an und dunkel genug, ebenso an oder aus",
      "triggers": [
        {
          "device_id": "6407885e3f139143853a499f71a829a6",
          "domain": "media_player",
          "entity_id": "03267e1e11a0e658ffe6b6d62d3f3b16",
          "type": "turned_off",
          "for": {
            "hours": 0,
            "minutes": 2,
            "seconds": 0
          },
          "trigger": "device",
          "id": "aus"
        },
        {
          "event": "sunset",
          "trigger": "sun",
          "id": "Sonnenuntergang"
        },
        {
          "device_id": "6407885e3f139143853a499f71a829a6",
          "domain": "media_player",
          "entity_id": "03267e1e11a0e658ffe6b6d62d3f3b16",
          "type": "turned_on",
          "trigger": "device",
          "id": "ein"
        },
        {
          "entity_id": [
            "media_player.lg_webos_smart_tv"
          ],
          "to": "on",
          "trigger": "state",
          "enabled": false
        }
      ],
      "conditions": [],
      "actions": [
        {
          "alias": "TV eingeschaltet nach Sonnenuntergang",
          "if": [
            {
              "condition": "device",
              "device_id": "6407885e3f139143853a499f71a829a6",
              "domain": "media_player",
              "entity_id": "03267e1e11a0e658ffe6b6d62d3f3b16",
              "type": "is_on"
            },
            {
              "condition": "sun",
              "after": "sunset"
            },
            {
              "condition": "trigger",
              "id": [
                "ein"
              ]
            }
          ],
          "then": [
            {
              "type": "turn_on",
              "device_id": "ca4e5316b533db506f6309bf2b39bbce",
              "entity_id": "b065d706fda21de56ce96959a80f7318",
              "domain": "switch"
            },
            {
              "action": "cover.close_cover",
              "metadata": {},
              "data": {},
              "target": {
                "entity_id": "cover.wohnzimmer_links_blind_reversed"
              }
            }
          ]
        },
        {
          "alias": "TV aus",
          "if": [
            {
              "condition": "device",
              "device_id": "6407885e3f139143853a499f71a829a6",
              "domain": "media_player",
              "entity_id": "03267e1e11a0e658ffe6b6d62d3f3b16",
              "type": "is_off"
            },
            {
              "condition": "trigger",
              "id": [
                "aus"
              ]
            }
          ],
          "then": [
            {
              "type": "turn_off",
              "device_id": "ca4e5316b533db506f6309bf2b39bbce",
              "entity_id": "b065d706fda21de56ce96959a80f7318",
              "domain": "switch"
            }
          ]
        },
        {
          "alias": "TV eingeschaltet, Sonne geht unter",
          "if": [
            {
              "condition": "device",
              "device_id": "6407885e3f139143853a499f71a829a6",
              "domain": "media_player",
              "entity_id": "03267e1e11a0e658ffe6b6d62d3f3b16",
              "type": "is_on"
            },
            {
              "condition": "or",
              "conditions": [
                {
                  "condition": "sun",
                  "after": "sunset"
                },
                {
                  "condition": "sun",
                  "before": "sunrise"
                }
              ]
            },
            {
              "condition": "trigger",
              "id": [
                "Sonnenuntergang"
              ]
            }
          ],
          "then": [
            {
              "type": "turn_on",
              "device_id": "ca4e5316b533db506f6309bf2b39bbce",
              "entity_id": "b065d706fda21de56ce96959a80f7318",
              "domain": "switch"
            },
            {
              "action": "cover.close_cover",
              "metadata": {},
              "data": {},
              "target": {
                "entity_id": "cover.wohnzimmer_links_blind_reversed"
              }
            }
          ]
        }
      ],
      "mode": "parallel",
      "max": 10
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01JMQDKF7NHA276YQP4ZR1Z229",
      "parent_id": "01JMQDKF7CZ1JTNYDHGJNY7E81",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "WZ_LG_ALL",
      "message": "triggered by state of media_player.lg_webos_smart_tv",
      "source": "state of media_player.lg_webos_smart_tv",
      "entity_id": "automation.lg_all",
      "context_id": "01JMQDKF7NHA276YQP4ZR1Z229",
      "domain": "automation",
      "when": 1740247776.5014637
    },
    {
      "state": "on",
      "entity_id": "switch.tasmota",
      "when": 1740247776.649667,
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "WZ_LG_ALL",
      "context_message": "triggered by state of media_player.lg_webos_smart_tv",
      "context_source": "state of media_player.lg_webos_smart_tv",
      "context_entity_id": "automation.lg_all"
    },
    {
      "state": "opening",
      "entity_id": "cover.rollo_links_abdeckung",
      "when": 1740247778.5760598,
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "WZ_LG_ALL",
      "context_message": "triggered by state of media_player.lg_webos_smart_tv",
      "context_source": "state of media_player.lg_webos_smart_tv",
      "context_entity_id": "automation.lg_all"
    }
  ]
}

in the last section of the trace the cover is triggered to open:

    {
      "state": "opening",
      "entity_id": "cover.rollo_links_abdeckung",
      "when": 1740247778.5760598,
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "WZ_LG_ALL",
      "context_message": "triggered by state of media_player.lg_webos_smart_tv",
      "context_source": "state of media_player.lg_webos_smart_tv",
      "context_entity_id": "automation.lg_all"
    }

But I don’t understand why. I would say it is nowhere configured to open in my automation. The more I look on it the lesser I see. Would be great if someone can take a look.

Thanks Micha