No it is not - it is “copy & pasted” from an my REST definition of the same:
- platform: rest
resource: http://10.168.10.23/status
name: Gardin_Utsikt_Inner
value_template: >
{%- if value[21:25] == 'Open' -%} Open
{%- elif value[21:25] == 'Clos' -%} Closed
{%- elif value[21:25] == 'MyPo' -%} My Position
{%- else -%} Offline
{%- endif -%}
icon: >
{%- if value[21:25] == 'Open' -%} mdi:curtains
{%- elif value[21:25] == 'Clos' -%} mdi:curtains-closed
{%- elif value[21:25] == 'MyPo' -%} mdi:star
{%- else -%} mdi:cloud-off-outline
{%- endif -%}
That works on the REST - however, that version of control of my Glydea-ESp32C6 implementation does not show the cover controls - it just shows the status…
So far I have tried a few different variants of this thru customize settings in configuration.yaml - none seems to do what I would like, nor do they present any error. To cut it short, here are the four versions I tested:
homeassistant:
customize:
cover.gardin_utsikten_inner:
device_class: curtain
icon: >
{%- if value[21:25] == 'Open' -%} mdi:curtains
{%- elif value[21:25] == 'Clos' -%} mdi:curtains-closed
{%- elif value[21:25] == 'MyPo' -%} mdi:star
{%- else -%} mdi:cloud-off-outline
{%- endif -%}
cover.gardin_matplats_inner:
device_class: curtain
templates:
icon: >
{%- if value[21:25] == 'Open' -%} mdi:curtains
{%- elif value[21:25] == 'Clos' -%} mdi:curtains-closed
{%- elif value[21:25] == 'MyPo' -%} mdi:star
{%- else -%} mdi:cloud-off-outline
{%- endif -%}
cover.gardin_sovrum_inner:
device_class: curtain
templates:
icon: >
{% if cover.gardin_sovrum_inner.attributes.current_position == 100 %} mdi:curtains
{% elif cover.gardin_sovrum_inner.attributes.current_position == 0 %} mdi:curtains-closed
{% elif cover.gardin_sovrum_inner.attributes.current_position == 50 %} mdi:star
{% else %} mdi:cloud-off-outline
{% endif %}
cover.gardin_matplats_ytter:
device_class: curtain
templates:
icon: >
{%- if value[21:25] == 'Open' -%} mdi:curtains
{%- elif value[21:25] == 'Clos' -%} mdi:curtains-closed
{%- elif value[21:25] == 'MyPo' -%} mdi:star
{%- else -%} mdi:cloud-off-outline
{%- endif -%}
Result of the above:
1st - No icon what so ever
2nd, 3rd and 4th - original icon, nothing changed
I have tested some variants of this, and fibbled back and forward with syntax. Actually no syntax error so far, but no luck with controlling icon either…
Just to show what I can see in development tools:
device_class: curtain
friendly_name: Gardin_Sovrum_Inner
supported_features: 15
icon: >
{% if current_position == 100 %} mdi:curtains {% elif current_position == 0 %}
mdi:curtains-closed {% elif current_position == 50 %} mdi:star {% else %}
mdi:cloud-off-outline {% endif %}
current_position: 50
I am trying to find a way here - but I know I am mixing and randomly trying to fix what might be clear for some, but not for me. Just a thing like “{%” vs {%-" - what with that minus sign? When and why?
And to answer your question, “value[21:25]” refers to the value returned from the ESP32C6 “status” question which will return one of the following text messages:
- Open
- Closed
- MyPosition
The 21:25 gives the 4 first characters of status string that is returned when calling the “status” function on the web server running on the ESP32C6.