Sensor returns "True" but not sure how to recognize that?

I have a sensor:

    tv_status:
      friendly_name: "TV Status"
      value_template: >-
        "{{ is_state_attr('remote.familyroom_hub', 'current_activity', 'Watch TV') or is_state_attr('remote.familyroom_hub', 'current_activity', 'Listen to Music') }}"

It returns “True” when one of my activities are on.

image

When I try and call it thru my Lovelace card as value “True” or “On” or “true” or “on” or whatever it fails. Any idea how I’m supposed to reference it?

So in the below:

      - card:
          color: var(--primary-text-color)
          color_type: icon
          icon: XBox Power Toggle
          name: XBox
          show_icon: false
          size: 25%
          entity: sensor.xbox_status
          styles:
            card:
              - border-radius: 30px
              - height: 32px
            label:
              - color: gray
              - font-size: 9px
              - justify-self: start
              - padding: 0px 5px
            name:
              - font-weight: bold
              - font-size: 15px
              - padding: 0px 0px
          state:
            - value: 'true'
              styles:
                icon:
                  - color: 'rgb(255,255,255)'
                card:
                  - background: 'rgb(0,128,0)'
                name:
                  - color: white
          tap_action:
            action: call-service
            service: remote.send_command
            service_data:
              command: PowerToggle
              device: Microsoft Xbox 360
              entity_id: remote.familyroom_hub
          type: 'custom:button-card'
        conditions:
          - entity: input_select.harmonytvsource
            state_not: PowerOff
        type: conditional

So in the above I set a value of true but it ignores it or fails. I tried True also but it always lower cases it. If I put double quotes it changes them to single. I can change it to my input_select and it’s value it’s fine.

Your first bit of code shows ‘tv_status’ and your other examples use ‘xbox_status’. Are you looking at the correct entity?

Make it a binary_sensor if it only has two states.

I’ve made some changes and doesn’t seem to be doing what I think or I have it setup wrong. So remote.familyroom_hub shows a current_activity of Watch TV now.

image

And my binary_sensor is set to:

- platform: template
  sensors:
    xbox360_status:
      friendly_name: "XBox 360 Status"
      value_template: >-
        "{{ is_state_attr('remote.familyroom_hub', 'current_activity', 'Watch TV') }}"

It’s coming up as off

image

Any idea why?

Since you are using a caret for multiline templates, you are not required to use quotes around the template. I’m not sure if that is entirely to blame, but have you tried the template builder to make sure it is returning true?

It is to blame. It’s the root cause of his issues.