diff --git a/calimero-server/Dockerfile b/calimero-server/Dockerfile index 5fc29b1..3a52567 100644 --- a/calimero-server/Dockerfile +++ b/calimero-server/Dockerfile @@ -57,11 +57,10 @@ RUN cd /opt/calimero/ \ && rm -R org # https://s01.oss.sonatype.org/#nexus-search;quick~io.calimero RUN cd /opt/calimero/ \ - && wget https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/io/calimero/calimero-rxtx/3.0-SNAPSHOT/calimero-rxtx-3.0-20240209.103824-5.jar \ - && wget https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/io/calimero/calimero-core/3.0-SNAPSHOT/calimero-core-3.0-20240209.103824-6.jar \ - && wget https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/io/calimero/calimero-device/3.0-SNAPSHOT/calimero-device-3.0-20240209.103824-5.jar \ - && wget https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/io/calimero/calimero-server/3.0-SNAPSHOT/calimero-server-3.0-20240209.103824-5.jar - + && wget https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/io/calimero/calimero-rxtx/3.0-SNAPSHOT/calimero-rxtx-3.0-20240331.030215-6.jar \ + && wget https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/io/calimero/calimero-core/3.0-SNAPSHOT/calimero-core-3.0-20240818.140036-12.jar \ + && wget https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/io/calimero/calimero-device/3.0-SNAPSHOT/calimero-device-3.0-20240818.140053-9.jar \ + && wget https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/io/calimero/calimero-server/3.0-SNAPSHOT/calimero-server-3.0-20240818.140122-11.jar ARG BUILD_FROM FROM $BUILD_FROM @@ -76,4 +75,4 @@ COPY --from=build /opt/calimero /opt/calimero COPY run.sh / RUN chmod a+x /run.sh -CMD [ "/run.sh" ] \ No newline at end of file +CMD [ "/run.sh" ] diff --git a/calimero-server/config.json b/calimero-server/config.json index cbac398..a19057d 100644 --- a/calimero-server/config.json +++ b/calimero-server/config.json @@ -12,6 +12,7 @@ "uart": true, "usb": true, "options": { + "discovery_name": "Hass OS KNXnet/IP Server", "knx_address": "1.1.0", "client_address_start": "1.1.101", "client_address_count": 5, @@ -21,6 +22,7 @@ "knx_source_override": true }, "schema": { + "discovery_name": "str", "knx_address": "str", "client_address_start": "str", "client_address_count": "int", diff --git a/calimero-server/run.sh b/calimero-server/run.sh index e0d64a1..3744242 100644 --- a/calimero-server/run.sh +++ b/calimero-server/run.sh @@ -1,5 +1,6 @@ #!/usr/bin/with-contenv bashio +DISCOVERY_NAME=$(bashio::config 'discovery_name') KNX_ADDRESS=$(bashio::config 'knx_address') CLIENT_ADDRESS_START=$(bashio::config 'client_address_start') CLIENT_ADDRESS_COUNT=$(bashio::config 'client_address_count') @@ -37,7 +38,7 @@ fi CONFIG_XML=" - + diff --git a/remote-backup/Dockerfile b/remote-backup/Dockerfile deleted file mode 100644 index 4d016bf..0000000 --- a/remote-backup/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -ARG BUILD_FROM -FROM $BUILD_FROM - -# Add env -ENV LANG C.UTF-8 - -# Setup base -RUN apk add --no-cache openssh-client - -# Hass.io CLI -ARG BUILD_ARCH -RUN apk add --no-cache curl \ - && curl -Lso /usr/bin/ha https://github.com/home-assistant/cli/releases/download/4.18.0/ha_${BUILD_ARCH} \ - && chmod a+x /usr/bin/ha - -# Copy data -COPY run.sh / -RUN chmod a+x /run.sh - -CMD [ "/run.sh" ] diff --git a/remote-backup/LICENSE.md b/remote-backup/LICENSE.md deleted file mode 100644 index 463f43b..0000000 --- a/remote-backup/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Nicolai Bjerre Pedersen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/remote-backup/README.md b/remote-backup/README.md deleted file mode 100644 index 9526461..0000000 --- a/remote-backup/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Remote Backup Hass.io Add-On - -Automatically create Hass.io snapshots to remote server location using SCP. - -When the add-on is started the following happens: -1. Snapshot is created locally with a timestamp name, e.g. `Automated backup 2018-03-04 04:00`. -1. It is copied to the specified remote location using SCP. -1. The local backup is removed again (optional). - -Based on https://github.com/rccoleman/hassio-remote-backup / https://github.com/overkill32/hassio-remote-backup - -## Add-On Configuration - -The add-on requires the following configuration: -```json -{ - "ssh_host": "192.168.1.2", - "ssh_port": 22, - "ssh_user": "root", - "ssh_key": [ -"-----BEGIN RSA PRIVATE KEY-----", -"MIICXAIBAAKBgQDTkdD4ya/Qxz5xKaKojVIOVWjyeyEoEuAafAvYvppqmaBhyh4N", -"5av4i87y8tdGusdq7V0Zj0+js4jEdvJRDrXJBrp1neLfsjkF6t1XLfrA51Ll9SXF", -"...", -"X+6r/gTvUEQv1ufAuUE5wKcq9FsbnTa3FOF0PdQDWl0=", -"-----END RSA PRIVATE KEY-----" - ], - "remote_directory": "~/hassio-backups", - "password": "password_protect_it", - "keep_local_backup": "14" -} -``` - -`password` and `keep_local_backup` are optional attributes. `keep_local_backup` controls how many local backups you want to preserve. Default (`""`) is to keep no local backups created from this addon. If `all` then all local backups will be preserved. A positive integer will determine how many of the latest backups will be preserved. Note this will delete other local backups created outside this addon. - -## Example automating daily backups - -_configuration.yaml_ -```yaml -automations: - - alias: Daily Backup at 4 AM - trigger: - platform: time - at: '4:00:00' - action: - - service: hassio.addon_start - data: - addon: local_remote_backup -``` \ No newline at end of file diff --git a/remote-backup/config.json b/remote-backup/config.json deleted file mode 100644 index c4585e5..0000000 --- a/remote-backup/config.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "Remote Backup", - "version": "0.9", - "slug": "remote_backup", - "description": "Exploit hass cli backups and SCP to create remote backups to specified server", - "arch": ["armhf", "armv7", "aarch64", "amd64", "i386"], - "url": "https://github.com/aschamberger/hassio-addons/", - "init": false, - "startup": "once", - "boot": "manual", - "hassio_api": true, - "hassio_role": "backup", - "map": ["backup:rw"], - "options": { - "ssh_host": "", - "ssh_port": 22, - "ssh_user": "", - "ssh_key": [], - "remote_directory": "", - "password": "", - "keep_local_backup": "" - }, - "schema": { - "ssh_host": "str", - "ssh_port": "int", - "ssh_user": "str", - "ssh_key": ["str"], - "remote_directory": "str", - "password": "str", - "keep_local_backup": "match(^(all|[+]?\\d*)$)" - } -} diff --git a/remote-backup/icon.png b/remote-backup/icon.png deleted file mode 100644 index 32c4729..0000000 Binary files a/remote-backup/icon.png and /dev/null differ diff --git a/remote-backup/logo.png b/remote-backup/logo.png deleted file mode 100644 index 32c4729..0000000 Binary files a/remote-backup/logo.png and /dev/null differ diff --git a/remote-backup/run.sh b/remote-backup/run.sh deleted file mode 100644 index 3e67b82..0000000 --- a/remote-backup/run.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/with-contenv bash - -CONFIG_PATH=/data/options.json - -# parse inputs from options -SSH_HOST=$(jq --raw-output ".ssh_host" $CONFIG_PATH) -SSH_PORT=$(jq --raw-output ".ssh_port" $CONFIG_PATH) -SSH_USER=$(jq --raw-output ".ssh_user" $CONFIG_PATH) -SSH_KEY=$(jq --raw-output ".ssh_key[]" $CONFIG_PATH) -REMOTE_DIRECTORY=$(jq --raw-output ".remote_directory" $CONFIG_PATH) -PASSWORD=$(jq --raw-output '.password' $CONFIG_PATH) -KEEP_LOCAL_BACKUP=$(jq --raw-output '.keep_local_backup' $CONFIG_PATH) - -function add-ssh-key { - echo "Adding SSH key" - mkdir -p /.ssh - ( - echo "Host remote" - echo " IdentityFile /.ssh/id" - echo " HostName ${SSH_HOST}" - echo " User ${SSH_USER}" - echo " Port ${SSH_PORT}" - echo " StrictHostKeyChecking no" - ) > "/.ssh/config" - - while read -r line; do - echo "$line" >> /.ssh/id - done <<< "$SSH_KEY" - - chmod 600 "/.ssh/config" - chmod 600 "/.ssh/id" -} - -function copy-backup-to-remote { - - cd /backup/ - echo "Copying ${slug}.tar to ${REMOTE_DIRECTORY} on ${SSH_HOST} using SCP" - scp -F "/.ssh/config" "${slug}.tar" remote:"${REMOTE_DIRECTORY}" -} - -function delete-local-backup { - - ha backups reload - - if [[ ${KEEP_LOCAL_BACKUP} == "all" ]]; then - : - elif [[ -z ${KEEP_LOCAL_BACKUP} ]]; then - echo "Deleting local backup: ${slug}" - ha backups remove ${slug} - else - - last_date_to_keep=$($HA --raw-json backups list | jq .data.backups[].date | sort -r | \ - head -n "${KEEP_LOCAL_BACKUP}" | tail -n 1 | xargs date -D "%Y-%m-%dT%T" +%s --date ) - - ha --raw-json backups list | jq -c .data.backups[] | while read backup; do - if [[ $(echo ${backup} | jq .date | xargs date -D "%Y-%m-%dT%T" +%s --date ) -lt ${last_date_to_keep} ]]; then - echo "Deleting local backup: $(echo ${backup} | jq -r .slug)" - ha backups remove $(echo ${backup} | jq -r .slug) - fi - done - - fi - echo Exiting -} - -function create-local-backup { - name="Automated backup $(date +'%Y-%m-%d %H:%M')" - echo "Creating local backup: \"${name}\"" - if [[ -z $PASSWORD ]]; then - slug=$(ha backups new --name="${name}" | cut -d' ' -f2) - else - slug=$(ha backups new --name="${name}" --password="${PASSWORD}" | cut -d' ' -f2) - fi - echo "Backup created: ${slug}" -} - -add-ssh-key -create-local-backup -copy-backup-to-remote -delete-local-backup - -echo "Backup process done!" -exit 0 diff --git a/repository.json b/repository.json index 5ca85d1..0445663 100644 --- a/repository.json +++ b/repository.json @@ -1,5 +1,5 @@ { - "name": "aschamberger Hass.io add-on repository", - "url": "https://github.com/aschamberger/hassio-addons", - "maintainer": "Andreas Schamberger" + "name": "George Gougoudis Hass.io add-on repository", + "url": "https://github.com/georgegougoudis/hassio-addons", + "maintainer": "George Gougoudis" } diff --git a/snmp-trap/Dockerfile b/snmp-trap/Dockerfile deleted file mode 100644 index 31d7ebe..0000000 --- a/snmp-trap/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -ARG BUILD_FROM -FROM $BUILD_FROM - -ENV LANG C.UTF-8 - -RUN apk update \ - && apk add --no-cache python3 py3-pip - -RUN pip install -f https://wheels.home-assistant.io/musllinux/ pysnmplib - -COPY trap.py / -RUN chmod a+x /trap.py -COPY run.sh / -RUN chmod a+x /run.sh - -CMD [ "/run.sh" ] \ No newline at end of file diff --git a/snmp-trap/README.md b/snmp-trap/README.md deleted file mode 100644 index e16d5a4..0000000 --- a/snmp-trap/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Home Assistant Add-On: SNMP Trap Reciever - -A SNMP trap reciever that will publish them as events to Home Assisstant via HTTP API based on the [pysnmp](https://github.com/pysnmp/pysnmp) python library. - -In Home Assisstant the traps can be used in an automation. Each event has a JSON payload like this: -``` -{"_source": "127.0.0.1", "_uptime": "123", "_trap_oid": "1.3.6.1.6.3.1.1.5.3", "1.3.6.1.2.1.2.2.1.1.5": "5"} -``` - -OIDs for my switch: -* "1.3.6.1.6.3.1.1.5.3" = link down -* "1.3.6.1.6.3.1.1.5.4" = link up -* "1.3.6.1.2.1.2.2.1.1.x" = port x - -Blueprint for deactivating the LAN port on link down: -https://gist.github.com/aschamberger/0ab0bd03561288cbb2ab079cad8f8a86 - -## Add-On Configuration - -The add-on requires the following configuration: -``` -port: 162 -community_string: public -``` - -`port` The port the reciever listens on (default: 162). - -`community_string` SNMP community string name (default: public). - -## Testing - -Sending traps via `snmptrap` from a Linux system: -``` -sudo apt-get install snmp -snmptrap -v2c -c public homeassistant:162 123 1.3.6.1.6.3.1.1.5.3 1.3.6.1.2.1.2.2.1.1.5 i 5 -``` -The command above sends a link down for port 5. - -## Links - -* supervisor token for HTTP API access: https://developers.home-assistant.io/docs/add-ons/communication/ -* based on https://pysnmp.readthedocs.io/en/latest/examples/v3arch/asyncio/manager/ntfrcv/transport-tweaks.html diff --git a/snmp-trap/config.json b/snmp-trap/config.json deleted file mode 100644 index ee35cac..0000000 --- a/snmp-trap/config.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "SNMP Trap Reciever", - "version": "0.1.4", - "slug": "snmp_trap", - "description": "Recieve SNMP v1/v2c traps and publish them as events to Home Assisstant", - "arch": ["armhf", "armv7", "aarch64", "amd64", "i386"], - "url": "https://github.com/aschamberger/hassio-addons/", - "init": false, - "startup": "services", - "boot": "auto", - "host_network": true, - "homeassistant_api": true, - "options": { - "port": 162, - "community_string": "public" - }, - "schema": { - "port": "int", - "community_string": "str" - } -} \ No newline at end of file diff --git a/snmp-trap/icon.png b/snmp-trap/icon.png deleted file mode 100644 index 1e8628d..0000000 Binary files a/snmp-trap/icon.png and /dev/null differ diff --git a/snmp-trap/logo.png b/snmp-trap/logo.png deleted file mode 100644 index 1e8628d..0000000 Binary files a/snmp-trap/logo.png and /dev/null differ diff --git a/snmp-trap/run.sh b/snmp-trap/run.sh deleted file mode 100644 index e3ae60e..0000000 --- a/snmp-trap/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/with-contenv bash - -CONFIG_PATH=/data/options.json - -export PORT=$(jq --raw-output ".port" $CONFIG_PATH) -export COMMUNITY_STRING=$(jq --raw-output ".community_string" $CONFIG_PATH) -export PYTHONUNBUFFERED=1 - -exec python3 trap.py diff --git a/snmp-trap/trap.py b/snmp-trap/trap.py deleted file mode 100644 index 18e5f72..0000000 --- a/snmp-trap/trap.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/python - -# based on https://pysnmp.readthedocs.io/en/latest/examples/v3arch/asyncio/manager/ntfrcv/transport-tweaks.html -# install https://www.piwheels.org/ to run on a dietpi/pi os - -import os -import asyncio -import requests -import json -from pysnmp.entity import engine, config -from pysnmp.carrier.asyncio.dgram import udp -from pysnmp.entity.rfc3413 import ntfrcv - -# get config from ENV vars -hassHost = "http://supervisor/core/api" -hassBearer = os.getenv('SUPERVISOR_TOKEN') -port = os.getenv('PORT') -communityString = os.getenv('COMMUNITY_STRING') - -# parameters for calling hass -url = hassHost + "/events/snmp_trap" -headers = { - "Authorization": "Bearer " + hassBearer, - "content-type": "application/json" -} - -# Get the event loop for this thread -loop = asyncio.new_event_loop() -asyncio.set_event_loop(loop) - -# Create SNMP engine with autogenernated engineID and pre-bound -# to socket transport dispatcher -snmpEngine = engine.SnmpEngine() - -# Transport setup: UDP over IPv4 -config.addTransport( - snmpEngine, - udp.domainName + (1,), - udp.UdpTransport().openServerMode(('0.0.0.0', port)) -) - -# SNMPv1/2c setup - -# SecurityName <-> CommunityName mapping -config.addV1System(snmpEngine, 'my-area', communityString) - -# Callback function for receiving notifications -# noinspection PyUnusedLocal -def cbFun(snmpEngine, stateReference, contextEngineId, - contextName, varBinds, cbCtx): - - transportDomain, transportAddress = snmpEngine.msgAndPduDsp.getTransportInfo(stateReference) - - #print('Notification from %s, SNMP Engine %s, ' - # 'Context %s' % (transportAddress, contextEngineId.prettyPrint(), - # contextName.prettyPrint())) - - data = {'_source': transportAddress[0]} - - for name, val in varBinds: - #print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) - name = name.prettyPrint() - if (name == '1.3.6.1.2.1.1.3.0'): - name = '_uptime' - elif (name == '1.3.6.1.6.3.1.1.4.1.0'): - name = '_trap_oid' - data[name] = val.prettyPrint() - - data = json.dumps(data) - print(data) - print(requests.post(url, headers=headers, data=data)) - -# Register SNMP Application at the SNMP engine -ntfrcv.NotificationReceiver(snmpEngine, cbFun) - -# Run asyncio main loop -loop.run_forever() \ No newline at end of file