Sensor convert to Binary Sensor

Hi Team.

I have a motion sensor that reports its batter as sensor. Is there a way that i can convert this to a binary_sensor ? Thanks in advance

Convert no. Make a template sensor to produce the result you want? Absolutely.

Thanks. I may need some basic assistance to get me rolling on this one. first time having to convert a sensor to a binary sensor.

I have this that works with binary_sensor but if it could be changed so that it worked with sensor and less than 25% then i would not need to convert a sensor to binary

type: custom:button-card
show_entity_picture: true
name: Batteries
state:
  - value: 'off'
    icon: mdi:battery
    color: red
  - value: 'on'
    icon: mdi:battery
    color: green
tap_action:
  action: navigate
  navigation_path: /mcfarlane-towers-ios/batteries
entity: binary_sensor.group_batteries
show_state: false
show_label: true
size: 10%
label: |
  [[[
    if (states['binary_sensor.group_batteries'].state === "on")
      return "OK";
    else if (states['binary_sensor.group_batteries'].state === "off")
      return "Check";
  ]]] 

You’re on the right track. Although the code in that card is a Javascript not a HA native Jinja template.

You’d use a template when you want to create a reusable sensor. (your original request) your alternative solution is to provide code or a template in each display card in Lovelace

My personal preference is if it’s reusable I go ahead and make it so (in this case the template sensor)

As far as best resources. Go to the developer tools under template - there’s your playground. Link to samples and docs are at the top left of that UI.

Make your template work in dev tools, then look up sensor under the template docs and it will show you where to place it in your config

im just going around and round in circles with this. think i will need to wait until tomorrow with fresh eyes.