Presence detection: hide sensor if Away?

Is there a way to hide the sensor from the front-end if the device is Away? I currently have custom groups set up and not using the default view. I can hide the sensor if I set “hide_if_away” to true but then it also does not log the activity in the logbook whenever the device is “Away”. It only logs when the device is “Home”. I want to hide the sensor and log the activity when “Away”. Thanks.

groups.yaml:

default_view:
  view: yes
  icon: mdi:home
  entities:
    - device_tracker.device1

known_devices.yaml:

device1:
  hide_if_away: false
  name: Name1
  track: true

I think you need to add the sensor to a group and set the group visibility based on a template from the away value.