maxlin
(Maxlin)
July 17, 2022, 7:35am
1
Hi everyone, I have a Word Clock with a WS2812
https://www.mikrocontroller.net/articles/WordClock_mit_WS2812#STM32_WordClock_Software
I would like to switch this on/off via Homeassistant, which I have already implemented via configuration.yaml
switch:
- platform: command_line
switches:
wordclock:
command_on: "/usr/bin/curl -X GET http://10.0.2.214/?action=poweron"
command_off: "/usr/bin/curl -X GET http://10.0.2.214/?action=poweroff"
value_template: '{{ value == "1" }}'
friendly_name: Wordclock
Now I would also like to pass texts or values to start a ticker or dim the clock, the commands are:
Ticker http ://10.0.2.214/?ticker=Text &action=saveticker
Brightness: Value 0- 10: http ://10.0.2.214/display?brightness=10 &action=savebrightness
Unfortunately I can’t do it, who can help me?
wordclock:
input_text:
ticker:
rest:
- authentication: basic
scan_interval: 60
resource_template: "http:// 10.0.2.214/?ticker={{ states('input_text.sa_site_id') }}sste&action=saveticker"
zoogara
(Daryl)
July 17, 2022, 8:05am
2
Welcome to the forums.
Have a read of the post linked below, especially item 11 about formatting. YAML is indent sensitive and to assist people in helping, you should use the “formatted text” tags when posting, so they can read your yaml correctly.
Before we begin…
This forum is not a helpdesk
The people here don’t work for Home Assistant, that’s an open source project. We are volunteering our free time to help others. Not all topics may get an answer, never mind one that helps you solve your problem.
[image]
This also isn’t a general home automation forum, this is a forum for Home Assistant and things related to it. Any question about Home Assistant, and about using things with Home Assistant, is welcome here. We can’t help you with e…
zoogara
(Daryl)
July 17, 2022, 10:29am
4
Not sure what this is here? Shouldn’t you configure a RESTful switch to pass your input_text to the Wordclock endpoint?
Or is there a Wordclock custom component you are using?
maxlin
(Maxlin)
July 17, 2022, 11:08am
5
Yes I want to use the RESTful switch, no custom component. I don’t know how to put the input text into the REST command as a variable. I also have trouble creating an input slider for the brightness setting.
zoogara
(Daryl)
July 17, 2022, 11:32pm
6
If you aren’t interested in any returned value from doing the settings maybe shell_command
is the way to go. Not having a WordClock or the API - this is a guess based on your post:
shell_command:
wc_set_text: "/usr/bin/curl -X GET http:// 10.0.2.214/?ticker={{ states('input_text.sa_site_id') }}sste&action=saveticker"
wc_set_brightness: # insert brightness etc
These days I create helpers like input_text
and input_number
in the GUI - but if you want to do them in YAML the examples are in the docs.
input_number:
wc_brightness:
name: "WordClock Brightness"
initial: 30
min: 1
max: 100
step: 1
input_text:
sa_site_id:
name: "WordClock Message"
initial: ""
Then automations to update on change of value:
automation:
trigger:
- platform: state
entity_id:
- input_text.sa_site_id
action:
service: shell_command.wc_set_text
# etc for other helpers.
maxlin
(Maxlin)
July 18, 2022, 1:28pm
7
ah okay that only works via automation not directly like with a switch
zoogara
(Daryl)
July 18, 2022, 8:40pm
8
I works by moving a slider in the UI. Nothing more is required apart from the helper and a short automation.
Even if you used a RESTful switch alone, that isn’t going to accept a numeric value.