With a python module, i wrote earlier, for remote control of hegel amplifiers and an MQTT queue i integrated the hegel in Home Assistant and Node-Red.
It is now possible to control all functions of my H190 and H390 with standard home automation components and apps.
So native volume control, input selection, on and off .
At the moment it is just a very basic script but soon will be a docker container with a bit more functionality and configuration.
if you use it, please let me know here in the community.
This way i know that i can put time in it thus not wasting it.
This is the work of a few hours tinkering.
Just for kicks and giggles, here is the Proof of Concept code.
It works, but use it at your own risk.
The hegel python module is not on pypi yet but will be.
#!/usr/bin/env python3
# Copyright (C) 2021, https://gitlab.com/ptrdvds
# All rights reserved.
# This file is part of hegel-remote.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
import hegel
import time
import paho.mqtt.client as mqtt
MQTT_BASE_TOPIC = 'home/hegel'
MQTT_HOST = "192.168.99.30"
MQTT_PORT = 1883
MQTT_SLS = 60
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
client.subscribe(MQTT_BASE_TOPIC + '/#')
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, message):
"""
This is where the magic happens.
:return: Not designed to return something
"""
elements = message.topic.split('/')
action = elements[-1]
function = elements[-2]
device = elements[-3]
if device.lower() in ['h190', 'h390']:
target_device = eval(device.lower())
if function in ['p', 'power',
'v', 'volume',
'i', 'input'
'm', 'mute']:
if action == 'set':
value = target_device.remote(function, message.payload)
if action == 'get':
value = target_device.remote(function)
client.publish(MQTT_BASE_TOPIC + '/' + device + '/' + function, value)
def service_loop(client):
"""
This is a service loop to send e.g. keepalive.
All to know when this program has stopped.
:return: Not designed to return something
"""
while True:
# TODO make heartbeat asynchronious
time.sleep(MQTT_SLS)
client.publish(MQTT_BASE_TOPIC + "/heartbeat", time.time())
def main():
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(MQTT_HOST,
MQTT_PORT,
MQTT_SLS,
)
client.loop_start()
service_loop(client)
if __name__ == '__main__':
h390 = hegel.create('H390', '192.168.20.40')
h190 = hegel.create('H190', '192.168.20.41')
main()