So I posted a request for change, and was referred over here to get some help
https://community.home-assistant.io/t/add-icon-template-for-cover-when-using-command-line/711634
So in short, I have 8 curtains (cover’s) that I can control over curl http://xxx.xxx.xxx.‘{{gardin}}’/open or /close or /myposition or to get /status. Over REST everything just works, and I can get the icon I like thru a “sensor” like this:
- platform: rest
resource: http://xxx/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 -%}
It just does not support the control buttons for my curtains (cover).
So I added command_line cover version of the same and now I can control the curtains with the buttons for open/stop/close which comes with that definition:
command_line:
- cover:
name: Gardin_Utsikten_Inner
unique_id: utsikten_innergardin
command_open: "/usr/bin/curl http://10.168.10.23/open"
command_close: "/usr/bin/curl http://10.168.10.23/close"
command_stop: "/usr/bin/curl http://10.168.10.23/myposition"
command_state: "/usr/bin/curl http://10.168.10.23/status"
value_template: >
{%- if value[21:25] == 'Open' -%} 100
{%- elif value[21:25] == 'Clos' -%} 0
{%- elif value[21:25] == 'MyPo' -%} 50
{%- else -%} Offline
{%- endif -%}
scan_interval: 60
But now I lost the control of the icon. Now these are Somfy Glydea motors, and they have a built in “store favorite position” called “My Position”. Now the command to get to that “My Position” is the same as sending “stop” to the device. So if the curtain is moving, it will stop, and if it is in a stopped position (anyware on the track so to speak) it will go to “My Position”. Very hand, for me and my wife anyway.
However, it would be awfully nice to get the ocon to “mdi:star” when the curtain is in “My Position”. Currently I can only get it to be either “open” or “closed”, and “open” works for anything that is NOT closed, so 1% to 100% = open. Nice
ehh… yea about that now: “My Position” is 80% for some of the curtains, or 20% for others - open, well yes partly open. However if I could get this to be an “mdi:star” icon, it would be much nicer - you know: happy wife - happy life
So I tried, as a newbie I might have to add, to add in configuration.yaml a few cuztom lines to figure that icon changing thingi out - so far I have no idea what I am doing I guess:
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
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_sovrum_ytter:
device_class: curtain
templates:
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 %}
All 4 curtains above are working in the same way. And just to give an idea what I have to “play” with, this is what I get under development tools for that command_line cover definition above:
current_position: 50
device_class: curtain
friendly_name: Gardin_Sovrum_Ytter
supported_features: 15
templates:
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 %}
So any reference to “value” in my code above, that is the value returned from the /status command. Any reference to “current_position” is to try to reference that attribute on the device (entiti?).
So the reason I added that request was that command_line has that support for other types except cover… Switch and Sensor got support for setting icon depending on “something”. It would be nice if that is implemented some day, it will for sure help me or any other newbie.
But until then I am trying to figure this Cuztom thingi out, and see if I can get it to work.
And I just can not get this to work. Either I get NO icon, or I get the Original icon from the command_line definition (which I have no control over).
Any ideas are welcome