Change Icon based on different sensor state

I have an Fire Tablet that I use for my Alarm Panel. Using MQTT I’m able to find out the battery level and also if the device is charging or not.
I’m wanting to somehow combine into one sensor the battery level and also if it is charging or not.

What I have so far, and I’m stuck at figuring out how to combine the two into one.

Sensor for battery %

- platform: mqtt
  state_topic: "alarmpanel/sensor/battery"
  name: "Alarm Panel Battery Level"
  unit_of_measurement: "%"
  device_class: battery
  value_template: '{{ value_json.value }}'

Sensor to see if device is charging or not:

- platform: mqtt
  state_topic: "alarmpanel/sensor/battery"
  name: "Alarm Panel Battery Charging"
  device_class: battery
  value_template: '{{ value_json.acPlugged }}'

I have a template in my customize yaml file to change the Alarm Panel Battery Charging icon when charging = true and when = false. I’m not sure how to also get the icon to show the correct battery level which is where I’m stuck.

sensor.alarm_panel_battery_charging:
  templates:
    icon: 'if (state === ''True'') return ''mdi:battery-charging''; return ''mdi:battery''; '