Python Plugin: GPIO SYSFS Switches

Python and python framework

Moderator: leecollings

Post Reply
blauwebuis
Posts: 331
Joined: Wednesday 21 December 2016 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: current
Contact:

Python Plugin: GPIO SYSFS Switches

Post by blauwebuis »

This plugin automatically creates switches for GPIO pins.

- You can input a list of pins
- The plugin creates a switch for every pin.
- It exports every pin and sets its direction to output (using shell commands).

If you toggle the switch, the pins will also be toggled.

More details on the wiki: https://www.domoticz.com/wiki/Plugins/G ... S-Switches
rickiewickie
Posts: 6
Joined: Sunday 28 January 2018 12:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: GPIO SYSFS Switches

Post by rickiewickie »

Thanks and great work! I will test it this weekend :)
arjenw
Posts: 9
Joined: Thursday 16 January 2014 8:54
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Python Plugin: GPIO SYSFS Switches

Post by arjenw »

@BlauweBuis.
First of all thanks for the effort for writing this script.
At the moment i'm trying to get a Anavi Flex HAT (RabbitMax Flex) working.
http://anavi.technology/#products

The HAT uses GPIO 29 for a relais/switch.
Programming is not my daily skill so could you give an example of putting in th GPIO 29 in your plugin.py script?

Is Domoticz picking the script by itself or do I have to run in before starting Domoticz?
While running plugin.py tells me there is an error on line 18, Import domoticz

Thanks for reply in advance.

with regards
Arjen
blauwebuis
Posts: 331
Joined: Wednesday 21 December 2016 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: current
Contact:

Re: Python Plugin: GPIO SYSFS Switches

Post by blauwebuis »

@arjenw:

- You install it just like every other plugin.
- You don't have to change the script. You can simply add the desired pin in the Domoticz interface, under hardware.

Please read the documentation.

- Installing a python plugin: https://www.domoticz.com/wiki/Using_Python_plugins
arjenw
Posts: 9
Joined: Thursday 16 January 2014 8:54
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Python Plugin: GPIO SYSFS Switches

Post by arjenw »

@BlauweBuis

Thanks for pointing n the direction of the Wiki for installing plugins.
I followed the directiosn.
Installed Python
rebooted the RPi.
Added the Hardware, but there was no option for putting in a GPIO port.
Do i have to put the file plugin.py in its own directoriy under ./domoticz/plugins/??/plugin.py
See picture 2 for Domoticz log.
The attachment Knipsel1.PNG is no longer available
Log:
2018-02-18 17:17:12.184 Domoticz V3.8923 (c)2012-2018 GizMoCuz
2018-02-18 17:17:12.186 Build Hash: f779742f, Date: 2018-02-18 12:01:14
2018-02-18 17:17:12.189 System: Raspberry Pi
2018-02-18 17:17:12.191 Startup Path: /home/pi/domoticz/
2018-02-18 17:17:12.408 Sunrise: 06:51:00 SunSet: 17:00:00
2018-02-18 17:17:12.408 Day length: 10:09:00 Sun at south: 11:05:00
2018-02-18 17:17:12.408 Civil twilight start: 06:16:00 Civil twilight end: 17:35:00
2018-02-18 17:17:12.408 Nautical twilight start: 05:36:00 Nautical twilight end: 18:14:00
2018-02-18 17:17:12.408 Astronomical twilight start: 04:57:00 Astronomical twilight end: 18:54:00
2018-02-18 17:17:12.409 EventSystem: reset all events...
2018-02-18 17:17:12.441 Active notification Subsystems: (0/14)
2018-02-18 17:17:12.473 WebServer(HTTP) started on address: :: with port 8080
2018-02-18 17:17:12.515 WebServer(SSL) started on address: :: with port 443
2018-02-18 17:17:12.518 Proxymanager started.
2018-02-18 17:17:12.520 Starting shared server on: :::6144
2018-02-18 17:17:12.520 TCPServer: shared server started...
2018-02-18 17:17:12.521 RxQueue: queue worker started...
2018-02-18 17:17:14.538 Sysfs GPIO: Startup - polling:no interrupts:no debounce:50msec inputs:0 outputs:0
2018-02-18 17:57:02.745 Incoming connection from: 192.168.0.112
Attachments
Hardware
Hardware
Knipsel1.PNG (43.77 KiB) Viewed 1625 times
blauwebuis
Posts: 331
Joined: Wednesday 21 December 2016 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: current
Contact:

Re: Python Plugin: GPIO SYSFS Switches

Post by blauwebuis »

Yes, it should be in a directory like that. Something like:

domoticz/plugins/sysfs_switches/plugin.py

You selected the wrong hardware too. It should be "sysfs pins" or "sysfs switches" (I just changed the name of the plugin to make it more recognisable)
arjenw
Posts: 9
Joined: Thursday 16 January 2014 8:54
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Python Plugin: GPIO SYSFS Switches

Post by arjenw »

BlauweBuis,

- Created the filesystem folder /home/pi/domoticz/plugins/sysfs_switches
- Created new file plugin.py with the latest content
<plugin key="SYSFS-Switches" name="SYSFS-Switches" author="blauwebuis" version="0.1.0" wikilink="http://www.domoticz.com/wiki/plugins" externallink="https://html5zombo.com/">
<description>
- made executable plugin.py
- rebooted Raspberry Pi

>> Result: in Domoticz the hardware mentioned is not shown in the list.

Is there a file (location) where i can looking to for debug information regarding this plugin?

regards
Arjen
blauwebuis
Posts: 331
Joined: Wednesday 21 December 2016 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: current
Contact:

Re: Python Plugin: GPIO SYSFS Switches

Post by blauwebuis »

Hey Arjen

In theory you did everything right.

Check your log. Does it mention the plugin system booting?
Are you running the beta?
Do other plugins work?
arjenw
Posts: 9
Joined: Thursday 16 January 2014 8:54
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Python Plugin: GPIO SYSFS Switches

Post by arjenw »

Running latest beta.
Installed additional plugin
There is still no Hardware as described

Do I have to alter any script to load the plugin? For example domoticz.sh?

See Domoticz log below:

2018-02-20 22:14:20.964 Domoticz V3.8926 (c)2012-2018 GizMoCuz
2018-02-20 22:14:20.964 Build Hash: b4a255b9, Date: 2018-02-20 12:01:54
2018-02-20 22:14:20.965 System: Raspberry Pi
2018-02-20 22:14:20.965 Startup Path: /home/pi/domoticz/
2018-02-20 22:14:21.233 Sunrise: 07:47:00 SunSet: 18:04:00
2018-02-20 22:14:21.233 Day length: 10:17:00 Sun at south: 12:05:00
2018-02-20 22:14:21.233 Civil twilight start: 07:12:00 Civil twilight end: 18:38:00
2018-02-20 22:14:21.233 Nautical twilight start: 06:32:00 Nautical twilight end: 19:18:00
2018-02-20 22:14:21.233 Astronomical twilight start: 05:53:00 Astronomical twilight end: 19:57:00
2018-02-20 22:14:21.233 EventSystem: reset all events...
2018-02-20 22:14:21.238 I2C Start HW witf ID: 4 Name: I2C_BME280 Address: 0 Port: Invert:0
2018-02-20 22:14:21.255 Active notification Subsystems: (0/14)
2018-02-20 22:14:21.285 WebServer(HTTP) started on address: :: with port 8080
2018-02-20 22:14:21.327 WebServer(SSL) started on address: :: with port 443
2018-02-20 22:14:21.330 Proxymanager started.
2018-02-20 22:14:21.333 Starting shared server on: :::6144
2018-02-20 22:14:21.333 TCPServer: shared server started...
2018-02-20 22:14:21.334 RxQueue: queue worker started...
2018-02-20 22:14:23.336 I2C_BME280: Worker started...
2018-02-20 22:14:23.337 Hardware Monitor: Started
2018-02-20 22:14:48.364 Incoming connection from: 192.168.0.115
2018-02-20 22:14:59.447 (3) Temp + Humidity + Baro (Temp Hum Baro)
2018-02-20 22:14:59.833 Incoming connection from: 192.168.0.101
2018-02-20 22:15:29.479 (3) Temp + Humidity + Baro (Temp Hum Baro)
2018-02-20 22:15:59.511 (3) Temp + Humidity + Baro (Temp Hum Baro)
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest