tom_l
September 26, 2020, 7:43am
1
I have the following rest commands:
lounge_enhance_on:
url: "http://10.1.1.17/YamahaExtendedControl/v1/main/setEnhancer?enable=true"
lounge_enhance_off:
url: "http://10.1.1.17/YamahaExtendedControl/v1/main/setEnhancer?enable=false"
And the sensor that shows the state of the enhancer:
- platform: rest
name: Lounge Enhancer
resource: http://10.1.1.16/YamahaExtendedControl/v1/main/getStatus
value_template: '{{ value_json.enhancer}}'
Is it possible to create a restful switch instead?
I’m reading the docs but not making much sense of them.
I can see clearly how I could use the sensor and commands in a template switch but restful is throwing me for a loop.
Like this?
- platform: rest
name: Lounge Enhancer
resource: http://10.1.1.17/YamahaExtendedControl/v1/main/setEnhancer?
body_on: '{"enable": "true"}'
body_off: '{"enable": "false"}'
state_resource: http://10.1.1.16/YamahaExtendedControl/v1/main/getStatus
is_on_template: '{{ value_json.enhancer }}'
headers:
Content-Type: application/json
verify_ssl: false
I think the issue is that you enable/disable the enhancer with a GET request, however according to the docs the restful switch issues POST requests by default and supports PUT as well but not GET.
tom_l
September 26, 2020, 8:06am
3
Damn. You’re right.
Template switch it is then.
But through your post I found out about the Yamaha API, thanks for this now I’m going to check if my model has this as well.
tom_l
September 26, 2020, 8:13am
5
Here’s the API reference (pdf)
Quick way to check:
http://your_avrx_ip_address/YamahaExtendedControl/v1/main/getStatus
Yeah I already found the API reference when I was checking why your rest switch doesn’t work. just need to get to the workstation for testing.
1 Like
tom_l
September 26, 2020, 8:16am
7
Ugh. Thought I’d crashed the API. Turns out I was looking at the wrong amp.
Awesome, seems like my receiver has the API.
1 Like
tom_l
September 26, 2020, 9:58am
9
FYI, this is what I ended up with. The update entity service was required to stop the switch bouncing as the restful binary sensor scan interval is too slow:
- platform: template
switches:
lounge_amp_enhancer:
friendly_name: Enhancer
value_template: "{{ is_state('binary_sensor.lounge_enhancer', 'on') }}"
turn_on:
- service: rest_command.lounge_enhancer_on
- delay:
seconds: 1
- service: homeassistant.update_entity
entity_id: binary_sensor.lounge_enhancer
turn_off:
- service: rest_command.lounge_enhancer_off
- delay:
seconds: 1
- service: homeassistant.update_entity
entity_id: binary_sensor.lounge_enhancer
icon_template: >-
{% if is_state('binary_sensor.lounge_enhancer', 'on') %}
mdi:tune-vertical
{% else %}
mdi:tune-vertical
{% endif %}
EDIT: had to add a delay between the rest service calls.
1 Like
tom_l
September 26, 2020, 5:47pm
10
I’d be interested to know if you can get the base extension function to work via the API:
http://{host}/YamahaExtendedControl/v1/main/setBassExtension?enable=true
This API command is the only one I can’t get to function. It works via my learned IR remote command so I’m not sure what is going on.
I don’t think this is supported by my stereo amp, I didn’t see “bass_extension” under http://ip-of-host/YamahaExtendedControl/v1/system/getFeatures
tom_l
September 26, 2020, 7:44pm
12
No worries. Thanks for looking.
tom_l
September 30, 2020, 6:07am
13
Ah, no wonder it wasn’t working. I don’t have that method either, I have setExtraBass. Similar but not the same.
Yamaha tech support regarding the API has been excellent BTW. They responded within a couple of business days and knew their product.
1 Like