Ankündigung

Einklappen
Keine Ankündigung bisher.

- √ - Executing Logic functions?

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

    - √ - Executing Logic functions?

    Hello folks...
    I've read the SmartHome.py ? SmartHome.py 1.0 documentation about configuration and logic, but i think i need to get answer on the following

    Finally my eibd daemon came alive on my PI, and i've installed the smarthome.py - now i'm just trying to understand some things about the programming:

    I'm use to program PLC's, where they scan the code all times. How does the smarthome.py handle this? Is it event driven, or do i have to call them all the time?

    Could someone please give me a little example, could be i have a Setpoint and a Actual temperature, if Setpoint is greater than actual value it turns on a bit =1? and make it evaluate everytime a new actual temperature is received from bus?

    Also a little explanation on "Item Functions"

    Thanks

    #2
    Items are the hirarchical structured values in your installation. Each item can be assigned with attributes so that the various plugins know, if they should hook to this item and how. For example the KNX plugin reads the knx_dpt attribute to do the mapping between KNX and the item value and knx_listen sets the group address to listen for. Plugins and logics can register themselfs to get notified when an item has changed. This is the event driven approach. But plugins and logics can also be invoked on a cyclic base.

    Logics can be defined in the etc/logics.py file with watch_item, which is the item hook for the event driven call of the logic, or with cycle, which is the recurring invocation of the corresponding logic.

    hth
    Mit freundlichen Grüßen
    Niko Will

    Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
    - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

    Kommentar


      #3
      Zitat von 2ndsky Beitrag anzeigen
      Items are the hirarchical structured values in your installation. Each item can be assigned with attributes so that the various plugins know, if they should hook to this item and how. For example the KNX plugin reads the knx_dpt attribute to do the mapping between KNX and the item value and knx_listen sets the group address to listen for. Plugins and logics can register themselfs to get notified when an item has changed. This is the event driven approach. But plugins and logics can also be invoked on a cyclic base.

      Logics can be defined in the etc/logics.py file with watch_item, which is the item hook for the event driven call of the logic, or with cycle, which is the recurring invocation of the corresponding logic.

      hth
      Okay.. That makes great sence in my world Then the most of the programming must be done in watch_item, i think that's often the best solution..

      What about the Item configuration then? I'm a bit insecure in how that function works....
      Maybe you could post a real example on how to make that file?

      Kommentar


        #4
        Did you have a look at the docu? Configuration ? SmartHome.py 1.0 documentation
        Mit freundlichen Grüßen
        Niko Will

        Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
        - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

        Kommentar


          #5
          Zitat von 2ndsky Beitrag anzeigen
          Did you have a look at the docu? Configuration ? SmartHome.py 1.0 documentation
          Yes i did.... but i got a bit confused, there's example.conf, level.conf, room.conf..
          If i make an item [DoorBell] - Will i then be able to use [DoorBell] in the logics, and then it knows all the specs about this? Like a kind of symbol list

          I will try and read it all again, and see if i can get the "big overview"

          Kommentar


            #6
            Like the docu says, every *.conf file in the items folder is parsed and added to the sh tree. If you have this door bell item in one of your *.conf files than you can use it as a trigger for the logics with watch_item = DoorBell and in the logics access it via sh like sh.DoorBell() or set the value with sh.DoorBell(True). If you have a nested item like

            Code:
            [GroundFloor]
                [[DoorBell]]
            then you access it via sh.GroundFloor.DoorBell() and use it with watch_item = GroundFloor.DoorBell to trigger logics.
            Mit freundlichen Grüßen
            Niko Will

            Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
            - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

            Kommentar


              #7
              Zitat von 2ndsky Beitrag anzeigen
              Like the docu says, every *.conf file in the items folder is parsed and added to the sh tree. If you have this door bell item in one of your *.conf files than you can use it as a trigger for the logics with watch_item = DoorBell and in the logics access it via sh like sh.DoorBell() or set the value with sh.DoorBell(True). If you have a nested item like

              Code:
              [GroundFloor]
                  [[DoorBell]]
              then you access it via sh.GroundFloor.DoorBell() and use it with watch_item = GroundFloor.DoorBell to trigger logics.
              Okay.. that makes sense, then it would be like this in the logical:

              Code:
              # put on the buzzer while doorbell =1
              if sh.Groundfloor.Doorbell():
                  sh.Groundfloor.Buzzer('on')
              And in the items i must define the following: (ofcourse with all the relevant KNX address and Data Type)
              Code:
              [Groundfloor]
              [[Doorbell]]
              [[Buzzer]]
              And then again under logic.conf i must have
              Code:
              filename = doorbell.py
              watch_item = Groundfloor.Doorbell
              am i correct?

              Kommentar


                #8
                Looks good so far. Only one thing, you have to define a name for your logic in the logic.conf as well:

                Code:
                [doorbell]
                    filename = doorbell.py
                    watch_item = Groundfloor.Doorbell
                Mit freundlichen Grüßen
                Niko Will

                Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
                - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

                Kommentar


                  #9
                  Zitat von 2ndsky Beitrag anzeigen
                  Looks good so far. Only one thing, you have to define a name for your logic in the logic.conf as well:

                  Code:
                  [doorbell]
                      filename = doorbell.py
                      watch_item = Groundfloor.Doorbell
                  Heh i noticed that, and changed it in my post, at the same time you were writing

                  When the eibd is running and communicating, would it then be enough to create the KNX parameters on the items path, and then when i call sh.living_room.light('on') it will send an ON signal at group address 1/1/3 according to the example below:
                  Like:
                  Code:
                  [living_room]
                      [[light]]
                          type = bool
                          knx_dpt = 1
                          knx_send = 1/1/3
                          knx_listen = 1/1/4 | 1/1/5
                          knx_init = 1/1/4

                  Kommentar

                  Lädt...
                  X