Hi everyone,
I’m interested in using a cover to control my TV volume (via Broadlink RM Pro IR blaster) so that the GUI is easy to use…
For example, I would like to have something like this (for TV Volume not Garage door)…
instead of what I currently have which is this…
Here’s the code I have so far but it’s not working because I don’t think you can call a Home Assistant script from a command_line cover.
Would anyone have any insight on how I can achieve this? Or is there a different approach I should be considering?
tv_volup:
sequence:
service: broadlink.send_packet_192_168_1_202
data:
packet:
- "JgBQAAABJZMSExITERMSExISEhMSExETEjcSNxI4ETgROBI3EhMROBETEhMSNxITERMSExI3EhMROBE4EhISOBE4ETgSExxxxxAAAAA="
tv_voldown:
sequence:
service: broadlink.send_packet_192_168_1_202
data:
packet:
- "JgBQAAABJ5ITERQRExEUERMRFBEUERMRFDUUNRQ2EzYTNhQ1FBETNhM2FDUUERMRFBEUERM2ExEUERMSEzYTNhM2FDUUccccBJ0gUAA0FAAAAAAAAAAA="
cover:
- platform: command_line
covers:
tv_volume:
command_open: script.tv_volup
command_close: script.tv_volmute
command_stop: script.tv_voldown
friendly_name: TV Volume
Thanks in advance…
treno
(travis reno)
May 31, 2017, 10:47am
2
You can use curl to make an API call to the script service.
quadmasta
(Brian Cribbs)
May 31, 2017, 1:27pm
3
I updated Light.Template so it handles 'brightness" and it’ll be released in .46. The video shows use via Google Home. It’s running HA scripts behind the scenes
Thanks so much for replying @treno
I got it working using the RESTful API as you recommended
I had a lot of trouble with the formatting of the command, due to the single and double quotes.
I don’t suppose you know how I can refer to a password and ip address stored in my secrets.yaml rather than writing it directly in the command? Due to the single and double quotes, I’m not sure how I can embed the !secret parameter…
The other problem is that when I click the button repeatedly, i got the below error;
2017-06-01 18:43:46 WARNING (MainThread) [homeassistant.components.script] Script script.tv_voldown already running.
2017-06-01 18:43:47 WARNING (MainThread) [homeassistant.components.script] Script script.tv_voldown already running.
2017-06-01 18:43:48 WARNING (MainThread) [homeassistant.components.script] Script script.tv_voldown already running.
2017-06-01 18:43:48 WARNING (MainThread) [homeassistant.components.script] Script script.tv_voldown already running.
2017-06-01 18:43:49 WARNING (MainThread) [homeassistant.components.script] Script script.tv_voldown already running.
Any idea how I can prevent that error?
Below is the final script I’m using…
script:
tv_volup:
sequence:
service: broadlink.send_packet_192_168_1_###
data:
packet:
- "JgxxxxFAAAAAAAAAAA="
tv_voldown:
sequence:
service: broadlink.send_packet_192_168_1_###
data:
packet:
- "JgxxxxFAAAAAAAAAAA="
tv_volmute:
sequence:
service: broadlink.send_packet_192_168_1_###
data:
packet:
- "JgxxxxFAAAAAAAAAAA="
cover:
- platform: command_line
covers:
tv_volume:
command_open: >-
curl -X POST -H "x-ha-access: MyPassword" \-H "Content-Type: application/json" \-d '{"entity_id": "script.tv_volup"}' \http://192.168.1.###:8123/api/services/script/turn_on
command_close: >-
curl -X POST -H "x-ha-access: MyPassword" \-H "Content-Type: application/json" \-d '{"entity_id": "script.tv_voldown"}' \http://192.168.1.###:8123/api/services/script/turn_on
command_stop: >-
curl -X POST -H "x-ha-access: MyPassword" \-H "Content-Type: application/json" \-d '{"entity_id": "script.tv_volmute"}' \http://192.168.1.###:8123/api/services/script/turn_on
friendly_name: TV Volume
treno
(travis reno)
June 1, 2017, 10:32am
5
I don’t think you can.
I handle this by making my commands calls to shell scripts that aren’t included in the confit path.
quadmasta
(Brian Cribbs)
June 3, 2017, 4:48pm
6
My PR that’ll be released in 4.6 allows for light.template so you can do this with a light. You can set “brightness” that’ll be passed through to the underlying object and you can pass that through to your script.
Here’s the PR:
home-assistant:dev
← cribbstechnologies:template-light
opened 01:02AM - 19 May 17 UTC
## Description:
**Pull request in [home-assistant.github.io](https://github.com… /home-assistant/home-assistant.github.io) with documentation (if applicable):** home-assistant/home-assistant.github.io#2661
## Example entry for `configuration.yaml` (if applicable):
```yaml
light:
- platform: template
lights:
temp_switch:
value_template: {{1 == 1}}
turn_on:
service: light.turn_on
entity_id: light.other_light
turn_off:
service: light.turn_off
entity_id: light.other_light
set_level:
service: light.turn_on
data_template: {{brightness}}
level_template: {{42}}
```
## Checklist:
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated in [home-assistant.github.io](https://github.com/home-assistant/home-assistant.github.io)
If the code does not interact with devices:
- [x] Local tests with `tox` run successfully. **Your PR cannot be merged unless tests pass**
- [x] Tests have been added to verify that the new code works.
Whenever the docs go live my home theater example is in there.