hi, i have configured a slider, but now i want an automation, that sets my dimmer to the correct status
the command i need to send to my dimmer =
http://ip/dimmer.php?hex=FFFFFFFF10
or
http://ip/dimmer.php?hex=FFFFFFFF20
i can use a curl shell command for that, but offcourse the 10 or 20 , needs to be variable, based on the input of the slider
something like :
shell_command:
dimmer: ‘curl -k http://ip/dimmer.php?hex=FFFFFFFF && {{ states.input_slider.{{ state.entity_id }}.dimmer }}’
It looks like you want to pass an input_slider object_id as a variable to the shell_command. Is that right? E.g.:
service: shell_command.my_shell_command
data:
object_id: my_slider
If so, then I think something like this might work:
shell_command:
my_shell_command: >
curl -k http://ip/dimmer.php?hex=FFFFFFFF{{ states('input_slider.' ~ objec_id) }}
If the state of that slider is not exactly the right format (e.g., exactly two digits), you might need to add some formatting.
ok, how can i find out the object _id number thats being sended?
is this correct code:
shell_command:
dimmer1: 'curl -k "http://ip/bla.php?hex=FFFF{{ states('input_slider.dimmer1' ~ objec_id) }}"'
in automation:
- alias: Dimmer1
id: '1513037592911'
trigger:
- entity_id: input_number.dimmer1
platform: state
action:
- service: shell_command.dimmer1
data:
object_id: input_slider.dimmer1
You’ve got entity_id’s and object_id’s confused. An entity_id is made up of a domain and an object_id, separated by a period. So input_slider.dimmer1
is an entity_id, whose domain is input_slider
and whose object_id is dimmer1
.
Let’s take a step back. Do you want the shell_command to be sent information about which input_slider to use from the automation, or do you want the shell_command to always use the same input_slider?
hi, needs always be the same slider, i only have one dimmer/slider
based on the slider status, like 10 , 20 , 30. , those numeric values are corresonding to the status of the light
this is what i have now : i am quite close i think, also it seems the value is being sended as 10.0 and 20.0 , so i need to change that format also
input_number:
dimmer1:
name: dimmer1
initial: 0
min: 0
max: 100
step: 10
shell_command:
dimmer1: 'curl -k http://ip/bla.php?hex=FFFFFFFF{{ states.input_number.dimmer1.state }'
automation :
- alias: Dimmer1
id: '1513037592911'
trigger:
- entity_id: input_number.dimmer1
platform: state
action:
- service: shell_command.dimmer1
Try:
shell_command:
dimmer1: "curl -k http://ip/bla.php?hex=FFFFFFFF{{ '%02d'|format(states('input_number.dimmer1')|int) }}"
This changes the state string into a int, and then uses the format filter to format it as two digits, with zero padding.
EDIT: Of course, the input_number is probably in decimal, and the URL seems to want hex, so you might need to change '%02d'
to '%02x'
.
OMG what do i love this community! its working
thnx a lot!!
1 Like