Skip to content

Commit d131d4d

Browse files
authored
Add new AI alarms for Foscam (openhab#16775)
Signed-off-by: Matthew Skinner <[email protected]>
1 parent 0ff8564 commit d131d4d

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/FoscamHandler.java

+24
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object ms
105105
ipCameraHandler.setChannelState(CHANNEL_ENABLE_LED, OnOffType.ON);
106106
}
107107

108+
if (content.contains("<humanDetectAlarmState>2</humanDetectAlarmState>")) {
109+
ipCameraHandler.motionDetected(CHANNEL_HUMAN_ALARM);
110+
} else if (content.contains("<humanDetectAlarmState>1</humanDetectAlarmState>")) {
111+
ipCameraHandler.noMotionDetected(CHANNEL_HUMAN_ALARM);
112+
}
113+
114+
if (content.contains("<crossLineDetectAlarmState>2</crossLineDetectAlarmState>")) {
115+
ipCameraHandler.motionDetected(CHANNEL_LINE_CROSSING_ALARM);
116+
} else if (content.contains("<crossLineDetectAlarmState>1</crossLineDetectAlarmState>")) {
117+
ipCameraHandler.noMotionDetected(CHANNEL_LINE_CROSSING_ALARM);
118+
}
119+
120+
if (content.contains("<carDetectAlarmState>2</carDetectAlarmState>")) {
121+
ipCameraHandler.motionDetected(CHANNEL_CAR_ALARM);
122+
} else if (content.contains("<carDetectAlarmState>1</carDetectAlarmState>")) {
123+
ipCameraHandler.noMotionDetected(CHANNEL_CAR_ALARM);
124+
}
125+
126+
if (content.contains("<petDetectAlarmState>2</petDetectAlarmState>")) {
127+
ipCameraHandler.motionDetected(CHANNEL_ANIMAL_ALARM);
128+
} else if (content.contains("<petDetectAlarmState>1</petDetectAlarmState>")) {
129+
ipCameraHandler.noMotionDetected(CHANNEL_ANIMAL_ALARM);
130+
}
131+
108132
if (content.contains("</CGI_Result>")) {
109133
ctx.close();
110134
}

bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/thing/thing-types.xml

+7
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,7 @@
14441444
<channel id="mp4History" typeId="mp4History"/>
14451445
<channel id="mp4HistoryLength" typeId="mp4HistoryLength"/>
14461446
<channel id="lastMotionType" typeId="lastMotionType"/>
1447+
<channel id="lineCrossingAlarm" typeId="lineCrossingAlarm"/>
14471448
<channel id="ffmpegMotionControl" typeId="ffmpegMotionControl"/>
14481449
<channel id="ffmpegMotionAlarm" typeId="ffmpegMotionAlarm"/>
14491450
<channel id="enableMotionAlarm" typeId="enableMotionAlarm"/>
@@ -1462,7 +1463,13 @@
14621463
<channel id="rtspUrl" typeId="rtspUrl"/>
14631464
<channel id="imageUrl" typeId="imageUrl"/>
14641465
<channel id="hlsUrl" typeId="hlsUrl"/>
1466+
<channel id="carAlarm" typeId="carAlarm"/>
1467+
<channel id="humanAlarm" typeId="humanAlarm"/>
1468+
<channel id="animalAlarm" typeId="animalAlarm"/>
14651469
</channels>
1470+
<properties>
1471+
<property name="thingTypeVersion">1</property>
1472+
</properties>
14661473
<config-description>
14671474

14681475
<parameter-group name="Settings">

bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/update/instructions.xml

+16
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,20 @@
3131
</instruction-set>
3232
</thing-type>
3333

34+
<thing-type uid="ipcamera:foscam">
35+
<instruction-set targetVersion="1">
36+
<add-channel id="carAlarm">
37+
<type>ipcamera:carAlarm</type>
38+
</add-channel>
39+
<add-channel id="humanAlarm">
40+
<type>ipcamera:humanAlarm</type>
41+
</add-channel>
42+
<add-channel id="animalAlarm">
43+
<type>ipcamera:animalAlarm</type>
44+
</add-channel>
45+
<add-channel id="lineCrossingAlarm">
46+
<type>ipcamera:lineCrossingAlarm</type>
47+
</add-channel>
48+
</instruction-set>
49+
</thing-type>
3450
</update:update-descriptions>

0 commit comments

Comments
 (0)