Command line Switch, status display icon, command_state from snmp

Hi all!
I created switch with http reuest for my lan controller device. Swtich work ok, problem is returned value for state switch…
My code is

  • platform: command_line
    switches:
    lc210_out1:
    command_on: “curl -u user:pass 192.168.5.210:86/outs.cgi?out1=0”
    command_off: “curl -u user:pass 192.168.5.210:86/outs.cgi?out1=1”
    friendly_name: SWITCH LAN CONTROLLER

How can i add correct state of switch ?
With this request i get answer for ON

111111

and this is for off

101111

This is state for 6 output relay on Lan controller. First number OUT 0 and last number for OUT 5

For state of this output relay i use snmp sensor, but i dont know insert in this switch for state…

This is snmp code:

  • platform: snmp
    name: “LC210 OUT 1”
    host: 192.168.5.210
    baseoid: 1.3.6.1.4.1.17095.3.2.0
    scan_interval: 1

Thankyou for hep !

Maybe use a value_template. I’m not sure if what is being returned is a number of a string (you may have to play with it some), but here is something to try if its a string:
value_template: "{% if value == '111111' %}true{% else %}false{% endif %}"

Here is lot combination of output number. 111111 is only , if ALL output ON, 101111 is only if all output ON, exept OUT 1 is OFF… i hope you understand… in this case, should only be looking at the second number in the string for OUT1, and for OUT2 only the third number…

Ah,OK, I understand now.

Here is something for you to try specifically for out1:
"{% if value | int(base=2) | bitwise_and(16) >0 %}true{% else %}false{% endif %}"

For out0 (leftmost bit), use bitwise_and(32)
For out5 (rightmost bit), use bitwise_and(1)
In other words, as you move from leftmost bit to right most bit, use 32,16,8,4,2,1 respectively.

You can try this out in the Developers Tool->Template using:

{% set binarystring = '101111' %}
{{ binarystring | int(base=2) | bitwise_and(16) }}