Skip to content

Commit

Permalink
Merge pull request #4 from ScottGibb/add-more-devices
Browse files Browse the repository at this point in the history
Add more devices
  • Loading branch information
ScottGibb authored Jan 14, 2025
2 parents f1b0947 + e9ea638 commit d8ebcab
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 15 deletions.
9 changes: 7 additions & 2 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ This flow will turn the lights in the master bedroom on and off dependent on the

### Alexa Integration Issues

Sadly the [Alexa plugin for Node-red](https://flows.nodered.org/node/node-red-contrib-alexa-remote2-applestrudel) by applesstrudel is not working as expected. It seems to be a common issue with the plugin. THis meant that I couldnt control my smart bulb in the end. However the core logic for this system is there and can be added in the future.
Sadly the [Alexa plugin for Node-red](https://flows.nodered.org/node/node-red-contrib-alexa-remote2-applestrudel) by applesstrudel is not working as expected. It seems to be a common issue with the plugin. I sadly had to abandon hopes of controlling my plusminus lightbulb and moved on to using a Matter controlled light bulb.

### Matter Integration

I have since moved to using a matter controlled light bulb. This is a much better solution as it is more reliable and does not require the use of a plugin. The light bulb is controlled using the [Matter](https://flows.nodered.org/node/@sammachin/node-red-matter-controller) plugin.

## Getting Started

Expand All @@ -44,7 +48,7 @@ Then configure your docker-compose.yaml file like how its configured in the [exa
Then when you are ready run the docker compose command:

```bash
docker compose up
docker compose up
```

## Developer Notes
Expand Down Expand Up @@ -106,5 +110,6 @@ cargo run --example receiver

- [HC-SR501](https://dronebotworkshop.com/using-pir-sensors-with-arduino-raspberry-pi/)
- [Node-Red](https://cookbook.nodered.org/mqtt/connect-to-broker)
- [Matter Controller](https://flows.nodered.org/node/@sammachin/node-red-matter-controller)
- [Alexa Remote](https://flows.nodered.org/node/node-red-contrib-alexa-remote2-applestrudel)
- [WSL2 Sharing USB Devices](https://learn.microsoft.com/en-us/windows/wsl/connect-usb)
4 changes: 2 additions & 2 deletions docs/System Architecture.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/node-red-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
179 changes: 168 additions & 11 deletions examples/node-red/timer_flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 550,
"y": 240,
"x": 430,
"y": 220,
"wires": []
},
{
Expand All @@ -53,7 +53,7 @@
"initialize": "",
"finalize": "",
"libs": [],
"x": 680,
"x": 720,
"y": 360,
"wires": [
[
Expand All @@ -68,9 +68,9 @@
"id": "10f86d63f63b1203",
"type": "inject",
"z": "b100c9c25a08567d",
"name": "Debug Injection",
"name": "No Presence Injection",
"props": [
{ "p": "payload.presence", "v": "true", "vt": "bool" },
{ "p": "payload.presence", "v": "false", "vt": "bool" },
{ "p": "timestamp", "v": "", "vt": "date" },
{ "p": "sensor_id", "v": "10", "vt": "str" }
],
Expand All @@ -79,7 +79,7 @@
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 200,
"x": 180,
"y": 280,
"wires": [["504d8e915fdac982", "0c321eaa8f89989e"]]
},
Expand Down Expand Up @@ -168,7 +168,7 @@
"type": "function",
"z": "b100c9c25a08567d",
"name": "Time Limiter",
"func": "// Get the current time\nvar currentTime = new Date();\nvar startTime = new Date();\nvar endTime = new Date();\n\n// Set the start time (8:00 AM)\nstartTime.setHours(8, 0, 0, 0);\n\n// Set the end time (9:00 PM)\nendTime.setHours(21, 0, 0, 0);\n\n// Check if the current time is within the range\nif (currentTime >= startTime && currentTime <= endTime) {\n // Pass the message through\n return msg;\n}",
"func": "// Get the current time\nvar currentTime = new Date();\nvar startTime = new Date();\nvar endTime = new Date();\n\n// Set the start time (8:00 AM)\nstartTime.setHours(8, 0, 0, 0);\n\n// Set the end time (9:00 PM)\nendTime.setHours(22, 0, 0, 0);\n\n// Check if the current time is within the range\nif (currentTime >= startTime && currentTime <= endTime) {\n // Pass the message through\n return msg;\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
Expand All @@ -177,18 +177,169 @@
"libs": [],
"x": 450,
"y": 360,
"wires": [["35e9173d2382cdf5"]]
"wires": [["35e9173d2382cdf5", "510e43d50645a2ac", "64cd08126f98d299"]]
},
{
"id": "3e5e6b6864be216d",
"type": "comment",
"z": "b100c9c25a08567d",
"name": "Alexa Overhead Light Control",
"name": "Matter Overhead Light Control",
"info": "",
"x": 1280,
"y": 160,
"x": 1220,
"y": 40,
"wires": []
},
{
"id": "8f78061b5b62a866",
"type": "mattermanager",
"z": "b100c9c25a08567d",
"name": "Overhead Light",
"controller": "935222afde0f1331",
"method": "commissionDevice",
"code": "1248-445-2811",
"codeType": "str",
"deviceid": "",
"deviceidType": "str",
"label": "Overhead Light",
"labelType": "str",
"x": 320,
"y": 620,
"wires": [[]]
},
{
"id": "32cf6c17d291dc82",
"type": "mattercommand",
"z": "b100c9c25a08567d",
"name": "",
"controller": "935222afde0f1331",
"device": "3878310905870684751-1",
"deviceName": "Overhead Light",
"endpoint": "",
"cluster": "6",
"command": "on",
"data": "{}",
"dataType": "json",
"simpleMode": false,
"x": 1190,
"y": 80,
"wires": [[]]
},
{
"id": "510e43d50645a2ac",
"type": "function",
"z": "b100c9c25a08567d",
"name": "Convert to Server Rack Fan Command",
"func": "//TODO: Detect Time\n// Set Lifghts on if during the day\n// After 10pm ignore presence\n\nif (!msg.payload.presence){\n msg.command = \"TurnOnRequest\"\n}else {\n msg.command = \"SetPercentageRequest\"\n msg.payload = 50\n}\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 770,
"y": 620,
"wires": [["16201a204d79d877"]]
},
{
"id": "16201a204d79d877",
"type": "link out",
"z": "b100c9c25a08567d",
"name": "link out 1",
"mode": "link",
"links": ["a7ddd911dd868a4b"],
"x": 1125,
"y": 620,
"wires": []
},
{
"id": "6dbc156775ab88ce",
"type": "inject",
"z": "b100c9c25a08567d",
"name": "Trigger",
"props": [{ "p": "payload" }, { "p": "topic", "vt": "str" }],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 620,
"wires": [["8f78061b5b62a866"]]
},
{
"id": "74622584567e76f7",
"type": "comment",
"z": "b100c9c25a08567d",
"name": "Matter Device Provisioning",
"info": "",
"x": 150,
"y": 580,
"wires": []
},
{
"id": "64cd08126f98d299",
"type": "switch",
"z": "b100c9c25a08567d",
"name": "Matter Controller",
"property": "payload.presence",
"propertyType": "msg",
"rules": [{ "t": "true" }, { "t": "false" }],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 750,
"y": 180,
"wires": [["32cf6c17d291dc82"], ["f5cabd1f8afefe12"]]
},
{
"id": "f5cabd1f8afefe12",
"type": "mattercommand",
"z": "b100c9c25a08567d",
"name": "",
"controller": "935222afde0f1331",
"device": "3878310905870684751-1",
"deviceName": "Overhead Light",
"endpoint": "",
"cluster": "6",
"command": "off",
"data": "{}",
"dataType": "json",
"simpleMode": false,
"x": 1190,
"y": 120,
"wires": [[]]
},
{
"id": "6f8238cbd575b45a",
"type": "comment",
"z": "b100c9c25a08567d",
"name": "Server Rack Direct Control",
"info": "",
"x": 1270,
"y": 620,
"wires": []
},
{
"id": "2108c40155a75644",
"type": "inject",
"z": "b100c9c25a08567d",
"name": "Presence Injection",
"props": [
{ "p": "payload.presence", "v": "true", "vt": "bool" },
{ "p": "timestamp", "v": "", "vt": "date" },
{ "p": "sensor_id", "v": "10", "vt": "str" }
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 170,
"y": 320,
"wires": [["504d8e915fdac982", "0c321eaa8f89989e"]]
},
{
"id": "7a20cadb7f538efb",
"type": "mqtt-broker",
Expand Down Expand Up @@ -219,5 +370,11 @@
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "935222afde0f1331",
"type": "mattercontroller",
"networkInterface": "eth0",
"logLevel": "DEBUG"
}
]

0 comments on commit d8ebcab

Please sign in to comment.