Page 1 of 1

dzVents Reboot Raspberry Pi

Posted: Sunday 11 June 2023 15:14
by Piacco
Hi,

My raspberry has memory leakage, so I want to reboot my raspberry pi if the memory exceeds the 80%, is this possible with dzVents?

I tried this, but this is not working.

Code: Select all

 if memory.percentage > 80 then
    
     dz.openURL(
            {
                url = "http://192.168.1.15:8181/json.htm?type=command&param=system_reboot",
                method = 'POST',
               
            })
     
     end

Code: Select all

2023-06-11 14:30:00.241 Error: Error opening url: http://192.168.1.15:8181/json.htm?type=command&param=system_reboot
I know that i have to solve the memory leakage ;)

Re: dzVents Reboot Raspberry Pi

Posted: Sunday 11 June 2023 19:52
by Number8
Either you are not using the async http method and the code should be

Code: Select all

dz.openURL("http://192.168.1.15:8181/json.htm?type=command&param=system_reboot")
or is you want to use the async way then you should set a callback
See doc https://www.domoticz.com/wiki/DzVents:_ ... _scripting
If you go the async way, use GET in that case (no POST data is needed)
Are you sure you web server port is set on 8181?

Re: dzVents Reboot Raspberry Pi

Posted: Sunday 11 June 2023 20:39
by Piacco
Yes Domoticz Port is on 8181 :D
I get the same error with the dz.openURL command.

Code: Select all

 dz.openURL("http://192.168.1.15:8181/json.htm?type=command&param=system_reboot")
2023-06-11 20:37:00.447 Error: Error opening url: http://192.168.1.15:8181/json.htm?type= ... tem_reboot

Re: dzVents Reboot Raspberry Pi

Posted: Sunday 11 June 2023 20:43
by willemd
A guess: Maybe user domoticz is not allowed to do the reboot? You need to be superuser?

Re: dzVents Reboot Raspberry Pi

Posted: Sunday 11 June 2023 21:04
by heggink
Use monit. It's really good at monitoring domoticz in all aspects. There should be a wiki

Re: dzVents Reboot Raspberry Pi

Posted: Sunday 11 June 2023 21:39
by Kedi
Perhaps use:

Code: Select all

 dz.openURL("http://127.0.0.1:8181/json.htm?type=command&param=system_reboot")
and make sure that 127.0.0.1 is set in "Thrusted Network" in Setup -> Settings -> Security