So I started looking at your code (I was really just trying to see if this worked before) and after looking at it there are really only a couple of commands:
c4.amp.out output input (input 00 to turn off the zone?)
c4.amp.chvol output volume
It looks like there is an acknowledgment of sorts but don’t see anywhere that you poll the amp for current status which is interesting.
After failing to get the addon working, I tried using part of your code directly in Python and was able to change volume on one of my zones. Interesting thing is Control4 updated the current volume when I did this so there is some info likely going back to the Controller/Director in order to update the Navigator display.
I created a script just for turning on / off zones. Based on my testing, it doesn’t look like Control4 is aware of zone changes, but is aware of volume changes. Simple script below…
import logging
import socket
import random
from time import sleep
HOST = "192.168.1.155"
PORT = 8750
# Zones
outside = "01"
kitchen = "02"
garage = "03"
bedroom = "04"
# Inputs
off = "00"
pandora = "01"
TBD2 = "02"
TBD3 = "03"
TBD4 = "04"
def send_udp_command(command):
COUNTER = "0s2a" + str(random.randint(10, 99))
COMMAND = COUNTER + " " + command + " \r\n"
print("Sending command: ", COMMAND)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto( bytes(COMMAND, "utf-8"), (HOST, PORT))
received = str(sock.recv(1024), "utf-8")
print("Command sent. Response: ", str(received))
def amp_output(output, input):
send_udp_command("c4.amp.out " + output + " " + input)
def amp_change_volume(output, volume):
send_udp_command("c4.amp.chvol " + output + " " + volume)
amp_output(outside, off)
amp_output(kitchen, off)
amp_output(garage, off)
amp_output(bedroom, off)
#amp_output(outside, pandora)
#amp_output(kitchen, pandora)
#amp_output(garage, pandora)
#amp_output(bedroom, pandora)