Ankündigung

Einklappen

Serverwartung 21.2.



Am 21.2. im Laufe des späten Abends wird eine Serverwartung durchgeführt. Das Forum ist dadurch für gut zwei Stunden nicht erreichbar.
Es wird eine Wartungsseite geschaltet.

Mehr anzeigen
Weniger anzeigen

NMA plugin, help

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

    NMA plugin, help

    Hi,

    I've configured my smarthome.py to use NMA plugin with global api-key. I got the push notification working by creating a logic for the item i wanted. But I was wondering if it is possible to trigger the logic only when the value of the watched Item is '1' ? My example is that I'm using KNX_listen = 1/0/0, and that would trigger my logic at any change of the item, but I only want to have a NMA push message when the Item is Set ('1'). ALSO, would it be possible to put the sh.nma-string directly in the items.py under the object you want push messages from?
    Any help would be truly appreciated.

    Best regards
    Christian



    #2
    just use If within your logic file.

    Code:
    if sh.your.item() == 1:
       sh.nma('Header', 'your notification text')
    kind regards
    markus

    Kommentar


      #3
      Thank you for helping me out, Markus!
      I tried using your description above, but my smarthome.py log returned: Exeption: ivalid token line1.
      Here's my nma.py file (logic file)

      if sh.1etg.gang.utelys.switching() == 1
      sh.nma('Utelys', 'Utelys ON', 2, 'http://10.0.0.49/smartvisu/')

      Kommentar


        #4
        ==1: : is missing in the end!

        Kommentar


          #5
          2016-07-19 18:44:21 ERROR Main Exception: invalid token (nma.py, line 1)
          Traceback (most recent call last):
          File "/usr/smarthome/lib/logic.py", line 119, in generate_bytecode
          self.bytecode = compile(code, self.filename, 'exec')
          File "/usr/smarthome/logics/nma.py", line 1
          if sh.1etg.gang.utelys.switching() == 1:
          ^
          SyntaxError: invalid token

          Kommentar


            #6
            You ran into a very nasty bug (which is fixed as of SmartHomeNG 1.2): You should never start an item name with a digit. name your item not 1etg but etg1 instead. That should work...

            Kommentar


              #7
              Thank you guys! I have now come 1 step further But now i get this message:
              Exception: expected an indented block (nma.py, line 2)

              Kommentar


                #8
                did u use 4 spaces indent at the places where you need to - e.g. after an "if" phrase?

                Kommentar


                  #9
                  This is the exact copy of my logic.py:
                  if sh.ute.utelys.switching() == 1:
                  sh.nma('Lights', 'Utelys ON', 2, 'http://10.0.0.49/smartvisu/')

                  Kommentar


                    #10
                    The line after if ... : needs to be indented. Normally it would be indented by 4 spaces. Thus your code would look like this:
                    Code:
                    if sh.ute.utelys.switching() == 1:
                        sh.nma('Lights', 'Utelys ON', 2, 'http://10.0.0.49/smartvisu/')

                    Kommentar

                    Lädt...
                    X