Hi,
Is it possible to change sampling rate for script? I have a script (blockly) which detects whether a physical button is pressed and alternatively turns on and off the device. It works but you need to hold the button pressed for half a second to get a reaction, which is annoying.
When I wrote the same logic in external Python scripts, which detects the button and sends a signal via JSON to domoticz, the reaction is without any delay. Is there a solution?
Sampling rate for blockly scripts
Moderator: leecollings
-
- Posts: 20
- Joined: Tuesday 28 August 2018 21:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Sampling rate for blockly scripts
Domoticz Version: 4.9895 running on Raspberry Pi B 3+ (Raspbian). PCF8574 as input and output.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Sampling rate for blockly scripts
What kind of communication is there between the button and domoticz ? RFLink, Zwave, MQTT, other ?Adso76 wrote: ↑Monday 10 December 2018 17:59 Hi,
Is it possible to change sampling rate for script? I have a script (blockly) which detects whether a physical button is pressed and alternatively turns on and off the device. It works but you need to hold the button pressed for half a second to get a reaction, which is annoying.
When I wrote the same logic in external Python scripts, which detects the button and sends a signal via JSON to domoticz, the reaction is without any delay. Is there a solution?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 20
- Joined: Tuesday 28 August 2018 21:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Sampling rate for blockly scripts
The communication is wire
I just connect one of the pins of PCF8574 with GND.

Domoticz Version: 4.9895 running on Raspberry Pi B 3+ (Raspbian). PCF8574 as input and output.
-
- Posts: 20
- Joined: Tuesday 28 August 2018 21:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Sampling rate for blockly scripts
@SweetPants
So how you explain that external Python script, which detects the button and sends a signal via JSON to domoticz works ok (the reaction is without any delay). IMHO, the problem is somewhere within domoticz.
So how you explain that external Python script, which detects the button and sends a signal via JSON to domoticz works ok (the reaction is without any delay). IMHO, the problem is somewhere within domoticz.
Domoticz Version: 4.9895 running on Raspberry Pi B 3+ (Raspbian). PCF8574 as input and output.
Re: Sampling rate for blockly scripts
Without knowing how the Python script looks like, i assume you read the GPIO pin directly without de-bouncing the input. Normally when you connect a switch to a GPIO port, you need to de-bounce the input from generating multiple state changes (search Google for that). Then there is a delay involved.
-
- Posts: 20
- Joined: Tuesday 28 August 2018 21:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Sampling rate for blockly scripts
Code: Select all
PCF8574=0x20
b=smbus.SMBus(1)
b.write_byte(PCF8574, 0xff)
state = 0
pins = b.read_byte(PCF8574)
prev_pin = pins & 0x01
while True:
pins = b.read_byte(PCF8574)
pin = pins & 0x01
if pin == 0 and prev_pin == 1:
if state:
state = 0
httpresponse = urllib.urlopen("http://192.168.1.200:8080/json.htm?type=command¶m=switchlight&idx=20&switchcmd=Off")
time.sleep(0.3)
httpresponse = urllib.urlopen("http://192.168.1.200:8080/json.htm?type=command¶m=switchlight&idx=8&switchcmd=Off")
else:
state = 1
httpresponse = urllib.urlopen("http://192.168.1.200:8080/json.htm?type=command¶m=switchlight&idx=20&switchcmd=On")
time.sleep(0.3)
httpresponse = urllib.urlopen("http://192.168.1.200:8080/json.htm&type=command¶m=switchlight&idx=8&switchcmd=Off")

Domoticz Version: 4.9895 running on Raspberry Pi B 3+ (Raspbian). PCF8574 as input and output.
Who is online
Users browsing this forum: No registered users and 1 guest