Pihole custom sensors

Firstly credit to @Vasiley for this pihole package here

I wonder if anyone who understands this level of code can help solve an issue.
For me pihole runs on a Pi on my network (not the same machine as HA) so i had to modify a few things where my command is:
ssh pi@<IP> pihole status

but displays pihole_raw_status correctly:
[✓] DNS service is running
[✓] Pi-hole blocking is Enabled

That said (a possible issue) is HA shows it on a single line:
[✓] DNS service is running [✓] Pi-hole blocking is Enabled

The error i get:
UndefinedError: list object has no element 1

is from the sensors reading the state from this:

  sensors:
    pihole_dns:
      value_template: "{{states.sensor.pihole_status_raw.state.split('[?]')[1][1:-3]}}"
      icon_template: >-
        {%- if states.sensor.pihole_status_raw.state.split('[?]')[1][1:-3] == 'DNS service is running' -%}
          mdi:checkbox-marked
        {%- else -%}
          mdi:checkbox-blank-outline
        {%- endif -%}```

any thoughts on how to solve this issue? 
[thanks in advance for any help!]

here you go

    {%- if 'DNS service is running' in states.sensor.pihole_status_raw.state -%}
      mdi:checkbox-marked
    {%- else -%}
      mdi:checkbox-blank-outline
    {%- endif -%}
1 Like

thanks i didnt know you could just find the text in the output?
i found an alternative but havent had chance to test either (for anyone who finds this)

  sensors:
    pihole_dns:
      value_template: >-
        {%-set dns = states.sensor.pihole_status_raw.state.split('[')[1][3:-3]-%}
        {%-if dns == 'DNS service is running'-%}
          DNS service is running
        {%-elif dns != 'DNS service is running'-%}
          DNS service is Disabled
        {%-else-%}
        unknown
        {%- endif -%}```