Here is the NodeRed Code. Change IP / USER / PASSWORD of course!..
[
{
"id": "93c44c49.6ea2a",
"type": "tab",
"label": "Camera Motion Sensors",
"disabled": false,
"info": ""
},
{
"id": "38d2e9e9.2b96f6",
"type": "www-request",
"z": "93c44c49.6ea2a",
"name": "Get Front Camera Motion Status",
"method": "GET",
"ret": "obj",
"url": "http://X.X.X.X/api.cgi?cmd=GetMdState&user=**USERNAME**s&password=**PASSWORD**",
"follow-redirects": true,
"persistent-http": true,
"tls": "",
"x": 200,
"y": 100,
"wires": [
[
"234c37f8.6a09e8"
]
]
},
{
"id": "5ebccf3d.0cc36",
"type": "api-call-service",
"z": "93c44c49.6ea2a",
"name": "Sensor Off",
"server": "d1ff6d9f.99f46",
"version": 1,
"service_domain": "input_boolean",
"service": "turn_off",
"entityId": "input_boolean.front_camera_motion",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 550,
"y": 40,
"wires": [
[]
]
},
{
"id": "234c37f8.6a09e8",
"type": "switch",
"z": "93c44c49.6ea2a",
"name": "Check Status",
"property": "payload.0.value.state",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "",
"vt": "prev"
},
{
"t": "eq",
"v": "0",
"vt": "num"
},
{
"t": "eq",
"v": "1",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 340,
"y": 40,
"wires": [
[],
[
"5ebccf3d.0cc36"
],
[
"b6c51b0c.251b18"
]
]
},
{
"id": "b6c51b0c.251b18",
"type": "api-call-service",
"z": "93c44c49.6ea2a",
"name": "Sensor On",
"server": "d1ff6d9f.99f46",
"version": 1,
"service_domain": "input_boolean",
"service": "turn_on",
"entityId": "input_boolean.front_camera_motion",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 550,
"y": 100,
"wires": [
[]
]
},
{
"id": "899ab24d.7aa7f",
"type": "inject",
"z": "93c44c49.6ea2a",
"name": "Repeat",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 120,
"y": 40,
"wires": [
[
"38d2e9e9.2b96f6"
]
]
},
{
"id": "d1ff6d9f.99f46",
"type": "server",
"z": "",
"name": "Home Assistant"
}
]
I modified it a bit to only update the sensor when there’s a change, and not poll from HA…