how run some commands in domoticz startup?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

how run some commands in domoticz startup?

Post 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
User avatar
sisaenkov
Posts: 50
Joined: Friday 27 May 2016 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8
Location: Moscow, Russia
Contact:

Re: how run some commands in domoticz startup?

Post 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
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how run some commands in domoticz startup?

Post 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
User avatar
sisaenkov
Posts: 50
Joined: Friday 27 May 2016 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8
Location: Moscow, Russia
Contact:

Re: how run some commands in domoticz startup?

Post 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.
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how run some commands in domoticz startup?

Post 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 ?
User avatar
sisaenkov
Posts: 50
Joined: Friday 27 May 2016 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8
Location: Moscow, Russia
Contact:

Re: how run some commands in domoticz startup?

Post by sisaenkov »

Yes, right.
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how run some commands in domoticz startup?

Post by reza »

sisaenkov wrote:Yes, right.
thank you very much
reza
Posts: 112
Joined: Tuesday 13 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

Re: how run some commands in domoticz startup?

Post 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 :(
Preetz
Posts: 3
Joined: Monday 31 August 2020 21:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Germany
Contact:

Re: how run some commands in domoticz startup?

Post 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?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how run some commands in domoticz startup?

Post 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?




Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest