Willkommen im Loxone Community Forum. Um alle Funktionen nutzen und sehen zu können, registriere dich bitte zuerst. Dies gilt auch für das herunterladen von Dateien.
I tried searching the German section of this forum, but without any luck. (Bad is an understatement of my knowledge of German!)
Has anybody already tried to read out the status of the GPIO pins of an raspberry pi into Loxone?
I want to use a raspberry pi in my cabin in my garden to arrange the lights and music. I want to control the lights via a physical button on the pi, but I also want to put the lights to off with the all off button in my house.
Yes, I'm using this to forward information from 1-wire sensors that are directly connected to the raspberry pi to the MS. On the raspberry you need something like (example with python code):
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import socket
import RPi.GPIO as GPIO
# use RPi.GPIO Layout (same as pin numbers)
GPIO.setmode(GPIO.BOARD)
# use pin 29 (BCM_GPIO 5) as output
GPIO.setup(29, GPIO.OUT)
# use pin 37 (BCM_GPIO 26) as input
GPIO.setup(37, GPIO.IN)
# IP address and UDP port of Loxone Miniserver
MINISERVER_IP = "192.168.1.10"
UDP_PORT = 7700
# create UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
... other init stuff
while True:
# main loop
...
# the following command sends out the variable temp_c that contains a temperature value to the MS
sock.sendto( "<ID=Sensor1 Value=" + str( temp_c ) + " >", ( MINISERVER_IP, UDP_PORT ) )
# turn out a LED (connected to GPIO pin on the raspi)
GPIO.output(29, GPIO.LOW)
if GPIO.input(37) == GPIO.HIGH:
sock.sendto( "<ID=Reed1 Value=1 >", ( MINISERVER_IP, UDP_PORT ) )
else:
sock.sendto( "<ID=Reed1 Value=0 >", ( MINISERVER_IP, UDP_PORT ) )
time.sleep(0.1)
On the MS you need a virtual UDP input with the same port as on the pi side and underneath a virtual UDP input command with e.g. <ID=Sensor1 Value=\v
or <ID=Reed1 Value=\v
Even if you only need digital inputs e.g. 0 and 1, it might be better to configure the virtual UDP input as analog and get the value with \v than to use a digital input. In this case the virtual input stays on "1" until a "0" is received.
Digital inputs would only trigger a short impulse if a string like <ID=button1> is received. They don't have a value that you can/need to read. The virtual UDP input command that is used on the MS as a virtual input does not stay on a value like 1. In case of a button that is pushed on the pi it may work, of course.
This is just an example that I've put together from two python scripts I am using (hopefully without a syntax error). So far I only need to send information to the MS, but not the other way around. There are a couple of other threads in this forum (try google translate for e.g. https://www.loxforum.com/forum/faqs-...nden#post43610 . Even if the translation might not be that good, the code example and screenshots should help.
Cheers,
Jan
Miniserver v14.5.12.7, 2x Ext., 2x Relay Ext., 2x Dimmer Ext., DMX Ext., 1-Wire Ext., Gira KNX Tastsensor 3 Komfort, Gira KNX Präsenzmelder, Fenster- und Türkontakte, Loxone Regen- und Windsensor, Gira Dual Q Rauchmelder vernetzt, 1x Relais-Modul Loxberry: SmartMeter, MS Backup, CamConnect, Weather4Lox Lüftung: Helios KWL EC 370W ET mit Modbus TCP - via Pico-C Heizung: Stiebel Eltron WPF 5 cool (Sole-Wasser WP) mit ISG, FB-Heizung mit 18 Kreisen, Erdsonde - via modbus/TCP Node-RED: IKEA Tradfri
Well, you should do some (online) python training to get more familiar with that programming language and the socket interface. Im not the expert on this matter, but if I read the explanation of ".bind" (see https://docs.python.org/2/library/so....socket.bind):
Bind the socket to address. The socket must not already be bound...
In your code the ".bind" is in the RecvUdp function that is called multiple times - that is not allowed, because the socket is already bound to the IP address. You should move the sock.bind command out of the RecvUdp function and move it to the line after the socket.socket command.
Miniserver v14.5.12.7, 2x Ext., 2x Relay Ext., 2x Dimmer Ext., DMX Ext., 1-Wire Ext., Gira KNX Tastsensor 3 Komfort, Gira KNX Präsenzmelder, Fenster- und Türkontakte, Loxone Regen- und Windsensor, Gira Dual Q Rauchmelder vernetzt, 1x Relais-Modul Loxberry: SmartMeter, MS Backup, CamConnect, Weather4Lox Lüftung: Helios KWL EC 370W ET mit Modbus TCP - via Pico-C Heizung: Stiebel Eltron WPF 5 cool (Sole-Wasser WP) mit ISG, FB-Heizung mit 18 Kreisen, Erdsonde - via modbus/TCP Node-RED: IKEA Tradfri
Wir verarbeiten personenbezogene Daten über Nutzer unserer Website mithilfe von Cookies und anderen Technologien, um unsere Dienste bereitzustellen, Werbung zu personalisieren und Websiteaktivitäten zu analysieren. Wir können bestimmte Informationen über unsere Nutzer mit unseren Werbe- und Analysepartnern teilen. Weitere Einzelheiten finden Sie in unserer Datenschutzrichtlinie.
Wenn Sie unten auf "Einverstanden" klicken, stimmen Sie unserer Datenschutzrichtlinie und unseren Datenverarbeitungs- und Cookie-Praktiken wie dort beschrieben zu. Sie erkennen außerdem an, dass dieses Forum möglicherweise außerhalb Ihres Landes gehostet wird und Sie der Erhebung, Speicherung und Verarbeitung Ihrer Daten in dem Land, in dem dieses Forum gehostet wird, zustimmen.
Kommentar