python script to issue GPIO command

Moderators: Voyager, BertB, grovkillen, Stuntteam, LisaM

Post Reply
Normal user
Posts: 8
Joined: 05 May 2019, 01:15

python script to issue GPIO command

#1 Post by HvdW » 12 May 2019, 13:07

Everything is running on my RPI.
I am using Domoticz to swith our boiler.
In Domoticz the command is:

Code: Select all

# Domoticz command is,5,0
I want to implement this command in Python from my RPI.

Code: Select all

import requests

url = ''
query = {'cmd': 'GPIO,5,0'}
res =, data=query)
This results in:

Code: Select all

<script language="javascript"><!--
function dept_onchange(frmselect) {frmselect.submit();}
//--></script><head><title>Strampke_02</title><style>* {font-family:sans-serif; font-size:12pt;}h1 {font-size:16pt; color:black;}h6 {font-size:10pt; color:black; text-align:center;}.button-menu {background-color:#ffffff; color:blue; margin: 10px; text-decoration:none}.button-link {padding:5px 15px; background-color:#0077dd; color:#fff; border:solid 1px #fff; text-decoration:none}.button-menu:hover {background:#ddddff;}.button-link:hover {background:#369;}th {padding:10px; background-color:black; color:#ffffff;}td {padding:7px;}table {color:black;}.div_l {float: left;}.div_r {float: right; margin: 2px; padding: 1px 10px; border-radius: 7px; background-color:#080; color:white;}.div_br {clear: both;}</style></head><h1>Welcome to ESP Easy: Strampke_02</h1><BR><a class="button-menu" href=".">Main</a><a class="button-menu" href="config">Config</a><a class="button-menu" href="hardware">Hardware</a><a class="button-menu" href="devices">Devices</a><a class="button-menu" href="tools">Tools</a><BR><BR>
Unknown command!<form><table><TH>System Info<TH><TH><TR><TD>Load:<TD>4% (LC=34480)<TR><TD>Uptime:<TD>2505 minutes<TR><TD>Wifi RSSI:<TD>-73 dB<TR><TD>IP:<TD><TR><TD>GW:<TD><TR><TD>Build:<TD>120<TR><TD>Core Version:<TD>2_3_0<TR><TD>Unit:<TD>2<TR><TD>STA MAC:<TD>dc:4f:22:18:09:98<TR><TD>AP MAC:<TD>de:4f:22:18:09:98<TR><TD>ESP Chip ID:<TD>1575320<TR><TD>Flash Chip ID:<TD>1458208<TR><TD>Flash Size:<TD>4096 kB<TR><TD>Sketch Size/Free:<TD>401 kB / 620 kB<TR><TD>Free Mem:<TD>27808<TR><TD>Boot cause:<TD>Cold boot<TR><TH>Node List:<TH>IP<TH>Age<TR><TD><TD></table></form><h6>Powered by</h6></body>
It must be simple to change the code in a way that it works.
At the moment that is beyond my scope.
Help appreciated.

User avatar
Normal user
Posts: 576
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary

Re: python script to issue GPIO command

#2 Post by enesbcs » 15 May 2019, 22:44

HvdW wrote: 12 May 2019, 13:07 I want to implement this command in Python from my RPI.
If you want to control your Raspberry with ESPEasy-like commands why don't you simply use RPIEasy? (with ESPEasy P2P networking it is able to use udp SendTo commands for remote espeasy control for example..)

If this is not what you want, you may consider using something like this from python:

Code: Select all

import urllib.request

Normal user
Posts: 8
Joined: 05 May 2019, 01:15

Re: python script to issue GPIO command

#3 Post by HvdW » 17 May 2019, 00:31

Thanks @enesbcs
RPIEasy looks great.
I'll shurely try it one of these days.

For now I'll gor for the urllib.request command
My ESP8266 with ESPEasy on it needs the command to switch a switch, that's all.
I wasn't able to find the proper code.
Thanks for helping out.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest