Skip to content

Commit

Permalink
add passkey override, 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tlskinneriv committed Jan 27, 2024
1 parent b7aa398 commit 44a4c64
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions awnet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [1.1.0] - 2024-01-27

### Changed

- Add MAC address override option to add-on. Add the MAC address of the device in the option to
override the PASSKEY data.

## [1.0.1] - 2023-09-09

### Changed
Expand Down
3 changes: 2 additions & 1 deletion awnet/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: AWNET to HASS
version: 1.0.1
version: 1.1.0
slug: awnet_to_hass
description: Addon to capture local Ambient Weather data in Home Assistant
arch:
Expand All @@ -13,6 +13,7 @@ options:
log_level: WARNING
schema:
log_level: list(DEBUG|INFO|WARNING|ERROR)
passkey_override: "match(^(?:[a-f0-9]{2}[\\.\\-:]?){5}[a-f0-9]{2}$)?"
ports:
80/tcp: 7080
init: false
Expand Down
6 changes: 6 additions & 0 deletions awnet/rootfs/awnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# set vars
AUTH_TOKEN = os.getenv("SUPERVISOR_TOKEN", "test")

ATTR_PASSKEY = 'PASSKEY'

_LOGGER = logging.getLogger(__name__)

def get_headers(environ):
Expand Down Expand Up @@ -64,6 +66,10 @@ def handle_results(result):
result[key] = result[key][0]
else:
_LOGGER.error('Unexpected list size for key %s', key)
m = re.search(pattern=r'(?:[a-f0-9]{2}[\.\-:]?){5}[a-f0-9]{2}', string=os.environ.get('PASSKEY_OVERRIDE', ''), flags=re.IGNORECASE)
if m is not None:
_LOGGER.debug('%s override: %s', ATTR_PASSKEY, m[0])
result[ATTR_PASSKEY] = m[0]
publish(result)


Expand Down
2 changes: 2 additions & 0 deletions awnet/rootfs/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/with-contenv bashio

export PASSKEY_OVERRIDE=$(bashio::config 'passkey_override')

LOG_LEVEL=$(bashio::config 'log_level')
python3 awnet.py $LOG_LEVEL
10 changes: 10 additions & 0 deletions awnet/translations/en.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
configuration:
log_level:
name: Log Level
passkey_override:
name: MAC Address Override
description: >-
If the device is not sending its MAC address in the PASSKEY field of the data, set this option
to the desired MAC address to override it. Accepted formats: 000000000000, 00:00:00:00:00:00,
00-00-00-00-00-00 or 0000.0000.0000

0 comments on commit 44a4c64

Please sign in to comment.