Scripting in blockly possible ??

Moderator: leecollings

Post Reply
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Scripting in blockly possible ??

Post 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
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Scripting in blockly possible ??

Post 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.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripting in blockly possible ??

Post by rick8245 »

Hi AllesvanZelf.

Thanks for your reply

Where do i find the ' On Action' item ?
Is that at Events ??
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Scripting in blockly possible ??

Post by Egregius »

There's a "start script" action in Blockly. No need for a dummy switch.
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripting in blockly possible ??

Post 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
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Scripting in blockly possible ??

Post 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?
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Scripting in blockly possible ??

Post 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
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripting in blockly possible ??

Post 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 &gt; /home/pi/domoticz/scripts/python/hcsrc501.log</field><field name="TextParam"></field></block></statement></block></xml>
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Scripting in blockly possible ??

Post by AllesVanZelf »

Ohhh under messages. That is a logical place to put the start script :lol:
Never found that one

You can place an image via an external service like: imgur
then get share link and the BBcode one.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripting in blockly possible ??

Post by rick8245 »

I cannot find another location with START SCRIPT
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Scripting in blockly possible ??

Post 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.
Image
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripting in blockly possible ??

Post by rick8245 »

It looks i have another interfce than you have.
I am running Domoticz on a raspberry.
dummySwitch.png
dummySwitch.png (17.61 KiB) Viewed 1035 times
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripting in blockly possible ??

Post by rick8245 »

found it
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Scripting in blockly possible ??

Post by AllesVanZelf »

No it is the same. The page I show is from the switches tab and edit the dummy switch.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripting in blockly possible ??

Post by rick8245 »

PIR_EDIT.png
PIR_EDIT.png (54.58 KiB) Viewed 1034 times
rick8245
Posts: 74
Joined: Wednesday 22 April 2020 15:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripting in blockly possible ??

Post by rick8245 »

Thanks AllesvnZelf. It works
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest