The information I received from JUKE was
Toggling zones:
Path: …/zone_toggle.php
Method: POST
Parameters:
- index: zone number minus 1
- id (optional): Typically None, but for multi-juke systems, can replace this with the mac id of the juke of interest
- power: power toggle for the zone. “on” will get flipped to “off” and “off” will get flipped to “on”
- source: source to play to the zone specified in the ‘id’ field
Changing volume:
Path: …/commit_zone_volumes.php
Method: POST
Parameters:
- data: a json string which consists of a list of dictionaries containing the following fields:
- index: zone number minus 1
- new_volume: volume to set to (0-100)
- id (optional): Typically None, but for multi-juke systems, can replace this with the mac id of the Juke of interest
Sample:
To clear zone 1:
requests.post(‘http://juke.local/zone_toggle.php’, data={‘index’:0, ‘id’:‘None’, ‘power’:‘on’})
To set zone 2 to source 3:
requests.post(‘http://juke.local/zone_toggle.php’, data={‘index’:1, ‘id’:‘None’, ‘power’:‘off’, ‘source’:3})
To set zone 2 volume to 100%:
requests.post(‘http://juke.local/commit_zone_volume.php’, data=“[{‘index’:1, ‘new_volume’:100, ‘id’:‘None’})]”
Based on the above and help from many here, in the file configuration.yaml add
rest_command: !include rest.yaml
File rest.yaml
# IP address for the Juke is needed, this configuration uses 10.10.10.13
# Setting outputs to source 1
# name juke_{the source}_{output numner}_{off if it to be off}
juke_s1_o1:
# url of juke with zone_toggle.pho as the page
url: http://10.10.10.13/zone_toggle.php
# post to change
method: post
# format of the post
content_type: "application/x-www-form-urlencoded"
# Path: .../zone_toggle.php
# Method: POST
# Parameters:
# - index: zone number minus 1
# - id (optional): Typically None, but for multi-juke systems,
# can replace this with the mac id of the juke of interest
# - power: power toggle for the zone. "on" will get flipped to "off"
# and "off" will get flipped to "on"
# - source: source to play to the zone specified in the 'id' field
payload: 'index=0&id=None&power=off&source=1'
juke_s1_o2:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=1&id=None&power=off&source=1'
juke_s1_o3:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=2&id=None&power=off&source=1'
juke_s1_o4:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=3&id=None&power=off&source=1'
juke_s1_o5:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=4&id=None&power=off&source=1'
juke_s1_o6:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=5&id=None&power=off&source=1'
juke_s1_o7:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=6&id=None&power=off&source=1'
juke_s1_o8:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=7&id=None&power=off&source=1'
# Setting outputs to source 2
# name juke_{the source}_{output numner}_{off if it to be off}
juke_s2_o1:
# url of juke with zone_toggle.pho as the page
url: http://10.10.10.13/zone_toggle.php
# post to change
method: post
# format of the post
content_type: "application/x-www-form-urlencoded"
# Path: .../zone_toggle.php
# Method: POST
# Parameters:
# - index: zone number minus 1
# - id (optional): Typically None, but for multi-juke systems,
# can replace this with the mac id of the juke of interest
# - power: power toggle for the zone. "on" will get flipped to "off"
# and "off" will get flipped to "on"
# - source: source to play to the zone specified in the 'id' field
payload: 'index=0&id=None&power=off&source=2'
juke_s2_o2:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=1&id=None&power=off&source=2'
juke_s2_o3:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=2&id=None&power=off&source=2'
juke_s2_o4:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=3&id=None&power=off&source=2'
juke_s2_o5:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=4&id=None&power=off&source=2'
juke_s2_o6:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=5&id=None&power=off&source=2'
juke_s2_o7:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=6&id=None&power=off&source=2'
juke_s2_o8:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=7&id=None&power=off&source=2'
# Setting outputs to source 3
# name juke_{the source}_{output numner}_{off if it to be off}
juke_s3_o1:
# url of juke with zone_toggle.pho as the page
url: http://10.10.10.13/zone_toggle.php
# post to change
method: post
# format of the post
content_type: "application/x-www-form-urlencoded"
# Path: .../zone_toggle.php
# Method: POST
# Parameters:
# - index: zone number minus 1
# - id (optional): Typically None, but for multi-juke systems,
# can replace this with the mac id of the juke of interest
# - power: power toggle for the zone. "on" will get flipped to "off"
# and "off" will get flipped to "on"
# - source: source to play to the zone specified in the 'id' field
payload: 'index=0&id=None&power=off&source=3'
juke_s3_o2:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=1&id=None&power=off&source=3'
juke_s3_o3:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=2&id=None&power=off&source=3'
juke_s3_o4:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=3&id=None&power=off&source=3'
juke_s3_o5:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=4&id=None&power=off&source=3'
juke_s3_o6:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=5&id=None&power=off&source=3'
juke_s3_o7:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=6&id=None&power=off&source=3'
juke_s3_o8:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=7&id=None&power=off&source=3'
# Setting Output to source 4
# name juke_{the source}_{output numner}_{off if it to be off}
juke_s4_o1:
# url of juke with zone_toggle.pho as the page
url: http://10.10.10.13/zone_toggle.php
# post to change
method: post
# format of the post
content_type: "application/x-www-form-urlencoded"
# Path: .../zone_toggle.php
# Method: POST
# Parameters:
# - index: zone number minus 1
# - id (optional): Typically None, but for multi-juke systems,
# can replace this with the mac id of the juke of interest
# - power: power toggle for the zone. "on" will get flipped to "off"
# and "off" will get flipped to "on"
# - source: source to play to the zone specified in the 'id' field
payload: 'index=0&id=None&power=off&source=4'
juke_s4_o2:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=1&id=None&power=off&source=4'
juke_s4_o3:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=2&id=None&power=off&source=4'
juke_s4_o4:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=3&id=None&power=off&source=4'
juke_s4_o5:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=4&id=None&power=off&source=4'
juke_s4_o6:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=5&id=None&power=off&source=4'
juke_s4_o7:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=6&id=None&power=off&source=4'
juke_s4_o8:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=7&id=None&power=off&source=4'
# Setting outputs to off
# name juke_{the source}_{output numner}_{off if it to be off}
# off will turn it off no matter the source, universal off
juke_s1_o1_off:
# url of juke with zone_toggle.pho as the page
url: http://10.10.10.13/zone_toggle.php
# post to change
method: post
# format of the post
content_type: "application/x-www-form-urlencoded"
# Path: .../zone_toggle.php
# Method: POST
# Parameters:
# - index: zone number minus 1
# - id (optional): Typically None, but for multi-juke systems,
# can replace this with the mac id of the juke of interest
# - power: power toggle for the zone. "on" will get flipped to "off"
# and "off" will get flipped to "on"
# - source: source to play to the zone specified in the 'id' field
payload: 'index=0&id=None&power=on&source=1'
juke_o2_off:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=1&id=None&power=on&source=1'
juke_o3_off:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=2&id=None&power=on&source=1'
juke_o4_off:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=3&id=None&power=on&source=1'
juke_o5_off:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=4&id=None&power=on&source=1'
juke_o6_off:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=5&id=None&power=on&source=1'
juke_o7_off:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=6&id=None&power=on&source=1'
juke_o8_off:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: 'index=7&id=None&power=on&source=1'
then the part I got working, but do not understand
Now to automate the speakers. I wanted the JUKE AUDIO to set a configuration of speakers every time a specific media player played. I could not call the entities directly from a single automation. ( Please comment if you can explain )
You need one automation to track the media player, then another to react to the first.
Tracking Automation in automations.yaml (I built it in the GUI) and what is not clear below is that the target is the second automation. I the GUI it shows Home-Audio-Zone-Set as the target the configuration file uses the entity_id that was created when I started to hack this into existence.
- id: '1651508519857' # Home Audio Helper - track the media state
alias: Home Audio Helper - track the media state
description: This will track the state of the media player, then trigger the automation
to turn on the JUKE Zones
trigger:
- platform: state
entity_id: media_player.itunes
to: playing
condition: []
action:
- service: automation.trigger
data: {}
target:
entity_id: automation.new_automation_2
mode: single
The second automation to actually move the speakers to the right configuration in automations.yaml is
- id: '1651490678798' # Home-Audio-Zone-Set
alias: Home-Audio-Zone-Set
description: ''
trigger: []
condition: []
action:
# Kitchen
- service: rest_command.juke_s4_o1
data: {}
# Dining Room
- service: rest_command.juke_s4_o2
data: {}
# Office
- service: rest_command.juke_o3_off
data: {}
# Basement
- service: rest_command.juke_s3_o4
data: {}
# Front Porch
- service: rest_command.juke_o5_off
data: {}
# Sunroom
- service: rest_command.juke_s4_o6
data: {}
# Back Deck
- service: rest_command.juke_o7_off
data: {}