kdmutriy
(Kdmutriy)
December 4, 2024, 7:30am
1
I have
command_line:
- switch:
name: Tree effect
command_on: echo -e '\x47\x54\x04\x00\x{{'%02x' % state_attr('input_select.cicle_effect_tree','options').index(states('input_select.cicle_effect_tree')) |int }}' | nc -w2 -u 192.168.0.118 8888
command_off: echo -e '\x47\x54\x02\x06' | nc -w2 -u 192.168.0.118 8888
but my devise not work for this command.
I tested static command and it is worked normal
- switch:
name: Tree effect
command_on: echo -e '\x47\x54\x04\x00\x15' | nc -w2 -u 192.168.0.118 8888
command_off: echo -e '\x47\x54\x02\x06' | nc -w2 -u 192.168.0.118 8888
who can explain why does not work dynamically?
Troon
(Troon)
December 4, 2024, 7:37am
2
command_on
and command_off
do not support templates, according to the documentation .
Perhaps try using a shell_command
instead?
1 Like
kdmutriy
(Kdmutriy)
December 4, 2024, 7:46am
3
I see such an example in the documentation
command_line:
- sensor:
name: Wind direction
command: "sh /home/pi/.homeassistant/scripts/wind_direction.sh {{ states('sensor.wind_direction') }}"
unit_of_measurement: "Direction"
maby use this solution?
But I dont know how is run “sensor”
Troon
(Troon)
December 4, 2024, 7:50am
4
A sensor gets a value, and its command
does support templates:
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
December 4, 2024, 7:51am
5
kdmutriy:
')) |int }}'
Hi kdmutriy ,
You have the same quote character inner and outer. double the inner set up or use " character there.
It’s getting confused.
So look for that in future templates, but it won’t help you here BC what he said.
2 Likes
kdmutriy
(Kdmutriy)
December 4, 2024, 8:19am
6
of course. you need to use “shell_command” I went to google how to do it in my case
kdmutriy
(Kdmutriy)
December 4, 2024, 8:11pm
7
I`m testing code
shell_command:
set_effect: echo -e '\x47\x54\x04\x00\x04' | nc -w2 -u 192.168.0.118 8888
set_select_effect: echo -e '\x47\x54\x04\x00\x{{"%02x" % state_attr("input_select.cicle_effect_tree","options").index(states("input_select.cicle_effect_tree")) |int }}' | nc -w2 -u 192.168.0.118 8888
set_effect - normal worked
set_select_effect - not worked
Am I doing something wrong again?