Creating a stateful button that calls a service

Hi,

I’ve looked into having a button that uses a broadlink mini to turn on and off my tv that isn’t connected to any network. So far the button functions perfectly, but I’d like the icon to be lit up if the tv is on, currently it doesn’t change color.

My yaml for the button is below. Does anyone know of a good way I could keep track of whether the tv is on, and have the icon reflect that it (might) be on after a press (I can manually sync the state with the physical tv with the power button so long as the state switches internally in homeassistant)?

type: button
tap_action:
  action: call-service
  service: remote.send_command
  service_data:
    entity_id: remote.broadlink_remote_remote
    device: tv
    command: power
show_icon: true
icon: 'hass:power'
name: Roku

Thanks!

Get some feedback from your TV using a power monitoring smart plug and create a template switch.