Ankündigung

Einklappen
Keine Ankündigung bisher.

HomeMatic Plugin fuer SmartHome.py

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    HomeMatic Plugin fuer SmartHome.py

    Hallo zusammen,

    Ich würde gerne bei ein paar Heizkörpern im Keller HomeMatic 105155 Funk-Stellantriebe in mein (KNX-)Bussystem einbinden. Dazu würde ich gerne SmartHome.py als Uebersetzter nehmen. Allerdings habe ich fuer HomeMatic kein Plugin gefunden. Gibt's da was?

    Ansonsten könnte ich auch noch FHEM nur zu diesem Zweck parallel zu SmartHome laufen lassen, möchte ich aber gerne vermeiden.

    Danke schonmal!
    //giase

    #2
    Hallo,

    mir ist kein Plugin bekannt. Vllt. hat aber schon jemand eines geschrieben???

    Bis bald

    Marcus

    Kommentar


      #3
      Hallo,

      ich hab da vor ewigen Zeiten mal was gebaut. Es hat soweit ich mich erinnere funktioniert. Allerdings ist das PlugIn sicher nicht optimal. War eine meiner ersten Spielereien mit SH.py. Außerdem kann es sein, dass es noch nicht auf die aktuelle Version von SH.py angepasst ist.

      Ich habe den Linux-Daemon von Homematic in Verbindung mit dem LAN-Interface benutzt. Das PlugIn kommuniziert dann über XMLRPC mit dem Daemon. Bisher waren nur Rollos und Schalter fertig. Heizungsregler sind nicht berücksichtigt, sollte aber ähnlich sein, wie die Rollos.

      Vielleicht hilft es ja jemandem weiter. Ich kann dazu nichts weiter tun, weil ich endlich aus der Mietwohnung raus bin und diesen "Funk-Mist" nicht mehr brauche (und auch kein Homematic mehr habe). Aber zum löschen ist es dann doch zu schade.

      Item-Beispiel Beleuchtung:

      Code:
          [[deckenlicht_sofa]]
              name = Deckenlicht Sofa
              visu = yes
              type = bool
              hm_address = JEQ0017982
              hm_type = switch
      Item-Beispiel Beschattung:

      Code:
          [[rollo_links]]
              name = Rollo links
              visu = yes
              hm_address = JEQ0018346
              hm_type = shutter
              [[[move]]]
                  type = num
                  visu = yes
                  hm_address = JEQ0018346
                  hm_type = move
              [[[stop]]]
                  type = num
                  visu = yes
                  hm_address = JEQ0018346
                  hm_type = stop
              [[[pos]]]
                  type = num
                  visu = yes
                  hm_address = JEQ0018346
                  hm_type = pos
      plugins.conf:

      Code:
      #[homematic]
      #    class_name = Homematic
      #    class_path = plugins.homematic
      #    host = 192.168.50.250
      #    port = 2001
      Viele Grüße,

      David
      Angehängte Dateien

      Kommentar


        #4
        Ich wurde angeschrieben, dass der Download von dem Anhang oben wohl wieder mal Ärger macht. Aber bevor ich es jetzt per Mail verteile, hier einfach mal der Inhalt des PlugIns:

        Code:
        #!/usr/bin/env python
        # vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab
        #########################################################################
        # Copyright 2013 KNX-User-Forum e.V.            https://knx-user-forum.de/
        #########################################################################
        #  This file is part of SmartHome.py.   http://smarthome.sourceforge.net/
        #
        #  SmartHome.py is free software: you can redistribute it and/or modify
        #  it under the terms of the GNU General Public License as published by
        #  the Free Software Foundation, either version 3 of the License, or
        #  (at your option) any later version.
        #
        #  SmartHome.py is distributed in the hope that it will be useful,
        #  but WITHOUT ANY WARRANTY; without even the implied warranty of
        #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        #  GNU General Public License for more details.
        #
        #  You should have received a copy of the GNU General Public License
        #  along with SmartHome.py. If not, see <http://www.gnu.org/licenses/>.
        #########################################################################
        
        import logging
        import sys
        import xmlrpclib
        
        logger = logging.getLogger('')
        
        class Homematic():
        
            def __init__(self, smarthome, host='0.0.0.0', port='2001'):
                self.sh = smarthome
                self.host = host
                self.port = port
                self.korrektur = 0
            
            def run(self):
                server_url = 'http://' + self.host + ':' + self.port + '/'
                self.server = xmlrpclib.Server(server_url)
                self.load_status()
                self.alive = True
        
            def load_status(self):
                for hm_devices in self.sh.find_items('hm_type'):
                    if hm_devices.conf['hm_type'] == 'pos':
                        try:
                            result = self.server.getValue(hm_devices.conf['hm_address'] + ':1', 'LEVEL')
                            value = 1 - float(result)
                            hm_devices(int(255 * float(value)))
                        except Exception, e:
                            logger.error("Could not connect to Homematic Device: " + hm_devices.conf['hm_address'])
                    elif hm_devices.conf['hm_type'] == 'switch':
                        try:
                            result = self.server.getValue(hm_devices.conf['hm_address'] + ':1', 'STATE')
                            hm_devices(bool(result))
                        except Exception, e:
                            logger.error("Could not connect to Homematic Device: " + hm_devices.conf['hm_address'])
                    elif hm_devices.conf['hm_type'] == '2ch_switch':
                        try:
                            result = self.server.getValue(hm_devices.conf['hm_address'] + ':' + hm_devices.conf['hm_channel'], 'STATE')
                            hm_devices(bool(result))
                        except Exception, e:
                            logger.error("Could not connect to Homematic Device: " + hm_devices.conf['hm_address'])
        
            def stop(self):
                self.alive = False
        
            def parse_item(self, item):
                if 'hm_address' in item.conf:
                    logger.debug("parse item: {0}".format(item))
                    return self.update_item
                else:
                    return None
        
            def update_item(self, item, caller=None, source=None, dest=None):
                if caller != 'Homematic':
                    if item.conf['hm_type'] == 'pos':
                        new_value = float(item()) / 255
                        conv_value = 1 - float(new_value)
                        try:
                            result = self.server.setValue(item.conf['hm_address'] + ':1', 'LEVEL', str(conv_value)) 
                            logger.debug('Homematic: Rollo auf ' + str(conv_value))
                        except Exception, e:
                            logger.error("Could not connect to Homematic Device: ".format(e))
                    elif item.conf['hm_type'] == 'stop':
                        item(0)
                        try:
                            result = self.server.setValue(item.conf['hm_address'] + ':1', 'STOP', bool('true'))
                            result2 = self.server.getValue(item.conf['hm_address'] + ':1', 'LEVEL')
                            for shutter_items in self.sh.find_items('hm_type'):
                                if shutter_items.conf['hm_type'] == 'pos':
                                    if shutter_items.conf['hm_address'] == item.conf['hm_address']:
                                        akt_value = 1 - float(result2)
                                        shutter_items(int(255 * float(akt_value)))
                            logger.debug('Homematic: Rollo stop...')
                        except Exception, e:
                            logger.error("Could not connect to Homematic Device: ".format(e))
                    elif item.conf['hm_type'] == 'move':
                        direction = item()
                        item(2)
                        if direction == 0:
                            try:
                                result = self.server.setValue(item.conf['hm_address'] + ':1', 'LEVEL', '1')
                            except Exception, e:
                                logger.error("Could not connect to Homematic Device: ".format(e))
                        elif direction == 1:
                            try:
                                result = self.server.setValue(item.conf['hm_address'] + ':1', 'LEVEL', '0') 
                                result2 = self.server.getValue(item.conf['hm_address'] + ':1', 'LEVEL')
                            except Exception, e:
                                logger.error("Could not connect to Homematic Device: ".format(e))
                            for shutter_items in self.sh.find_items('hm_type'):
                                if shutter_items.conf['hm_type'] == 'pos':
                                    if shutter_items.conf['hm_address'] == item.conf['hm_address']:
                                        akt_value = 1 - float(result2)
                                        shutter_items(int(255 * float(akt_value)))
                    elif item.conf['hm_type'] == 'switch':
                        try:
                            result = self.server.setValue(item.conf['hm_address'] + ':1', 'STATE', item())
                        except Exception, e:
                            logger.error("Could not connect to Homematic Device: ".format(e))
                    elif item.conf['hm_type'] == '2ch_switch':
                        try:
                            result = self.server.setValue(item.conf['hm_address'] + ':' + item.conf['hm_channel'], 'STATE', item()) 
                        except Exception, e:
                            logger.error("Could not connect to Homematic Device: ".format(e))
                            
        if __name__ == '__main__':
            logging.basicConfig(level=logging.DEBUG)
            myplugin = Plugin('homematic')
            myplugin.run()
        Viele Grüße,

        David

        Kommentar


          #5
          Vielen Dank! Ich kucke mir das bei Gelegenheit mal an und melde mich!

          Kommentar


            #6
            Hi,
            das Plugin läuft so nicht mit smarthome.py oder smarthomeNG, allein die Python Version verursacht Fehler.
            Ich werde es ins Repository aufnehmen und dann umbauen. Wäre gut wenn das dann jemand testet, der die Hardware auch hat.


            Gruß
            Christian

            Kommentar


              #7
              so, das Plugin ist im develop branch, kann von dort aus in den master branch zum testen kopiert werden.
              Kann das bitte jemand testen der die entsprechende Hardware hat und hier berrichten.
              Danke.

              Kommentar


                #8
                Hi,

                Ich bin momentan leider sehr unter Wasser mit anderen Dingen (Kinder...), werde aber berichten wenn ich dazu komme.

                //giase

                Kommentar


                  #9
                  Hallo cmalo,

                  ich kann das im develop branch nicht finden (https://github.com/mknx/smarthome/tree/develop/plugins)
                  oder bin ich da falsch?

                  Kommentar


                    #10
                    Hallo ChrisW,

                    ja, ich glaube du bist (warst) falsch: https://github.com/smarthomeNG/smart...master/plugins

                    Daniel

                    Kommentar


                      #11
                      Hallo zusammen,

                      momentan versuche ich das HM-CFG-LAN unter SmartHomeNG zum laufen zu bekommen, leider ohne Erfolg. Ich bekommen lediglich "ERROR Main Could not connect to Homematic Device:".

                      Gibt es inzwischen neuere Infos?

                      Viele Grüße
                      Karsten

                      Kommentar

                      Lädt...
                      X