├── .github ├── dependabot.yml └── workflows │ ├── main.yml │ ├── release.yml │ └── trivy-analysis.yml ├── .gitignore ├── LICENSE ├── README.md ├── docker-compose.yml ├── docker-image ├── Dockerfile ├── LICENSE ├── README.md ├── docker-make.sh ├── entrypoint.sh ├── package.json └── scripts │ └── remove_native_gpio.sh └── start.sh /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | - package-ecosystem: "npm" 9 | directory: "/docker-image" 10 | schedule: 11 | interval: "daily" 12 | - package-ecosystem: "docker" 13 | directory: "/docker-image" 14 | schedule: 15 | interval: "daily" 16 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Rebuild Master 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "15 1 * * *" 7 | push: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | node_version: [10, 12, 14] 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v2 20 | - name: Set up QEMU 21 | uses: docker/setup-qemu-action@v1 22 | - name: Set up Docker Buildx 23 | id: buildx 24 | uses: docker/setup-buildx-action@v1 25 | - name: Login to DockerHub 26 | uses: docker/login-action@v1 27 | with: 28 | username: ${{ secrets.DOCKER_USERNAME }} 29 | password: ${{ secrets.DOCKER_PASSWORD }} 30 | - name: Login to GitHub Container Registry 31 | uses: docker/login-action@v1 32 | with: 33 | username: ${{ secrets.PACKAGES_USER }} 34 | password: ${{ secrets.PACKAGES_TOKEN }} 35 | registry: ghcr.io 36 | - name: Cache Docker layers 37 | uses: actions/cache@v2 38 | id: cache 39 | with: 40 | path: /tmp/.buildx-cache 41 | key: ${{ runner.os }}-buildx-${{ github.sha }} 42 | restore-keys: | 43 | ${{ runner.os }}-buildx- 44 | - name: Available platforms 45 | run: echo ${{ steps.buildx.outputs.platforms }} 46 | - name: Run Buildx 47 | run: | 48 | if [ ${{ matrix.node_version }} -eq "14" ]; then 49 | export DEVEL="-t ctmagazin/ctnodered:devel -t ghcr.io/ct-open-source/ctnodered:devel" 50 | fi 51 | export PLATFORMS="linux/amd64,linux/arm/v7,linux/arm64/v8,linux/arm/v6" 52 | docker buildx build \ 53 | --platform $PLATFORMS \ 54 | -o type=registry \ 55 | -t ctmagazin/ctnodered:"devel-${{ matrix.node_version }}" \ 56 | -t ghcr.io/ct-open-source/ctnodered:"devel-${{ matrix.node_version }}" \ 57 | $DEVEL \ 58 | --build-arg NODE_VERSION=${{ matrix.node_version }} \ 59 | --build-arg NODE_RED_VERSION=latest \ 60 | --build-arg OS=alpine \ 61 | --build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")" \ 62 | --build-arg TAG_SUFFIX=devel-${{ matrix.node_version }} \ 63 | --file ./docker-image/Dockerfile ./docker-image 64 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Build Release 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: [published] 7 | schedule: 8 | - cron: "0 10 * * 1" # Update the image every Monday morning to provide regular updates 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-20.04 13 | strategy: 14 | matrix: 15 | node_version: [10, 12, 14] 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v2 19 | with: 20 | fetch-depth: 0 21 | - name: Checkout latest release 22 | run: git checkout $(git describe --tags `git rev-list --tags --max-count=1`) -b latest-release 23 | - name: Set up QEMU 24 | uses: docker/setup-qemu-action@v1 25 | - name: Set up Docker Buildx 26 | id: buildx 27 | uses: docker/setup-buildx-action@v1 28 | - name: Login to DockerHub 29 | uses: docker/login-action@v1 30 | with: 31 | username: ${{ secrets.DOCKER_USERNAME }} 32 | password: ${{ secrets.DOCKER_PASSWORD }} 33 | - name: Login to GitHub Container Registry 34 | uses: docker/login-action@v1 35 | with: 36 | username: ${{ secrets.PACKAGES_USER }} 37 | password: ${{ secrets.PACKAGES_TOKEN }} 38 | registry: ghcr.io 39 | - name: Cache Docker layers 40 | uses: actions/cache@v2 41 | id: cache 42 | with: 43 | path: /tmp/.buildx-cache 44 | key: ${{ runner.os }}-buildx-${{ github.sha }} 45 | restore-keys: | 46 | ${{ runner.os }}-buildx- 47 | 48 | - name: Available platforms 49 | run: echo ${{ steps.buildx.outputs.platforms }} 50 | - name: Run Buildx 51 | run: | 52 | if [ ${{ matrix.node_version }} -eq "12" ]; then 53 | export LATEST="-t ctmagazin/ctnodered:latest -t ghcr.io/ct-open-source/ctnodered:latest" 54 | fi 55 | docker buildx build \ 56 | --platform linux/amd64,linux/arm/v7,linux/arm64,linux/arm/v6 \ 57 | -o type=registry \ 58 | -t ctmagazin/ctnodered:$(git describe --tags `git rev-list --tags --max-count=1`)-${{ matrix.node_version }} \ 59 | -t ctmagazin/ctnodered:latest-${{ matrix.node_version }} \ 60 | -t ghcr.io/ct-open-source/ctnodered:$(git describe --tags `git rev-list --tags --max-count=1`)-${{ matrix.node_version }} \ 61 | -t ghcr.io/ct-open-source/ctnodered:latest-${{ matrix.node_version }} \ 62 | $LATEST \ 63 | --build-arg NODE_VERSION=${{ matrix.node_version }} \ 64 | --build-arg NODE_RED_VERSION=latest \ 65 | --build-arg OS=alpine \ 66 | --build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")" \ 67 | --build-arg TAG_SUFFIX=latest-${{ matrix.node_version }} \ 68 | --file ./docker-image/Dockerfile ./docker-image 69 | -------------------------------------------------------------------------------- /.github/workflows/trivy-analysis.yml: -------------------------------------------------------------------------------- 1 | name: Code check with Trivy 2 | on: 3 | push: 4 | branches: [ master ] 5 | pull_request: 6 | jobs: 7 | build: 8 | name: Build 9 | runs-on: "ubuntu-18.04" 10 | steps: 11 | - name: Checkout code 12 | uses: actions/checkout@v2 13 | 14 | - name: Build an image from Dockerfile 15 | run: | 16 | docker build -t docker.io/ctmagazin/ctnodered:${{ github.sha }} --file ./docker-image/Dockerfile ./docker-image 17 | 18 | - name: Run Trivy vulnerability scanner 19 | uses: aquasecurity/trivy-action@master 20 | with: 21 | image-ref: 'docker.io/ctmagazin/ctnodered:${{ github.sha }}' 22 | format: 'template' 23 | template: '@/contrib/sarif.tpl' 24 | output: 'trivy-results.sarif' 25 | severity: 'CRITICAL,HIGH' 26 | 27 | - name: Upload Trivy scan results to GitHub Security tab 28 | uses: github/codeql-action/upload-sarif@v1 29 | with: 30 | sarif_file: 'trivy-results.sarif' 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | data/* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # c't-Smart-Home 2 | 3 | A ready-to-use Node-RED setup for home automation maintained by [german computer magazine c't](https://www.ct.de/smarthome). 4 | 5 | It includes [Node-RED](https://nodered.org/), MQTT (provided by [Eclipse Mosquitto](https://mosquitto.org/)), Zigbee-Support (provided by [zigbee2mqtt](https://www.zigbee2mqtt.io/)). 6 | 7 | We also added Node-RED-Nodes for [HomeKit](https://github.com/NRCHKB/node-red-contrib-homekit-bridged), [FritzBox](https://github.com/bashgroup/node-red-contrib-fritz), [Tado](https://github.com/mattdavis90/node-red-contrib-tado-client), [Bluetooth-LE-Support](https://github.com/clausbroch/node-red-contrib-noble-bluetooth), [Zigbee2Mqtt-Support](https://flows.nodered.org/node/node-red-contrib-zigbee2mqtt) and a [Dashboard](https://github.com/node-red/node-red-dashboard). 8 | 9 | ![-](https://img.shields.io/github/stars/ct-Open-Source/ct-Smart-Home.svg) 10 | ![-](https://img.shields.io/github/release/ct-Open-Source/ct-Smart-Home.svg) 11 | ![-](https://img.shields.io/docker/pulls/ctmagazin/ctnodered.svg) 12 | ![-](https://img.shields.io/docker/stars/ctmagazin/ctnodered.svg) 13 | ![-](https://img.shields.io/github/license/ct-Open-Source/ct-Smart-Home.svg) 14 | ![-](https://img.shields.io/badge/GitHub-Actions-blueviolet) 15 | 16 | ## Requirements 17 | 18 | To get this going you need a working [Docker 18.02.0+ setup](https://docs.docker.com/install/) and [docker-compose](https://docs.docker.com/compose/install/). 19 | 20 | This setup will run on any AMD64 or ARM32v7 Linux machine. This includes virtually any PC or a Raspberry Pi 3 or newer. We also build containers for ARM64v8, ARM32v6 but they are untested. If you want to run the containers on macOS, try running `start.sh` as root. 21 | 22 | If you want to control Zigbee devices you also will need a Zigbee controller stick. Have a look at [Zigbee2MQTT's documentation](https://www.zigbee2mqtt.io/getting_started/what_do_i_need.html) for that. 23 | 24 | ## Getting started 25 | 26 | * Install docker and docker-compose: [german article on installation process](https://www.heise.de/ct/artikel/Docker-einrichten-unter-Linux-Windows-macOS-4309355.html?hg=1&hgi=3&hgf=false) 27 | 28 | * Clone this repository 29 | *Note: It's also possible to download the latest release from the release tab, but it's not recommended, because then the update mechanism won't work.* 30 | 31 | * `cd` into the folder containing this repos files 32 | 33 | * Run `./start.sh start` to setup the data folder needed to run the containers and start them up. 34 | *Note: The Zigbee2mqtt container will only start if a [Zigbee-Controller](https://www.zigbee2mqtt.io/information/supported_adapters.html) is connected. Make sure to update the adapter to the newest firmware!* 35 | **Backup the `./data` folder regularly, as it contains all your data and configuration files** 36 | 37 | * When you've got "the hang of it" follow the steps listed in the *Security* section to get a properly secured setup. 38 | 39 | ### Updating 40 | 41 | You should make a backup of all files in the `./data` folder. If you made changes to files outside of `./data` it is imperative to backup those too. 42 | 43 | An update via `start.sh update` will pull the latest release of this repository. This will work for most use cases. 44 | 45 | If you made changes to files provided in the repository, you'll have to undo those changes and reapply them. If you're familiar with `git` use `git stash` and `git stash apply`. If you want a specially customized version of this repo, think about forking it. 46 | 47 | If you manually downloaded the files from the release tab, you'll have to do the update manually. This takes three steps: 48 | 49 | * Backup your installation 50 | 51 | * Run `docker-compose down --remove-orphans` 52 | 53 | * Download the new release and overwrite the files in your installation. Or even better: switch to a cloned repository. 54 | 55 | * Run `./start.sh start` to start c't-Smart-Home 56 | 57 | ### Configuration 58 | 59 | To change configuration of the provided services, either use the corresponding web interfaces or have a look in the `./data` folder. There you'll find all the necessary configurations to modify your setup. 60 | 61 | ### How to access the services 62 | 63 | After starting the containers you'll reach Node-RED [http://docker-host:1880](http://docker-host:1880) and the Zigbee administrative interface at [http://docker-host:1881](http://docker-host:1881). Mosquitto is available on Port 1883 (and 9001 for websockets). You can see more details of the processes output in the container logs with the command `docker-compose logs`. 64 | 65 | ## Security 66 | 67 | **Never** make c't-Smart-Home available from outside of your network without following these following steps. In any case you should limit the access by enabling password protection! 68 | 69 | None of the services are protected by authorization mechanisms by default. This is not optimal, but a compromise to make it easier for beginners. To secure Node-RED have a look at their [documentation about "Securing Node-RED"](https://nodered.org/docs/user-guide/runtime/securing-node-red). It will show you how to enable a mandatory login. 70 | 71 | Zigbee2Mqtts web frontend also provides an authentication mechanism. It's described in their [documentation of the frontend](https://www.zigbee2mqtt.io/information/frontend.htm). 72 | 73 | Mosquitto won't demand a authentication either, but you can enable it in the config file. Just enable the last two lines and run the following command. Be sure to replace `USERNAME` with your preferred name. 74 | 75 | `docker run -it -v ${PWD}/data/mqtt/config/passwd:/passwd eclipse-mosquitto mosquitto_passwd /passwd USERNAME` 76 | 77 | Now restart mosquitto with `docker-compose restart mqtt`. Your mosquitto server should require authentication via the username/password combination you provided. Don't forget to modify the Zigbee2MQTT configuration and the Node-RED setup. To add more mosquitto users just run the command again. 78 | 79 | Additionally you should run c't-Smart-Home behind a reverse proxy like [Traefik](https://traefik.io/) to ensure all connections are encrypted. Traefik is able to secure not only HTTP, but also generic TCP and UDP connections. 80 | 81 | ## `start.sh` options 82 | 83 | ```plaintext 84 | 🏡 c't-Smart-Home – setup script 85 | ————————————————————————————— 86 | Usage: 87 | start.sh update – to update this copy of the repo 88 | start.sh fix – correct the permissions in the data folder 89 | start.sh start – run all containers 90 | start.sh stop – stop all containers 91 | start.sh data – set up the data folder needed for the containers, but run none of them. Useful for personalized setups. 92 | 93 | Check https://github.com/ct-Open-Source/ct-Smart-Home/ for updates. 94 | ``` 95 | 96 | ## Manual start 97 | 98 | * run `./start.sh data` to create the necessary folders 99 | * Use `docker-compose up -d` to start the containers 100 | * If you do not want to start Zigbee2mqtt, add the name of the Node-RED container to the docker-compose command: `docker-compose up -d nodered`. The MQTT container will always be started, because it's a dependency of Node-RED. 101 | 102 | ## Troubleshooting 103 | 104 | ### I've made an update to the system, but now I get errors about "orphaned containers". How do I fix this? 105 | 106 | This happens when there are containers running that haven't been defined in the `docker-compose.yml`. The cause for this might be a failed deployment or that a container was added to or removed from the c't-Smart-Home setup. You can fix this by running `docker-compose down --remove-orphans`, followed by `./start.sh start`. 107 | 108 | ### After the latest update Mosquitto won't accept connections. What is happening? 109 | 110 | From version 2.x onward Mosquitto explicitly requires a option to enable anonymous logins. While it is highly recommended to require authentication for Mosquitto, it's okay for a beginner setup and for testing to have no authentication. To reactivate anonymous logins open the file `./data/mqtt/conf/mosquitto.conf` and add the line `allow_anonymous true`. Then run `docker-compose restart mqtt`. 111 | 112 | ### I can't see any devices in the Zigbee2Mqtt nodes provided by node-red-contrib-zigbee2mqtt. 113 | 114 | If you upgrade from an existing installation, you must add `homeassistant: true` to `./data/zigbee/configuration.yaml`. 115 | 116 | ### The Zigbee2Mqtt web-frontend doesn't work for me, but the service is running just fine. Did I miss something? 117 | 118 | You probably did an update from an earlier version of c't-Smart-Home to a recent one. You must add a few lines to `./data/zigbee/configuration.yaml`. Have a look at their [documentation of the frontend](https://www.zigbee2mqtt.io/information/frontend.htm). Make sure to set the option `port` to `1881`. 119 | 120 | ### Why doesn't c't-Smart-Home provide a complete setup with HTTPS support for the services. What's the issue? 121 | 122 | There is no technical issue. Using a reverse proxy like [Traefik](https://traefik.io/) works just fine. But this will add an additional level of complexity to the system, and might encourage inexperienced users to put the setup on the open internet for convenience. This is *absolutely not recommended*. 123 | 124 | An experienced user is able to setup Traefik in a short amount of time and will be able to secure the services in a proper way. 125 | 126 | ### I'm trying to use the setup on my NAS, but I can't run the containers 127 | 128 | Sadly most NAS vendors use modified versions of Docker that miss some features. You'll possibly have to run the containers manually oder change some options in the `docker-compose.yml`. We sadly can't provide support for NAS setups due to the varying featureset of their Docker support. 129 | 130 | ### Can I run c't-Smart-Home on a Mac? 131 | 132 | You could try, but we don't support it on a Mac. 133 | 134 | ### I'm missing some nodes after an update. What happended? 135 | 136 | We probably removed some unnecessary or outdated nodes. Check which are missing and look in the palette for them. Most likely you can reinstall them from there. 137 | 138 | ### Node-RED won't start after an update. The logs show permission errors. How do I fix this? 139 | 140 | For security reasons the Node-RED service won't run as root anymore. It now runs with the GID and UID 1000. To fix this issue you must set the GID and UID of data/nodered and all of its content to 1000. You can use `start.sh fix` to correct those issues. 141 | 142 | ## Container images and Versions 143 | 144 | The Node-RED container image is a variation on [the official one](https://hub.docker.com/r/nodered/node-red) provided by the Node-RED project. We provide versions based on Node.js versions 10 (Maintenance LTS), 12 (Maintenance LTS) and 14 (Active LTS). See Node.js [releases page](https://nodejs.org/en/about/releases/) for support cycles. The container image based on Active LTS will always be the default. You can freely modify your copy of the compose file to use a different container image or even create your own image. 145 | 146 | The `:latest` image is rebuild upon new releases and updated weekly to include updates to Node-RED and the underlying libraries. The `:devel` images are being rebuilt every night. 147 | 148 | | Container-Tag | Node-RED version | Node.js version | Notes | Arch | 149 | | - | - | - | - | - | 150 | | **Release versions** 151 | | **latest** | **latest release version** | **12** | latest release version | all | 152 | | latest-10 | 1.x | 10 | latest release version | all | 153 | | latest-12 | 1.x | 12 | latest release version | all | 154 | | latest-14 | 1.x | 14 | latest release version | all | 155 | | **Development versions** | 156 | | **devel** | **latest devel version** | **14** | **build from current devel** | all | 157 | | devel-10 | 1.x | 10 | build from current devel | all | 158 | | devel-12 | 1.x | 12 | build from current devel | all | 159 | | devel-14 | 1.x | 14 | build from current devel | all | 160 | | **Deprecated relases** | 161 | | release-1.1.1-amd64 | 0.20.5 | 8 | deprecated | amd64 | 162 | | release-1.1.1-arm32v7 | 0.20.5 | 8 | deprecated | arm32v7 | 163 | 164 | We also use the `:latest` versions of [Eclipse Mosquitto](https://hub.docker.com/_/eclipse-mosquitto) and [Zigbee2mqtt](https://github.com/Koenkk/zigbee2mqtt.io). 165 | 166 | The Docker images are hosted on the [Docker Hub](https://hub.docker.com/repository/docker/ctmagazin/ctnodered) and on [GitHubs Container Registry ghcr.io](https://github.com/orgs/ct-Open-Source/packages/container/package/ctnodered). The default is to use GitHubs Container Registry, since the rate limits and retention policies of the Docker Hub are possible causes for future issues. 167 | 168 | ## Further information 169 | 170 | ### Articles in c't 171 | 172 | This project is described in the German computer magazine c't: [https://ct.de/smarthome](https://ct.de/smarthome) 173 | 174 | Zigbee2mqtt is described here: [https://ct.de/ygdp](https://ct.de/ygdp) 175 | 176 | ### Documentation 177 | 178 | [Node-RED documentation](https://nodered.org/docs/) 179 | 180 | [Zigbee2MQTT documentation](https://www.zigbee2mqtt.io/) 181 | (Note: If you use and enjoy the Zigbee service, consider [sponsoring Koen Kanters](https://www.paypal.com/paypalme/koenkk) great work!) 182 | 183 | [Mosquitto documentation](https://mosquitto.org/man/mosquitto-8.html) 184 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | 3 | services: 4 | nodered: 5 | image: ghcr.io/ct-open-source/ctnodered:latest 6 | volumes: 7 | - ./data/nodered:/data 8 | - /etc/localtime:/etc/localtime 9 | depends_on: 10 | - mqtt 11 | restart: always 12 | network_mode: "host" 13 | environment: 14 | - TZ=Europe/Berlin 15 | 16 | mqtt: 17 | image: "eclipse-mosquitto" 18 | ports: 19 | - "1883:1883" 20 | - "9001:9001" 21 | volumes: 22 | - ./data/mqtt:/mosquitto 23 | - /etc/localtime:/etc/localtime 24 | restart: always 25 | environment: 26 | - TZ=Europe/Berlin 27 | 28 | zigbee: 29 | image: koenkk/zigbee2mqtt 30 | volumes: 31 | - ./data/zigbee:/app/data 32 | - /run/udev:/run/udev:ro 33 | - /etc/localtime:/etc/localtime 34 | devices: 35 | - "/dev/ttyACM0:/dev/ttyACM0" 36 | - "/dev/ttyACM1:/dev/ttyACM1" 37 | restart: always 38 | privileged: true 39 | ports: 40 | - 1881:1881 41 | environment: 42 | - TZ=Europe/Berlin 43 | -------------------------------------------------------------------------------- /docker-image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG NODE_VERSION=14 2 | ARG OS=alpine 3 | 4 | #### Stage BASE ######################################################################################################## 5 | FROM node:${NODE_VERSION}-${OS} AS base 6 | 7 | # Copy scripts 8 | COPY scripts/*.sh /tmp/ 9 | 10 | # Install tools, create Node-RED app and data dir, add user and set rights 11 | RUN set -ex && \ 12 | apk add --no-cache \ 13 | bash \ 14 | tzdata \ 15 | iputils \ 16 | curl \ 17 | nano \ 18 | git \ 19 | openssl \ 20 | openssh-client \ 21 | su-exec \ 22 | avahi \ 23 | avahi-compat-libdns_sd \ 24 | dbus \ 25 | ffmpeg \ 26 | bluez &&\ 27 | dbus-uuidgen --ensure && \ 28 | mkdir -p /usr/src/node-red /data && \ 29 | deluser --remove-home node && \ 30 | adduser -h /usr/src/node-red -D -H node-red -u 1000 && \ 31 | chown -R node-red:root /data && chmod -R g+rwX /data && \ 32 | chown -R node-red:root /usr/src/node-red && chmod -R g+rwX /usr/src/node-red 33 | 34 | # Set work directory 35 | WORKDIR /usr/src/node-red 36 | 37 | # package.json contains Node-RED NPM module and node dependencies 38 | COPY package.json . 39 | 40 | #### Stage BUILD ####################################################################################################### 41 | FROM base AS build 42 | 43 | # Install Build tools 44 | RUN apk add --no-cache --virtual buildtools build-base linux-headers udev eudev-dev avahi-dev libusb-dev libc-dev python3 && \ 45 | npx npm-check-updates -u && \ 46 | npm install --unsafe-perm --no-update-notifier --only=production --no-optional && \ 47 | /tmp/remove_native_gpio.sh && \ 48 | npm dedupe && \ 49 | npm cache clean --force && \ 50 | npm prune --production && \ 51 | apk del buildtools && \ 52 | cp -R node_modules prod_node_modules 53 | 54 | 55 | #### Stage RELEASE ##################################################################################################### 56 | FROM base AS RELEASE 57 | USER root 58 | ARG BUILD_DATE 59 | ARG BUILD_VERSION 60 | ARG BUILD_REF 61 | ARG ARCH 62 | ARG NODE_RED_VERSION=latest 63 | ARG TAG_SUFFIX=default 64 | 65 | LABEL org.label-schema.build-date=${BUILD_DATE} \ 66 | org.label-schema.docker.dockerfile="Dockerfile" \ 67 | org.label-schema.license="Apache-2.0" \ 68 | org.label-schema.name="Node-RED for c't-Smart-Home" \ 69 | org.label-schema.version=${BUILD_VERSION} \ 70 | org.label-schema.description="Low-code programming for event-driven applications." \ 71 | org.label-schema.url="https://www.ct.de/smarthome" \ 72 | org.label-schema.vcs-ref=${BUILD_REF} \ 73 | org.label-schema.vcs-type="Git" \ 74 | org.label-schema.vcs-url="https://github.com/ct-Open-Source/ct-Smart-Home" \ 75 | org.label-schema.arch=${ARCH} \ 76 | authors="Dave Conway-Jones, Nick O'Leary, James Thomas, Raymond Mouthaan, Merlin Schumacher, Jan Mahn, Andrijan Möcker, Anton Golubev, J. Völker, GnafGnaf" \ 77 | org.opencontainers.image.source=https://github.com/ct-Open-Source/ct-Smart-Home 78 | 79 | COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules 80 | COPY entrypoint.sh /usr/src/node-red/entrypoint.sh 81 | 82 | # Chown, install devtools & Clean up 83 | RUN rm -r /tmp/* && \ 84 | setcap 'cap_net_raw+eip' `which l2ping` && \ 85 | setcap 'cap_net_raw+eip' `which node` 86 | 87 | # Env variables 88 | ENV NODE_RED_VERSION=$NODE_RED_VERSION \ 89 | NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules \ 90 | FLOWS=flows.json 91 | 92 | # ENV NODE_RED_ENABLE_SAFE_MODE=true # Uncomment to enable safe start mode (flows not running) 93 | ENV NODE_RED_ENABLE_PROJECTS=true 94 | 95 | # User configuration directory volume 96 | VOLUME ["/data"] 97 | 98 | # Expose the listening port of node-red 99 | EXPOSE 1880 100 | 101 | # Add a healthcheck (default every 30 secs) 102 | HEALTHCHECK CMD curl http://localhost:1880/ || exit 1 103 | 104 | CMD ["/bin/sh", "/usr/src/node-red/entrypoint.sh" ] 105 | -------------------------------------------------------------------------------- /docker-image/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /docker-image/README.md: -------------------------------------------------------------------------------- 1 | # Build your own Docker image 2 | 3 | The docker-custom directory contains files you need to build your own images. 4 | 5 | The follow steps describe in short which steps to take to build your own images. 6 | 7 | ## 1. git clone 8 | 9 | Clone the Node-RED Docker project from github 10 | ```shell script 11 | git clone https://github.com/node-red/node-red-docker.git 12 | ``` 13 | 14 | Change dir to docker-custom 15 | ```shell script 16 | cd node-red-docker/docker-custom 17 | ``` 18 | 19 | ## 1. **package.json** 20 | 21 | - Change the node-red version in package.json (from the docker-custom directory) to the version you require 22 | - Add optionally packages you require 23 | 24 | ## 2. **docker-make.sh** 25 | 26 | The `docker-make.sh` is a helper script to build a custom Node-RED docker image. 27 | 28 | Change the build arguments as needed: 29 | 30 | - `--build-arg ARCH=amd64` : architecture your are building for (arm32v6, arm32v7, arm64v8, amd64) 31 | - `--build-arg NODE_VERSION=10` : NodeJS version you like to use 32 | - `--build-arg NODE_RED_VERSION=${NODE_RED_VERSION}` : don't change this, ${NODE_RED_VERSION} gets populated from package.json 33 | - `--build-arg OS=alpine` : the linux distro to use (alpine) 34 | - `--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")"` : don't change this 35 | - `--build-arg TAG_SUFFIX=default` : to build the default or minimal image 36 | - `--file Dockerfile.custom` : Dockerfile to use to build your image. 37 | - `--tag testing:node-red-build` : set the image name and tag 38 | 39 | ## 3. **Run docker-make.sh** 40 | 41 | Run `docker-make.sh` 42 | 43 | ```shell script 44 | $ ./docker-make.sh 45 | ``` 46 | 47 | This starts building your custom image and might take a while depending on the system you are running on. 48 | 49 | When building is done you can run the custom image by the following command: 50 | 51 | ```shell script 52 | $ docker run -it -p1880:1880 testing:node-red-build 53 | ``` 54 | 55 | With the following command you can verify your docker image: 56 | 57 | ```shell script 58 | $ docker inspect testing:node-red-build 59 | ``` 60 | 61 | ## 4. **Advanced Configuration** 62 | 63 | `Dockerfile.custom` can be modified as required. To add more applications the `scripts/install_devtools.sh` can be modified as needed. 64 | -------------------------------------------------------------------------------- /docker-image/docker-make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export NODE_RED_VERSION=$(grep -oE "\"node-red\": \"(\w*.\w*.\w*.\w*.\w*.)" package.json | cut -d\" -f4) 3 | 4 | echo "#########################################################################" 5 | echo "node-red version: ${NODE_RED_VERSION}" 6 | echo "#########################################################################" 7 | 8 | docker build --no-cache \ 9 | --build-arg ARCH=amd64 \ 10 | --build-arg NODE_VERSION=12 \ 11 | --build-arg NODE_RED_VERSION=${NODE_RED_VERSION} \ 12 | --build-arg OS=alpine \ 13 | --build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")" \ 14 | --build-arg TAG_SUFFIX=default \ 15 | --file Dockerfile \ 16 | --squash \ 17 | --tag testing:node-red-build . 18 | -------------------------------------------------------------------------------- /docker-image/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [[ -e /var/run/dbus.pid ]] && su-exec root rm -f /var/run/dbus.pid 3 | [[ -e /var/run/avahi-daemon/pid ]] && su-exec root rm -f /var/run/avahi-daemon/pid 4 | [[ -e /var/run/dbus/system_bus_socket ]] && su-exec root rm -f /var/run/dbus/system_bus_socket 5 | 6 | echo "Starting dbus daemon" 7 | su-exec root dbus-daemon --system --fork 8 | 9 | until [ -e /var/run/dbus/system_bus_socket ]; do 10 | sleep 1s 11 | done 12 | 13 | echo "Starting Avahi daemon" 14 | su-exec root avahi-daemon -D --no-chroot -f /etc/avahi/avahi-daemon.conf 15 | 16 | echo "Starting Node-Red" 17 | su-exec node-red npm start --cache /data/.npm -- --userDir /data 18 | -------------------------------------------------------------------------------- /docker-image/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ctnodered", 3 | "version": "1.5.0", 4 | "description": "A visual tool for wiring the Internet of Things", 5 | "homepage": "hhttps://www.ct.de/smarthome", 6 | "license": "Apache-2.0", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/ct-Open-Source/ct-Smart-Home.git" 10 | }, 11 | "main": "node_modules/node-red/red/red.js", 12 | "scripts": { 13 | "start": "node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS", 14 | "debug": "node --inspect=0.0.0.0:9229 $NODE_OPTIONS node_modules/node-red/red.js $FLOWS", 15 | "debug_brk": "node --inspect=0.0.0.0:9229 --inspect-brk $NODE_OPTIONS node_modules/node-red/red.js $FLOWS" 16 | }, 17 | "contributors": [ 18 | { 19 | "name": "Dave Conway-Jones" 20 | }, 21 | { 22 | "name": "Nick O'Leary" 23 | }, 24 | { 25 | "name": "James Thomas" 26 | }, 27 | { 28 | "name": "Raymond Mouthaan" 29 | }, 30 | { 31 | "name": "Jan Mahn" 32 | }, 33 | { 34 | "name": "Merlin Schumacher" 35 | }, 36 | { 37 | "name": "Andrijan Möcker" 38 | }, 39 | { 40 | "name": "Anton Golubev" 41 | }, 42 | { 43 | "name": "J. Völker" 44 | }, 45 | { 46 | "name": "GnafGnaf" 47 | } 48 | ], 49 | "dependencies": { 50 | "node-red": "latest", 51 | "node-red-contrib-fritz": "*", 52 | "node-red-contrib-homekit-bridged": "*", 53 | "node-red-contrib-noble-bluetooth": "*", 54 | "node-red-contrib-tado-client": "*", 55 | "node-red-contrib-zigbee2mqtt": "*", 56 | "node-red-dashboard": "*", 57 | "@abandonware/bluetooth-hci-socket": "*" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /docker-image/scripts/remove_native_gpio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | # Remove native GPIO node if exists 5 | if [[ -d "/usr/src/node-red/node_modules/@node-red/nodes/core/hardware" ]]; then 6 | echo "Removing native GPIO node" 7 | rm -r /usr/src/node-red/node_modules/@node-red/nodes/core/hardware 8 | else 9 | echo "Skip removing native GPIO node" 10 | fi 11 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function detect_zigbee_device { 4 | if usb_dev=$(lsusb -d 0451:); then 5 | usb_dev_count=$(ls -1 /dev/ttyACM* 2>/dev/null | wc -l) 6 | if [ "$usb_dev_count" -gt 1 ]; then 7 | >&2 echo "There are multiple devices connected, that could be Zigbee USB adaptors. Please check data/zigbee/configuration.yml, if the device is wrong. /dev/ttyACM0 is used as the default." 8 | 9 | echo "/dev/ttyACM0" 10 | fi 11 | 12 | if [ -c /dev/ttyACM0 ]; then 13 | echo "/dev/ttyACM0" 14 | else 15 | >&2 echo "I could not find /dev/ttyACM0. Please check your hardware." 16 | fi 17 | else 18 | >&2 echo No Texas Instruments USB device found. 19 | 20 | echo "False" 21 | fi 22 | } 23 | 24 | function create_mosquitto_config { 25 | cat > data/mqtt/config/mosquitto.conf < data/zigbee/configuration.yaml <&2 106 | exit 1 107 | fi 108 | 109 | if ! [ -x "$(command -v git)" ]; then 110 | echo '⚠️ Error: git is not installed.' >&2 111 | exit 1 112 | fi 113 | } 114 | 115 | function start { 116 | 117 | device=$(detect_zigbee_device) 118 | if [ $device == "False" ]; then 119 | echo '⚠️ No Zigbee adaptor found. Not starting Zigbee2MQTT.' 120 | container="nodered mqtt" 121 | fi 122 | 123 | if [ ! -d data ]; then 124 | build_data_structure 125 | fi 126 | 127 | echo '🏃 Starting the containers' 128 | docker-compose up -d $container 129 | echo '⚠️ After you made yourself familiar with the setup, it'"'"'s strongly suggested to secure the services. Read the "Security" section in the README!' 130 | } 131 | 132 | function stop { 133 | echo '🛑 Stopping all containers' 134 | docker-compose stop 135 | } 136 | 137 | function update { 138 | 139 | if [[ ! -d ".git" ]] 140 | then 141 | echo "🛑You have manually downloaded the release version of c't-Smart-Home. 142 | The automatic update only works with a cloned Git repository. 143 | Try backing up your settings shutting down all containers with 144 | 145 | docker-compose down --remove orphans 146 | 147 | Then copy the current version from GitHub to this folder and run 148 | 149 | ./start.sh start. 150 | 151 | Alternatively create a Git clone of the repository." 152 | exit 1 153 | fi 154 | echo '☠️ Shutting down all running containers and removing them.' 155 | docker-compose down --remove-orphans 156 | if [ ! $? -eq 0 ]; then 157 | echo '⚠️ Updating failed. Please check the repository on GitHub.' 158 | fi 159 | echo '⬇️ Pulling latest release via git.' 160 | git fetch --tags 161 | latestTag=$(git describe --tags `git rev-list --tags --max-count=1`) 162 | git checkout $latestTag 163 | if [ ! $? -eq 0 ]; then 164 | echo '⚠️ Updating failed. Please check the repository on GitHub.' 165 | fi 166 | echo '⬇️ Pulling docker images.' 167 | docker-compose pull 168 | if [ ! $? -eq 0 ]; then 169 | echo '⚠️ Updating failed. Please check the repository on GitHub.' 170 | fi 171 | start 172 | fix_permissions 173 | } 174 | 175 | check_dependencies 176 | 177 | case "$1" in 178 | "start") 179 | start 180 | ;; 181 | "stop") 182 | stop 183 | ;; 184 | "update") 185 | update 186 | ;; 187 | "fix") 188 | fix_permissions 189 | ;; 190 | "data") 191 | build_data_structure 192 | ;; 193 | * ) 194 | cat << EOF 195 | 🏡 c't-Smart-Home – setup script 196 | ————————————————————————————— 197 | Usage: 198 | start.sh update – update to the latest release version 199 | start.sh fix – correct the permissions in the data folder 200 | start.sh start – run all containers 201 | start.sh stop – stop all containers 202 | start.sh data – set up the data folder needed for the containers, but run none of them. Useful for personalized setups. 203 | 204 | Check https://github.com/ct-Open-Source/ct-Smart-Home/ for updates. 205 | EOF 206 | ;; 207 | esac 208 | --------------------------------------------------------------------------------