Command_line switch - get current state

Hi,
I am after some advice. I have a NUC server running esxi. What I want to do from HA is to switch between different ESXI power profiles.
I have achieved that by creating command_line switch - this will switch between Low Power and Balanced power profiles:

switch:
  - platform: command_line
    switches:
      esxi_power_profile:
        command_on: bash /config/scripts/balanced.sh
        command_off: bash /config/scripts/low.sh

then I have added this to my dashboard to enable me to switch between the two profiles:

type: entities
entities:
  - entity: switch.esxi_power_profile
    name: 'Low Power / Balanced'
show_header_toggle: false
state_color: true
title: ESXI host power profile

My problem is how do I get the current state
I can see that the command line switch has got command_state option.
I have created another script called /config/scripts/state.sh
when run from the terminal that will return either “Low Power” or “Balanced”
This is where I’m stuck - how do I link that together.
Any advice would be much appreciated.
Thanks

Try this:

switch:
  - platform: command_line
    switches:
      esxi_power_profile:
        command_on: bash /config/scripts/balanced.sh
        command_off: bash /config/scripts/low.sh
        command_state: 'bash /config/scripts/state.sh | grep -q "Balanced"'