Ankündigung

Einklappen
Keine Ankündigung bisher.

Switch light on when UDP command received from PC

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

    [Handbuch] Switch light on when UDP command received from PC

    I saw in the user manual the following regarding receiving UDP commands from a PC in EIBPC:

    Code:
    Port=0u16
    IP=0u32
    Data1=0;Data2=0;Data3=0
    telegram=event(readudp(Port, IP,Data1,Data2,Data3))
    if (Port==2243u16) and (IP==122.32.22.1) and telegram then \\
    write('3/4/0'u08,Data1); \\
    write('3/4/1'u08,Data2); \\
    write('3/4/2'u08,Data3) \\
    endif
    I would like to send an UDP command "light_on" from my PC and have EIBPC, upon receipt, switch on a light.

    Could I do this by doing the following (assuming IP and port number and Group Address for the mentioned light are correct for my situation):

    Code:
    Port=0u16
    IP=0u32
    Data1=light_on
    telegram=event(readudp(Port, IP,Data1))
    if (Port==2243u16) and (IP==122.32.22.1) and telegram then \\
    write('3/4/0'u08,"EIN"); \\
    endif
    Thanks,
    Perry

    #2
    Zitat von Perry Beitrag anzeigen
    Could I do this by doing the following (assuming IP and port number and Group Address for the mentioned light are correct for my situation):
    This should work.
    EDIT: You could send a message in the UDP to detemine which light you want to switch.
    offizielles Supportforum für den Enertex® EibPC: https://knx-user-forum.de/eibpc/
    Enertex Produkte kaufen

    Kommentar


      #3
      Thanks, buth, no, now you have made me curious!

      I thought that it would be necessary to tell EIBPC beforehand on what UDP command trigger it should act by telling it Data1=light_on.
      Now you are saying I could send different GA's as payload in the UDP command and have EIBPC use those to activate different lights?

      How should I do this and how would EIBPC ignore other UDP commands that are sent (i.e. ones that do not have the GA's in the payload)?
      Or should I use separate ports for each of those 'switch light' UDP commands?

      Kommentar


        #4
        Perry,

        try out the following then:

        [highlight=epc]

        MyIP = 192.168.10.12
        MyPort = 2243u16
        MySwitch1 = $GardenLight$
        MySwitch2 = $LivingRoomLight$

        // Send an UDP paket from PC with either string "GardenLight" or "LivingRoomLight" to switch the light...

        Port=0u16
        IP=0u32
        Data=$$
        telegram=event(readudp(Port, IP,Data))

        if (Port==MyPort ) and (IP==MyIP) and telegram and Data == MySwitch1 then {
        write('3/4/0'b01,EIN); /* Garden Light on */;
        } endif

        if (Port==MyPort ) and (IP==MyIP) and telegram and Data == MySwitch2 then {
        write('3/4/1'b01,EIN); /* Living Room Light on */;
        } endif

        [/highlight]

        Regards,
        Bernd

        Kommentar


          #5
          you could also make use of address(), e.g. if you send the Groupaddress and the type to send. With that you will have full controll over the groupadresses.
          See in manual address(), gaimage(),
          offizielles Supportforum für den Enertex® EibPC: https://knx-user-forum.de/eibpc/
          Enertex Produkte kaufen

          Kommentar


            #6
            Hi enertegus,

            I think Perry just looks for a very simple way. He already has my UDP remote control macro from the Remanent Variables (Download area) but it looks as if he just does not want the big solution right now until he understands what's going on there

            Regards,
            Bernd

            Kommentar


              #7
              Thanks guys!

              I will be testing this out at some point (probably next weekend).

              Bernd is quite right: I never learned programming professionally, so everything I do must meet KISSS standards (Keep it super simple, stupid), so I can see what is going on step by step. With the aid of Bernd's macro I am now able to send commands to my always-on PC to switch on and off my logitech squeezeboxes and amplifiers from several different light switches. Each time I learn something that works out, my confidence is growing until I can take the next step. This method has got me from knowing nothing about computers to knowing just enough about Python and KNX to achieve interesting results while keeping me curious enough to long for more and better solutions.
              I am afraid that if I take big leaps, I will not understand, mess up and get frustrated.
              Therefore I am grateful that you guys are willing to share your knowledge with me in layman's terms.

              Best regards,
              Perry

              Kommentar


                #8
                I'm interested too in send udp packets to knx, but i'm very very new to Eibpc. Basically, i need to send a command from PC to Eibpc, by passing to Eibpc 2 parameters: the GroupAddress and the Value to send to Knx in format groupaddress=value.

                Is there a way to do something like this?
                Code:
                IP=0u32
                Rx=$$ // Received Command, for example 0/0/1=1
                
                telegram=event(readudp(Port, IP, Rx));
                GA=split(Rx,0u16,find(Rx,$=$,0u16)-1u16); // is 0/0/1
                Value=split(Rx,find(Rx,$=$,0u16),1399u16); // is 1
                
                if (Port==2243u16) and (IP==122.32.22.1) and telegram then \\
                write(GA,Value); \\
                endif
                Thanks.

                Kommentar


                  #9
                  Hi Massimo,

                  have a look at BMXRemanent8 in download area.

                  Regards,
                  Bernd

                  Kommentar


                    #10
                    Zitat von TheMax74 Beitrag anzeigen
                    Is there a way to do something like this?
                    almost. Try:
                    [highlight=epc]
                    IP=0u32
                    Port=0u16
                    Rx=$$ // Received Command, for example 0/0/1=1
                    telegram=event(readudp(Port, IP, Rx));
                    // Group address send as 16-Bit Number
                    GA_Nr=convert(split(Rx,0u16,find(Rx,$=$,0u16)-1u16), 0u16);
                    // Must fit the GA Type, e.g. 8 Bit:
                    Value=convert(split(Rx,find(Rx,$=$,0u16),1399u16), 0u08)

                    if (Port==2243u16) and (IP==122.32.22.1) and telegram then {
                    write(address(GA_Nr),Value)
                    }endif[/highlight]
                    offizielles Supportforum für den Enertex® EibPC: https://knx-user-forum.de/eibpc/
                    Enertex Produkte kaufen

                    Kommentar


                      #11
                      Understood.
                      Many thanks.

                      Kommentar


                        #12
                        Zitat von TheMax74 Beitrag anzeigen
                        Understood.
                        Many thanks.
                        See Section "KNX-Telegramm-Routing", starting from page 186 in the (English, German page might be slightly different) manual.
                        You can initiate a telegram-read with Readknx(), you can read the current image of an GA with Gaimage().
                        offizielles Supportforum für den Enertex® EibPC: https://knx-user-forum.de/eibpc/
                        Enertex Produkte kaufen

                        Kommentar


                          #13
                          I have been unable to get the UDP communication from PC to EIBPC to work.
                          I am also a bit confused about the ports to be used. The manual says the EIBPC listens exclusively to 4806, yet none of the UDP sending examples in the manual (and on this website) include 4806 in them.

                          Anyway, I have been trying to enter all sorts of port numbers in the UDP broadcasting plugin of Eventghost, but none of it works.
                          I will try to find some UDP sniffer to see if the UDP messages are in fact being sent properly.

                          Kommentar


                            #14
                            Just an update: I can confirm that EIBPC receives UDP messages from my sending PC, as I managed to switch on a light when sending command 'test' from the UDP plugin on the PC to port 4806 and using the following test'code' under the EibPC section:

                            Port=0u16
                            IP=0u32
                            Data1=0
                            telegram=event(readudp(Port, IP,Data1))
                            if (IP==192.168.1.40) and telegram then \\
                            write('2/2/0'b01,ON)\\
                            endif

                            However, as soon as I add a conditional port in the "if .." section, it no longer reacts.

                            Kommentar


                              #15
                              Zitat von Perry Beitrag anzeigen
                              However, as soon as I add a conditional port in the "if .." section, it no longer reacts.
                              What exactly do you mean?
                              offizielles Supportforum für den Enertex® EibPC: https://knx-user-forum.de/eibpc/
                              Enertex Produkte kaufen

                              Kommentar

                              Lädt...
                              X