Is it possible read other Shelly's status? If it is possible is there differece depending gen1 or gen2 products? I have code like below which work local devices, but I don't know how I can include other Shelly's IP address to this code.
Get Component Status from other Shelly
-
-
You can try with an URL and RPC method. At least with Generation 2, remote access should be possible.
In the callback function you can use the response in JSON format.
An example - untested
CodeShelly.call('http.get',{url:'http://<remote ip address>/rpc/switch.getstatus?id=0'}, function(response) { let power = response.apower; //... } );
To use a remote Gen. 1 Shelly, you should study its HTTP communication.
-
Thank you for your help, but still I have something what I can't understand. I tried it code like below, but seems that it can't get apower status.
-
The second, inner function is never processed.
-
Hallo,
dazu hätte ich auch eine Frage.
Mit dem Aufruf kann ich tatsächlich die Werte eines anderen Shellys über die IP abrufen.
CodeShelly.call('http.get',{url:'http://192.168.xxx.xxx/rpc/switch.getstatus?id=0'}, function (response, error_code, error_message, ud) { print(JSON.stringify(response)); print(response['body']); } );
Wie komme ich aber an die untergeordneten Werte in dem Json-Array?
Diese beiden Aufrufe funktionieren jedenfalls nichtCodeprint(response['body']['apower']) print(response['body']['.']['apower']) print(response['body'])
Bei Aufruf nur des Body in der 3. Zeile bekomme ich wenigstens ein Ergebnis:
"{\"id\":0, \"source\":\"http\", \"output\":true, \"apower\":0.0, \"voltage\":232.2, \"current\":0.000, \"aenergy\":{\"total\":0 17:33:18
.000,\"by_minute\":[0.000,0.000,0.000],\"minute_ts\":1722439980},\"temperature\":{\"tC\":43.7, \"tF\":110.7}}"
Wie ich das weiter auswerte, ist mir ein Rätsel - oder muss ich das mit String-Methoden von Javascript selbst parsen?
-
Dieses Thema enthält 11 weitere Beiträge, die nur für registrierte Benutzer sichtbar sind.