Prevent Soundbar Standby and Power It On Automatically with IR Blaster

I use a Teufel Cinebar One soundbar as the speaker for my Windows PC, which runs in a Proxmox virtual machine. This setup allows me to integrate it with Home Assistant using the Proxmox HACS integration for automation. If you are running a normal bare metal Windows PC you can simply use the ping service or something like the HASS-agent.

The issue is that the soundbar automatically goes into standby mode when no audio is played, and unfortunately, this feature cannot be disabled. My workaround is to use a Zigbee IR blaster that has learned a remote command (I use a random bass EQ setting that doesn’t affect the sound), which is sent every 14 minutes. This is the only reliable way I’ve found to prevent the soundbar from going into standby, as methods that play inaudible sounds don’t work with this model.

While I was setting this up, I also created an automation that powers on the soundbar when the Windows VM starts, so I rarely need to use the physical remote anymore.

To make the solution more robust, I added a trigger for when Home Assistant restarts, so the automation loop (based on a while true) continues running even after a reboot.

alias: Teufel IR Blaster
description: >-
  Turns on Teufel Cinebar One at OS (Proxmox VM) startup and keeps it from going
  into standby as long the VM is running. Another trigger makes sure that the
  while true loop continues if HomeAssistant is restarted.
triggers:
  - type: running
    device_id: 74d33f8ed5a70d11a8aee6e470555742
    entity_id: a0cb8ac10cfb2d66dd5a132f06d19db7
    domain: binary_sensor
    trigger: device
    id: win-started
  - trigger: homeassistant
    event: start
    id: ha-start
conditions: []
actions:
  - if:
      - condition: trigger
        id:
          - win-started
    then:
      - action: mqtt.publish
        data:
          evaluate_payload: false
          qos: "0"
          retain: false
          topic: zigbee2mqtt/AZ_IRBlaster/set
          payload: >-
            {"ir_code_to_send":
            "BVkjlhE5AkABA4UGOQLgDwHAG0AH4A8DQAHgAxvgBwFAG+ADAQuFBjkChQY5AoUGOQI="}
    alias: Turn on when VM has started
  - alias: >-
      Initialize keep awake loop when VM started or HA is restarted while VM is
      running
    if:
      - condition: or
        conditions:
          - condition: and
            conditions:
              - condition: trigger
                id:
                  - ha-start
              - type: is_running
                condition: device
                device_id: 74d33f8ed5a70d11a8aee6e470555742
                entity_id: a0cb8ac10cfb2d66dd5a132f06d19db7
                domain: binary_sensor
            alias: Continue loop even after HA restart
          - condition: trigger
            id:
              - win-started
    then:
      - delay:
          hours: 0
          minutes: 0
          seconds: 10
          milliseconds: 0
      - repeat:
          sequence:
            - action: mqtt.publish
              data:
                evaluate_payload: false
                qos: "0"
                retain: false
                topic: zigbee2mqtt/AZ_IRBlaster/set
                payload: >-
                  {"ir_code_to_send":
                  "BU8jlhE5AkABA4UGOQLgDwHAG0AH4BcDQAFAI+APAcAbQAfAAwcWnE8jxgg5Ag=="}
              alias: Trigger bass eq button to keep speaker awake
            - delay:
                hours: 0
                minutes: 14
                seconds: 0
                milliseconds: 0
          while:
            - type: is_running
              condition: device
              device_id: 74d33f8ed5a70d11a8aee6e470555742
              entity_id: a0cb8ac10cfb2d66dd5a132f06d19db7
              domain: binary_sensor
    enabled: true
mode: restart

Edit 1: changed mode to restart because vm start trigger is used twice.
Edit 2: added descriptions