Skip to content

Commit

Permalink
Merge pull request #43 from Asapros/dev
Browse files Browse the repository at this point in the history
Support for ADC sensor filters
  • Loading branch information
pszafer authored Jul 5, 2023
2 parents c73fdaf + 2a4981a commit 2b901a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions boneio/helper/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def create_adc(manager: Manager, topic_prefix: str, adc_list: list = []):
send_message=manager.send_message,
topic_prefix=topic_prefix,
update_interval=gpio.get(UPDATE_INTERVAL, TimePeriod(seconds=60)),
filters=gpio.get(FILTERS, []),
)
if gpio.get(SHOW_HA, True):
manager.send_ha_autodiscovery(
Expand Down
1 change: 1 addition & 0 deletions boneio/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ adc:
default: True
meta:
label: If you want you can disable discovering this input in HA.
filters: !include filters_adc.yaml
cover:
type: list
required: False
Expand Down
3 changes: 2 additions & 1 deletion boneio/sensor/adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ def initialize_adc():
class GpioADCSensor(BasicMqtt, AsyncUpdater, Filter):
"""Represent Gpio ADC sensor."""

def __init__(self, pin: str, **kwargs) -> None:
def __init__(self, pin: str, filters: list, **kwargs) -> None:
"""Setup GPIO ADC Sensor"""
super().__init__(topic_type=SENSOR, **kwargs)
self._pin = pin
self._state = None
self._filters = filters
AsyncUpdater.__init__(self, **kwargs)
_LOGGER.debug("Configured sensor pin %s", self._pin)

Expand Down

0 comments on commit 2b901a0

Please sign in to comment.