Page 1 of 1
Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 9:51
by rick8245
Is is possible to add a script (bash, sh, or python) in Blockly ??
I have a good running python script and I want to embed it into blockly.
Is that possible ? if so How do I do that ??
Thanks in advance .
// Rick
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 11:48
by AllesVanZelf
You could make a dummy switch and trigger the bash script in there from the 'on action' line as: script://run-script.sh and save this script in the domoticz/scripts folder.
I symlink this script files to my own /home/pi/bin/ folder.
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 13:17
by rick8245
Hi AllesvanZelf.
Thanks for your reply
Where do i find the ' On Action' item ?
Is that at Events ??
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 13:24
by Egregius
There's a "start script" action in Blockly. No need for a dummy switch.
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 13:32
by rick8245
Ok I found it.
I have this in the line: python /home/pi/domoticz/scripts/python/hcsr501.py
No further parameters.
Can I see if it works ??
The Domoticz log does not give any messages on this
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:22
by AllesVanZelf
Egregius wrote: Wednesday 29 April 2020 13:24
There's a "start script" action in Blockly. No need for a dummy switch.

Where in Blockly is this start script entry?
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:25
by AllesVanZelf
rick8245 wrote: Wednesday 29 April 2020 13:32
I have this in the line: python /home/pi/domoticz/scripts/python/hcsr501.py
No further parameters.
Can I see if it works ??
The Domoticz log does not give any messages on this
I would put this python command in a bash script, like: hcsr501.sh
Code: Select all
#!/bin/sh
python /home/pi/domoticz/scripts/python/hcsr501.py
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:27
by rick8245
Can i embed pictures inhere?
In the DO of the If DO construction.
I will put the export here.
<xml xmlns="
http://www.w3.org/1999/xhtml"><block type="domoticzcontrols_if" id="qxqq~F1V^#22G~YDf,a6" x="16" y="10"><value name="IF0"><block type="logic_compare" id="aJeFzXRT$j@8lS7/7-H/"><field name="OP">EQ</field><value name="A"><block type="switchvariablesMR" id="Tzo+#Up2HGqdIZ[{yoJO"><field name="Switch">34</field></block></value><value name="B"><block type="logic_states" id="DbIG8h~*%2Z?cU6E[G{;"><field name="State">On</field></block></value></block></value><statement name="DO0"><block type="start_script" id="Fg2T`pJNGo.RylX^h:N)"><field name="TextPath">python /home/pi/domoticz/scripts/python/hcsr501.py > /home/pi/domoticz/scripts/python/hcsrc501.log</field><field name="TextParam"></field></block></statement></block></xml>
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:34
by AllesVanZelf
Ohhh under messages. That is a logical place to put the start script

Never found that one
You can place an image via an external service like:
imgur
then get share link and the BBcode one.
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:37
by rick8245
I cannot find another location with START SCRIPT
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:41
by AllesVanZelf
rick8245 wrote: Wednesday 29 April 2020 13:17
Where do i find the ' On Action' item ?
Is that at Events ??
In the created dummy switch.

Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:52
by rick8245
It looks i have another interfce than you have.
I am running Domoticz on a raspberry.

- dummySwitch.png (17.61 KiB) Viewed 1053 times
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:58
by rick8245
found it
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 14:59
by AllesVanZelf
No it is the same. The page I show is from the switches tab and edit the dummy switch.
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 15:02
by rick8245

- PIR_EDIT.png (54.58 KiB) Viewed 1052 times
Re: Scripting in blockly possible ??
Posted: Wednesday 29 April 2020 15:22
by rick8245
Thanks AllesvnZelf. It works