Enable hardware with script or API

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
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Enable hardware with script or API

Post by rolandbreedveld »

Hi all

I sometimes have an issue with my P1 interface, I have to disable and enable the "P1 Smart Meter USB" hardware to make it work again.
I want to do this automatic from my (=self-made) monitor-script, if possible with a api-call, but can't find how to do this, only to create/delete hardware.
Does anybody know how?

regards, Roland
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Enable hardware with script or API

Post by waaren »

rolandbreedveld wrote: Saturday 29 September 2018 18:53 I sometimes have an issue with my P1 interface, I have to disable and enable the "P1 Smart Meter USB" hardware to make it work again.
I want to do this automatic from my (=self-made) monitor-script, if possible with a api-call, but can't find how to do this
@rolandbreedveld, [Me being political correct :D ] I think it would be much more preferable if you can find the root cause of this problem and get that out of the way.

Unfortunately there seem to be no generic api-call to enable /disable hardware. The call varies per hardware type and other settings.
e.g. the call to disable my RFXcom is:

Code: Select all

http://DOMOTICZ_IP:DOMOTICZ_PORT/json.htm?type=command&param=updatehardware&htype=1&port=%2Fdev%2FttyUSB-RFtrx433&extra=&name=RFtrx433&enabled=false&idx=3&datatimeout=0&Mode1=0&Mode2=11&Mode3=0&Mode4=44&Mode5=46&Mode6=64
and the call to diable my P1 link is:

Code: Select all

http://DOMOTICZ_IP:DOMOTICZ_PORT/json.htm?type=command&param=updatehardware&htype=4&port=%2Fdev%2FttyUSB-P1&extra=&name=P1&enabled=false&idx=6&datatimeout=0&Mode1=1&Mode2=0&Mode3=0&Mode4=0&Mode5=0&Mode6=0
only sending

Code: Select all

http://DOMOTICZ_IP:DOMOTICZ_PORT/json.htm?type=command&param=updatehardware&enabled=false&idx=3
does result in an {"status": "ERR"} return

you can find the api-call for your domoticz system by entering developer mode ( [CTRL][SHIFT]I in chrome) and there choose network when accessing the hardware tab in domoticz and disable / enable the hardware you are looking for. In the developer window you will see the json domoticz uses to perform the requested action.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Enable hardware with script or API

Post by rolandbreedveld »

@waaren
Thanxzz, this wil do the job, didn't find this on the forum/wiki

regards, Roland
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
HansieNL
Posts: 964
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Enable hardware with script or API

Post by HansieNL »

@rolandbreedveld I have the same problem. Once in a while the P1 stops working and disabling/ enabling the hardware solves the problem.
Can you share your script you are using to solve this problem?
Thanks in advance.
Blah blah blah
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Enable hardware with script or API

Post by rolandbreedveld »

@HansieNL

solution is simple, set in the P1 hardware, the timeout at 15 minutes, this will restart the P1 service if dead.
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
HansieNL
Posts: 964
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Enable hardware with script or API

Post by HansieNL »

@rolandbreedveld Thanks. Didn't think about that solution. Sometimes things can be that simple :o :shock:
Blah blah blah
kofec
Posts: 53
Joined: Friday 16 September 2016 14:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Enable hardware with script or API

Post by kofec »

How to enable device ?
I'm able to disable but not enable:

Code: Select all

wget -q -O - "http://192.168.1.11:8080/json.htm?type=command&param=updatehardware&htype=41&name=MySensorsKinowaNano&enabled=false&
idx=2"
{
   "status" : "OK",
   "title" : "UpdateHardware"
}

wget -q -O - "http://192.168.1.11:8080/json.htm?type=command&param=updatehardware&htype=41&name=MySensorsKinowaNano&enabled=true&i
dx=2"
{
   "status" : "ERR"
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Enable hardware with script or API

Post by waaren »

kofec wrote: Tuesday 23 April 2019 18:35 How to enable device ?
I'm able to disable but not enable:
On my system I to add &port=%2Fdev%2FttyUSB-RFtrx433 to the http to get it working for my RFtrx433 device.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
kofec
Posts: 53
Joined: Friday 16 September 2016 14:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Enable hardware with script or API

Post by kofec »

It works. Thanks a lot:

Code: Select all

wget -q -O - "http://192.168.1.11:8080/json.htm?type=command&param=updatehardware&htype=41&name=MySensorsKinowaNano&enabled=true&i
dx=2&port=/dev/ttyUSB0"
{
   "status" : "OK",
   "title" : "UpdateHardware"
}
Marcel62
Posts: 2
Joined: Sunday 21 July 2019 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Enable hardware with script or API

Post by Marcel62 »

I've got the same problem. During disable/enable the hardware is not available. I noticed that just "update" the hardware (with no changes, just press the update button) also fixes the problem, the hardware is still available. In my case Aeon Labs Aeotec Gen 5, one of the nodes seems lost the connection (Heal Node does not work). During the update all other nodes are still available.
So i prefer an update.
Is it possible to call update from commandline (script) ?
It would be perfect to test the nodes first, and only call the update if one of the devices are not ok

thanks
Marcel62
Posts: 2
Joined: Sunday 21 July 2019 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Enable hardware with script or API

Post by Marcel62 »

found it, in the reply of warren , thanks
Post Reply

Who is online

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