Page 1 of 1

how run some commands in domoticz startup?

Posted: Saturday 19 November 2016 19:36
by reza
hi guys
i use raspberrypi with v3.57
i want in startup (after power off/on or reset) some command run. for example after power off , when power is on , a light go to on(automatic) . every time is repeat. is this option in domoticz ? if yes how i do it? thank you

Re: how run some commands in domoticz startup?

Posted: Saturday 19 November 2016 20:05
by sisaenkov
You can add next command in init script /etc/init.d/domoticz.sh to turn On the light:

Code: Select all

/usr/bin/curl -s "http://172.16.1.31:8080/json.htm?type=command&param=switchlight&idx=177&switchcmd=On"
Change IP address and idx parameter (idx=177 in my example) to yours one.

Insert here:

Code: Select all

do_start()
{

        # Turn the lights On
        /usr/bin/curl -s "http://172.16.1.31:8080/json.htm?type=command&param=switchlight&idx=177&switchcmd=On"

...
And also you need to add Raspberry Pi's IP address in Domoticz Settings -> Local networks field to call JSON without auth:
Image

Re: how run some commands in domoticz startup?

Posted: Saturday 19 November 2016 20:32
by reza
sisaenkov wrote:You can add next command in init script /etc/init.d/domoticz.sh to turn On the light:

Code: Select all

/usr/bin/curl -s "http://172.16.1.31:8080/json.htm?type=command&param=switchlight&idx=177&switchcmd=On"
Change IP address and idx parameter (idx=177 in my example) to yours one.

Insert here:

Code: Select all

do_start()
{

        # Turn the lights On
        /usr/bin/curl -s "http://172.16.1.31:8080/json.htm?type=command&param=switchlight&idx=177&switchcmd=On"

...
And also you need to add Raspberry Pi's IP address in Domoticz Settings -> Local networks field to call JSON without auth:
Image
hi thank you my friend but i am beginner . so can you explain more ? where is "/etc/init.d/domoticz.sh" ? how go to this ?
for example idx is 90 and ip address (raspberry) in my local network is 192.168.0.102. so what do am i do ? in setting....
thank you

Re: how run some commands in domoticz startup?

Posted: Sunday 20 November 2016 9:25
by sisaenkov
1. Read this.
2. Next type command:

Code: Select all

sudo nano /etc/init.d/domoticz.sh
3. Insert next two lines after do_start() {:

Code: Select all

do_start()
{

       # Turn the lights On
       /usr/bin/curl -s "http://192.168.0.102:8080/json.htm?type=command&param=switchlight&idx=90&switchcmd=On"
4. Press Ctrl+O for save. And Ctrl+X for exit from editor.
5. Go to Settings in Domoticz and type 127.0.0*;192.168.0.102 in Local networks field.

Re: how run some commands in domoticz startup?

Posted: Sunday 20 November 2016 17:02
by reza
sisaenkov wrote:1. Read this.
2. Next type command:

Code: Select all

sudo nano /etc/init.d/domoticz.sh
3. Insert next two lines after do_start() {:

Code: Select all

do_start()
{

       # Turn the lights On
       /usr/bin/curl -s "http://192.168.0.102:8080/json.htm?type=command&param=switchlight&idx=90&switchcmd=On"
4. Press Ctrl+O for save. And Ctrl+X for exit from editor.
5. Go to Settings in Domoticz and type 127.0.0*;192.168.0.102 in Local networks field.
thank you my dear friend ,and if i want use 2 light is on :
/usr/bin/curl -s "http://192.168.0.102:8080/json.htm?type ... itchcmd=On"
/usr/bin/curl -s "http://192.168.0.102:8080/json.htm?type ... itchcmd=On"
is this true ? this command is const "/usr/bin/curl -s" for all devices ?

Re: how run some commands in domoticz startup?

Posted: Sunday 20 November 2016 17:16
by sisaenkov
Yes, right.

Re: how run some commands in domoticz startup?

Posted: Sunday 20 November 2016 17:50
by reza
sisaenkov wrote:Yes, right.
thank you very much

Re: how run some commands in domoticz startup?

Posted: Monday 21 November 2016 9:15
by reza
sisaenkov wrote:Yes, right.
my friend i want use this for a orange pi one with debian-jessie os. i test this but dont work :(

Re: how run some commands in domoticz startup?

Posted: Tuesday 01 September 2020 9:38
by Preetz

Code: Select all

/usr/bin/curl -s "http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=Off"
Executing this line from shell works fine.
Pasted in /etc/init.d/domoticz.sh in do_start() method, it does not.

Does anyone have a clue what I'm missing?

Re: how run some commands in domoticz startup?

Posted: Tuesday 01 September 2020 12:58
by waaren
Preetz wrote:

Code: Select all

/usr/bin/curl -s "http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=Off"
Executing this line from shell works fine.
Pasted in /etc/init.d/domoticz.sh in do_start() method, it does not.

Does anyone have a clue what I'm missing?
Are you sure domoticz is already started when the curl gets executed?