I’d love to control my AVR through the network as opposed to IR control. Is there any scope for this, it already has a phone app for android and iPhone.
I’ve found this ‘API’ for Harmon/Kardon equipment, has anyone implemented this in any way? https://github.com/KarimGeiger/HKAPI
If not the code is PHP, what would be the best way to implement it with Home Assistant?
I see it’s quit easy to control via socket connection and POST request, I just tested it with a unit test and it work on my JBL AVR101 (same API as the Harman/Kardon)
import unittest
import socket
import time
class HarmanCarbonTest(unittest.TestCase):
def test_socket(selfself):
xml = """<?xml version="1.0" encoding="UTF-8"?>
<harman>
<avr>
<common>
<control>
<name>power-on</name>
<zone>Main Zone</zone>
<para></para>
</control>
</common>
</avr>
</harman>"""
command2 = """POST AVR HTTP/1.1\r\nHost: :10025\r\nUser-Agent: Harman Kardon AVR Remote Controller /2.0\r\nContent-Length: """ + str(xml.__len__())\
+ """\r\n\r\n""" + xml
command = '<xml version="1.0" encoding="UTF-8"><header/><body><code><body/>'
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("192.168.0.177", 10025))
#s.send(command)
print("going to do it")
s.sendto(command2.encode(), ("192.168.0.177", 10025))
print("has done it")
time.sleep(5)
s.close()
I’d like a few person to try it out before I merge it in home-assistant main code.
To try it out, simply save the code in a harman_kardon_avr.py file under config/custom_components/media_player/ (if the directories doesn’t exist, simply create them).
The code is available here: https://pastebin.com/ZLMHYcbw
You’ll have to replace “source name” with the name of the source you want to set. You should use the source name as it appear on the on-screen menu.
(Example values: Cable Sat, Disc, DVR, Radio, TV, USB, Game, Media Server, Home Network, AUX, Source A, Source B, Source C, Source D)