Detect a change of a variable

Hello i need your help. I have a variable with the actual tv channel. example: activeChannel = ard.

Now i want to check a channel change. example activeChannel=zdf

I need a trigger (changeChannel) for a automation.

Any idea?

Thanx Oliver

Is that the state of an entity, or the attribute of an entity?

it ist a state of an entity. i generate it with a template from an attribute.

  • platform: template
    sensors:
    solo4k_aktiver_sender:
    friendly_name: ‘Solo4k Aktiver Sender’
    value_template: ‘{{ states.media_player.solo4k.attributes.source }}’

Please format your YAML correctly, as explained in the big blue box at the top.

Then it’s a normal automation with a state based trigger:

trigger:
  platform: state
  entity_id: sensor.solo4k_aktiver_sender
  to: 'zdf'

Sorry, my question was not clear enough. I want to trigger every channel change. From ard to zdf, from zdf to ard, from wdr to ndr etc.

In that case, drop the to: line, then it will trigger on every state change of sensor.solo4k_aktiver_sender.

Thank you very much. Its functional!