Skip to content

Commit

Permalink
Improve Neokey 4x1 Function, update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
kizniche committed Dec 16, 2023
1 parent f7825ba commit af00afa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
## 8.15.13 (Unreleased)

### Features
### Bugfixes

- Fix inability to properly import settings backup
- Fix Actions not executing for MQTT, TTN, and Python Code Inputs ([#1336](https://github.com/kizniche/Mycodo/issues/1336))
- Fix running pylint

### Features

- Add ability to use Actions in Custom Functions
- Add Input Action: Execute Python 3 Code ([#1334](https://github.com/kizniche/Mycodo/issues/1334))
- Add Function: Adafruit Neokey (Key Press Executes Actions) ([#1353](https://github.com/kizniche/Mycodo/issues/1353))
- Add Action: Neopixel Flashing On
- Add Action: Neopixel Flashing Off
- Change deprecated threading.currentThread to threading.current_thread
- Update InfluxDB 2.x to 2.7.3

### Bugfixes
### Miscellaneous

- Fix Actions not executing for MQTT, TTN, and Python Code Inputs ([#1336](https://github.com/kizniche/Mycodo/issues/1336))
- Fix running pylint
- Update InfluxDB 2.x to 2.7.3


## 8.15.12 (2023.10.28)
Expand Down
22 changes: 16 additions & 6 deletions mycodo/functions/function_adafruit_neokey_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ def execute_at_modification(
'required': True,
'name': 'Last Action LED Color (RGB)',
'phrase': 'The RGB color while the last action is running (e.g 10, 0, 0)'
},
{
'id': 'led_shutdown',
'type': 'text',
'default_value': '0, 0, 0',
'required': True,
'name': 'Shutdown LED Color (RGB)',
'phrase': 'The RGB color when the Function is disabled (e.g 10, 0, 0)'
}
]
}
Expand All @@ -260,7 +268,7 @@ def __init__(self, function, testing=False):
self.flashing = {}
self.colorwheel = None
self.control = None
self.timer_flash = None
self.timer_flash = time.time()
self.key_press_executing = {}
self.toggle = {}

Expand Down Expand Up @@ -336,14 +344,11 @@ def listener(self):
while self.running:
# Check key press
for key in range(4):
if self.neokey[key]:
if self.neokey[key] and not self.key_press_executing[key]:
self.key_press_executing[key] = True
self.logger.debug(f"Key {key + 1} Pressed")
self.set_color({"led_number": key, "led_color": self.options_channels['led_start'][key]})

while self.neokey[key] and self.running:
time.sleep(0.2)

write_influxdb_value(
self.unique_id,
self.channels_measurement[key].unit,
Expand All @@ -369,7 +374,12 @@ def listener(self):
self.flashing[key]["on"] = True
self.set_color({"led_number": key, "led_color": self.flashing[key]["color"]})

time.sleep(0.25)
time.sleep(0.05)

def stop_function(self):
self.running = False
for key in range(4):
self.set_color({"led_number": key, "led_color": self.options_channels['led_shutdown'][key]})

def run_key_actions(self, key):
action_ids = self.options_channels['key_action_ids'][key]
Expand Down

0 comments on commit af00afa

Please sign in to comment.