Hanazeder HLC20: programmable home automation / heating controller

Hi there,

in case somebody also uses the hanazeder HLC20 for home automation for e.g. heating and is interested to read the outputs or even write the inputs. I wrote some python code for the serial connection to the controller, which makes the handshake and can read outputs and write the inputs. The python-script then updates the openHAB-items via the API - and could be used to write Outputs.

If interested, just drop a line here and I try to rewrite the script for easier using and some documentation.

1 Like

Nice. I don’t have a need for this personally but based on my experience with a similar python script I wrote for communicating with OH, creating a github repo for it makes telling people about it and getting feedback and improvements from the community much nicer. My script is here:

hah! If I only knew, how to use git or github! *:wink:
I do know, that github is cool for software source code management - but that’s all about it. But if I find some time - and there’s somebody more into it, I’m happy to see, if I can get a repository for this. (but don’t ask me, how to manage those things as merging or pull request or whatever there is! :cold_sweat:

It is well worth learning. Git is a fantastic way to back up and keep track of versions of your OH config. The rest of the github stuff can be figured out fairly easily and if you get stuck Google has yet to fail me.

I have to agree with @rlkoshak. git/github is definitely worth spending a few minutes learning for.

Still, if you just want to share your script, allow collaboration and want to be able to add changes (the minimum set of benefits for using github), you can upload your script to gist, a lightweight option by github: https://gist.github.com

Example: https://gist.github.com/ThomDietrich/ff836dbe0f0eaa2c5270a846a963893b

I did already set up the github for it. The weekend I want to make my own script somewhat more generic.
A problem I think is a bit too big for my programming skills (cough) is to make it MySQL-Independent. I made a table with all modules to be read, this should be possible to maintain in a .ini file or whatever, but my skills are limited here.

This would be a good way to broaden the script anyways, if someone more skilled likes to change this! :wink:

If you want to see an example of how to parse ini files in Python, see the sensorReporter.py file in my link above. It is really trivial to do.

yeah, you say this so easily, in fact I did look into this and my problem is to include a set of modules, which are read out by attributes within the MySQL table.

The ini-file should make it easy to move through this in a loop. And there my skills stop, like I don’t know how to put this… :wink:

…but, if someone would like to use it without SQL, he could just adjust the code! :stuck_out_tongue_winking_eye:

So I’ll break down what I did.


# The Python class that reads in the ini file and makes it easy to process
import ConfigParser

# Configure the parser
config = ConfigParser.ConfigParser(allow_no_value=True)

# Get the config based on the command line argument
def main():
  # exit if there is no command line argument
  if len(sys.argv) < 2:
    print "No config file specified on the command line!"
    sys.exit(1)

    loadConfig(sys.argv[1])

# code to actually read in the ini file
def loadConfig(configFile):
  # Read in the file
  config.read(configFile)

  # Get some parameters from a known section
  # String
  config.get("Section", "StrItem")
  # int
  config.get("Section", "IntItem")

  # Get a list of sections that start with the same thing
  for section in config.sections():
    if section.startswith("Connection"):
        # pull an Item from the current ConnectionX section

if __name__ == "__main__":
    main()

That is pretty much all there is to it.

Now, I assume you already know how to create a module from its String name since you are doing it from MySQL, but here is how I do it from the ini file.

import ConfigParser

config = ConfigParser.ConfigParser(allow_no_value=True)

config.read("config.ini")

sensors = []

for section in config.sections:
  if section.startswith("Sensor"):
    try:
      module_name, class_name = config.get(section, "Class").rsplit(".", 1)
      MyDevice = getattr(importlib.import_module(module_name), class_name)
      sensors.append(MyDevice()) # all the constructor
    except ImportError:
      logger.err("%s.%s is not supported on this platform" % module_name, class_name)

In that above it reads in the ini file and iterates all the sections that start with “Sensor”. For each it gets the module and class name from the “Class:” parameter, creates the class and then instantiates the class, appending it to sensors.

1 Like

thanks! I’ll get through this on the weekend!