mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-31 05:24:24 +02:00
[ipcamera] Add reboot action for Reolink ipcamera (#18337)
* Add reboot channel for Reolink ipcam Signed-off-by: Simmon Yau <simmonyau@gmail.com>
This commit is contained in:
@@ -703,6 +703,16 @@ then
|
||||
end
|
||||
```
|
||||
|
||||
## How To Reboot Camera
|
||||
```
|
||||
rule "Reboot Camera At 12:00 AM"
|
||||
when
|
||||
Time cron "0 0 0 ? *"
|
||||
then
|
||||
getActions("ipcamera", "ipcamera:reolink:1a40bbe041").reboot()
|
||||
end
|
||||
```
|
||||
|
||||
## HABpanel
|
||||
|
||||
This section is about how to get things working in HABpanel.
|
||||
|
||||
+13
@@ -76,4 +76,17 @@ public class IpCameraActions implements ThingActions {
|
||||
public static void recordGIF(ThingActions actions, @Nullable String filename, int secondsToRecord) {
|
||||
((IpCameraActions) actions).recordGIF(filename, secondsToRecord);
|
||||
}
|
||||
|
||||
@RuleAction(label = "reboot", description = "Reboot camera")
|
||||
public void reboot() {
|
||||
logger.debug("Rebooting camera.");
|
||||
IpCameraHandler localHandler = handler;
|
||||
if (localHandler != null) {
|
||||
localHandler.reboot();
|
||||
}
|
||||
}
|
||||
|
||||
public static void reboot(@Nullable ThingActions actions) {
|
||||
((IpCameraActions) actions).reboot();
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -322,6 +322,12 @@ public class ReolinkHandler extends ChannelDuplexHandler {
|
||||
ipCameraHandler.setChannelState(CHANNEL_ENABLE_RECORDINGS, OnOffType.ON);
|
||||
}
|
||||
break;
|
||||
case "/api.cgi?cmd=Reboot":
|
||||
// This handles reboot action response.
|
||||
if (!content.contains("\"rspCode\" : 200")) {
|
||||
ipCameraHandler.logger.warn("Reboot failed:\n{}", content);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// ignore responses from all Setxx commands
|
||||
if (!cutDownURL.startsWith("/cgi-bin/api.cgi?cmd=Set")
|
||||
@@ -589,4 +595,8 @@ public class ReolinkHandler extends ChannelDuplexHandler {
|
||||
public List<String> getLowPriorityRequests() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public void reboot() {
|
||||
ipCameraHandler.sendHttpPOST("/api.cgi?cmd=Reboot" + ipCameraHandler.reolinkAuth, "[{\"cmd\":\"Reboot\"}]");
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -1059,6 +1059,17 @@ public class IpCameraHandler extends BaseThingHandler {
|
||||
setChannelState(CHANNEL_RECORDING_GIF, DecimalType.valueOf(new String("" + seconds)));
|
||||
}
|
||||
|
||||
public void reboot() {
|
||||
switch (thing.getThingTypeUID().getId()) {
|
||||
case REOLINK_THING:
|
||||
ReolinkHandler reolinkHandler = new ReolinkHandler(getHandle());
|
||||
reolinkHandler.reboot();
|
||||
break;
|
||||
default:
|
||||
logger.warn("Reboot is not yet supported for ipcamera type {}", thing.getThingTypeUID().getId());
|
||||
}
|
||||
}
|
||||
|
||||
private void getReolinkToken() {
|
||||
sendHttpPOST("/api.cgi?cmd=Login",
|
||||
"[{\"cmd\":\"Login\", \"param\":{ \"User\":{ \"Version\": \"0\", \"userName\":\""
|
||||
|
||||
Reference in New Issue
Block a user