Yes, right, now it returns a different error, maybe something to do with user rights?EddyG wrote: ↑Wednesday 05 January 2022 15:45 It should be:because Domoticz is inside docker and using paths like /opt/domoticz/.....Code: Select all
script:///opt/domoticz/scripts/relay....
You could check what the right path is by going inside docker.
Synology - script doesn't work
Moderator: leecollings
- fabry91
- Posts: 67
- Joined: Sunday 09 December 2018 16:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Italy
- Contact:
Re: Synology - script doesn't work
- Attachments
-
- domologs.jpg (52.82 KiB) Viewed 46099 times
Re: Synology - script doesn't work
That is probably because the 'nc' command is not in the docker image.
You could install that but remember that every time you update the image you will have to do it again, because it is lost if you update the image.
Go into the container with
execute these command in the container.
exit the container.
You could install that but remember that every time you update the image you will have to do it again, because it is lost if you update the image.
Go into the container with
Code: Select all
sudo docker run -it domoticz/domoticz /bin/bash
Code: Select all
apt-get update
apt-get install netcat
- fabry91
- Posts: 67
- Joined: Sunday 09 December 2018 16:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Italy
- Contact:
Re: Synology - script doesn't work
I have tried to install netcut but it returns with some warnings, same error in Domoticz when I run the script:EddyG wrote: ↑Wednesday 05 January 2022 16:26 That is probably because the 'nc' command is not in the docker image.
You could install that but remember that every time you update the image you will have to do it again, because it is lost if you update the image.
Go into the container withexecute these command in the container.Code: Select all
sudo docker run -it domoticz/domoticz /bin/bash
exit the container.Code: Select all
apt-get update apt-get install netcat
PS. the script is:
Code: Select all
echo -n "11" | nc -n -w 1 192.168.0.99 6722
- Attachments
-
- containerbash.jpg (184.29 KiB) Viewed 46097 times
Re: Synology - script doesn't work
Try using netcat instead of the nc command in the script.
Code: Select all
echo -n "11" | netcat -n -w 1 192.168.0.99 6722
- fabry91
- Posts: 67
- Joined: Sunday 09 December 2018 16:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Italy
- Contact:
Re: Synology - script doesn't work
same error, I noticed that in the container scripts folder there isn't the same script files outside the docker:EddyG wrote: ↑Wednesday 05 January 2022 16:57 Try using netcat instead of the nc command in the script.Code: Select all
echo -n "11" | netcat -n -w 1 192.168.0.99 6722
PS. I have modified the scripts file in "\docker\Domoticz\scripts"
- Attachments
-
- scripts.jpg (107.8 KiB) Viewed 46091 times
-
- domologs.jpg (47.46 KiB) Viewed 46091 times
- fabry91
- Posts: 67
- Joined: Sunday 09 December 2018 16:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Italy
- Contact:
Re: Synology - script doesn't work
Maybe figured it out!!
I added at the end of the Action: "script:///opt/domoticz/.... & and now command are executing right, will check in place when I get home
I added at the end of the Action: "script:///opt/domoticz/.... & and now command are executing right, will check in place when I get home

- Attachments
-
- domoactionscript.jpg (26.02 KiB) Viewed 46084 times
-
- domologs.jpg (41.27 KiB) Viewed 46084 times
- fabry91
- Posts: 67
- Joined: Sunday 09 December 2018 16:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Italy
- Contact:
Re: Synology - script doesn't work
Doesn't help to use netcat instead of "nc"...EddyG wrote: ↑Wednesday 05 January 2022 16:57 Try using netcat instead of the nc command in the script.Code: Select all
echo -n "11" | netcat -n -w 1 192.168.0.99 6722
Result of domoticz logs:
Code: Select all
Error: Error executing script command (/opt/domoticz/scripts/relay_ch2_on.sh). returned: 32512

How can I test netcat and be sure it is working?
Re: Synology - script doesn't work
I oversaw that you have to open port 6722 in the docker container besides the port 8080 and 443
Did you test the complete command on the command line in the docker container?
Did you test the complete command on the command line in the docker container?
- fabry91
- Posts: 67
- Joined: Sunday 09 December 2018 16:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Italy
- Contact:
Re: Synology - script doesn't work
Okay, port settings of the docker says that is in the same network of the docker host, how can I open port 6722?
- Attachments
-
- Screenshot_20220105-222521__01.jpg (55.95 KiB) Viewed 46051 times
Re: Synology - script doesn't work
Set the problem of the port aside, it does not hurt, I assumed that the same port might be used for a response.
First get your script working from inside docker.
Did you try to execute the script content inside the docker container?
Did you try to find inside the container your script?
E.g. in /opt/domoticz/scripts or /opt/domoticz/userdata or /opt/domoticz/userdata/scripts
And what is the result?
If you found your script in the docker container, did you try to execute the script from inside the container?
And what is the result?
If you lack the experience with docker, either read more about docker and how to install and maintain containers or go back to your working raspberry.
First get your script working from inside docker.
Did you try to execute the script content inside the docker container?
Code: Select all
echo -n "11" | nc -n -w 1 192.168.0.99 6722
E.g. in /opt/domoticz/scripts or /opt/domoticz/userdata or /opt/domoticz/userdata/scripts
And what is the result?
If you found your script in the docker container, did you try to execute the script from inside the container?
And what is the result?
If you lack the experience with docker, either read more about docker and how to install and maintain containers or go back to your working raspberry.
- fabry91
- Posts: 67
- Joined: Sunday 09 December 2018 16:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Italy
- Contact:
Re: Synology - script doesn't work
Hello Eddy and thank you again for your reply.EddyG wrote: ↑Thursday 06 January 2022 10:35 Set the problem of the port aside, it does not hurt, I assumed that the same port might be used for a response.
First get your script working from inside docker.
Did you try to execute the script content inside the docker container?Did you try to find inside the container your script?Code: Select all
echo -n "11" | nc -n -w 1 192.168.0.99 6722
E.g. in /opt/domoticz/scripts or /opt/domoticz/userdata or /opt/domoticz/userdata/scripts
And what is the result?
If you found your script in the docker container, did you try to execute the script from inside the container?
And what is the result?
If you lack the experience with docker, either read more about docker and how to install and maintain containers or go back to your working raspberry.
I am new with docker and I succesfull migrate Domoticz db, DZGA and get everything working, only thing that is not working is this SR-201 script relay.
So I tried to execute the script from a command line inside the docker and the result is "command not found":
- Attachments
-
- scripts.jpg (139.46 KiB) Viewed 46008 times
- waltervl
- Posts: 5907
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Synology - script doesn't work
Do I read netcut? it should be netcat.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Re: Synology - script doesn't work
That is really strange. I did the same on my test system where domoticz also runs in a container.
I got the same errors when installing netcat.
Both nc and netcat are found in /bin/ in the docker container.
Your echo -n "11" | nc -n -w 1 192.168.0.99 6722 command runs fine in my container, of course I get an error about the non-existing IP or with a real IP that connection is refused.
You can check if those nc and netcat commands exists in the /bin/ directory in the container.
Remember (like I said before) when ever you stop the container or update the image the 2 command to install netcat have to be run again.
'netcat' is NOT part of the image. That is 1 of the disadvantages of running Domoticz in a docker container.
If you do have anything special (like you have with netcat / nc) than Domoticz in a container might not be a good idea.
I got the same errors when installing netcat.
Both nc and netcat are found in /bin/ in the docker container.
Your echo -n "11" | nc -n -w 1 192.168.0.99 6722 command runs fine in my container, of course I get an error about the non-existing IP or with a real IP that connection is refused.
You can check if those nc and netcat commands exists in the /bin/ directory in the container.
Remember (like I said before) when ever you stop the container or update the image the 2 command to install netcat have to be run again.
'netcat' is NOT part of the image. That is 1 of the disadvantages of running Domoticz in a docker container.
If you do have anything special (like you have with netcat / nc) than Domoticz in a container might not be a good idea.
Last edited by EddyG on Thursday 06 January 2022 13:26, edited 1 time in total.
Re: Synology - script doesn't work
When nc is not found then netcat is not found either. nc is just a link to netcat.
I already mentioned here that there is a way around it, see here: viewtopic.php?p=282919#p282919
But that is really complicated for people who are not familiar with Linux.
I already mentioned here that there is a way around it, see here: viewtopic.php?p=282919#p282919
But that is really complicated for people who are not familiar with Linux.
Re: Synology - script doesn't work
Also an idea might be to look for a python script that will do the same as your script.
python3 is default included in the Domoticz container image.
python3 is default included in the Domoticz container image.
- waltervl
- Posts: 5907
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Synology - script doesn't work
And here is the python equivalent (and doing much more): https://github.com/cryxli/sr201/blob/ma ... t/relay.py
usage to close relay 1
to open relay 1
usage
Code: Select all
python relay.py 192.168.0.99 close:1
Code: Select all
python relay.py 192.168.0.99 open:1
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
- fabry91
- Posts: 67
- Joined: Sunday 09 December 2018 16:52
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Italy
- Contact:
Re: Synology - script doesn't work
Hello Eddy and Walter,
thank you very much for yours suggestion, I finally figured it out doing this:
- open a new terminal on the Domoticz container
- cd scripts
- execute the command
- test the script with the return of "10000000" for on and "00000000" for off, with succesfull switch on and off of the relay 
So now in domoticz no error and can control perfectly the SR-201
I know that SR-201 can use python script too but the easiest way when we tested for the first time this type of relay was to use netcat.
@EddyG only thing is that, when I stop e start back the container the script continue to work, anyway better
Thank you very very much for all of your time and effort!

thank you very much for yours suggestion, I finally figured it out doing this:
- open a new terminal on the Domoticz container
- cd scripts
- execute the command
Code: Select all
apt-get update
apt-get install netcat
Code: Select all
echo -n "11" | nc -n -w 1 192.168.0.99 6722

So now in domoticz no error and can control perfectly the SR-201
I know that SR-201 can use python script too but the easiest way when we tested for the first time this type of relay was to use netcat.
@EddyG only thing is that, when I stop e start back the container the script continue to work, anyway better

Thank you very very much for all of your time and effort!



Re: Synology - script doesn't work
Glad that it worked, but you still might investigate some time in the python3 solution, because that is always present in the container image.
So netcat does not get lost when you update the container.
@waltervl unfortunately there is, for some reason, no link from python to python3 in the container, so python will not work, only python3.
So netcat does not get lost when you update the container.
@waltervl unfortunately there is, for some reason, no link from python to python3 in the container, so python will not work, only python3.
- waltervl
- Posts: 5907
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Synology - script doesn't work
In the script there is a reference to python3 so it should work....
#!/usr/bin/python3
#
#!/usr/bin/python3
#
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest