Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Make Raspberry Pi GPIO optional #27

Closed
b-morgan opened this issue Mar 2, 2024 · 9 comments
Closed

[Request] Make Raspberry Pi GPIO optional #27

b-morgan opened this issue Mar 2, 2024 · 9 comments

Comments

@b-morgan
Copy link

b-morgan commented Mar 2, 2024

I'm attempting to install callattendant on a Libre LePotato running Raspbian (although this request also could apply to an actual Raspberry Pi).

I don't have a "hat" with any extra hardware and don't believe I need one. The default config file has GPIO_LED_* settings but does not have a global enable/disable setting.

The original emxsys/callattendant#171 contains a commit that removes the GPIO support, emxsys/callattendant@8d7fb7c.

I'd like to see this "removal" be made into an option.

@roycewilliams
Copy link

Is the expected change cosmetic (no attempts to initialize in the logs, etc.), or is there an operational problem when trying to invoke GPIO on a non-GPIO device?

@thess
Copy link
Owner

thess commented Mar 3, 2024

Call attendant supports 3 distinct status notification sub-systems: GPIO, MQTT and NULL. The setting you want is STATUS_INDICATORS in the app.cfg file. The current default (if installed from source) is 'NULL' which is what I believe you are asking. Setting up external GPIO indicators requires additional hardware support as noted in app.cfg.example

# Indicator modules can be one of: GPIO, NULL or MQTT. Multiple indicator type not supported.
# Default is NULL (No special hardware)
#     MQTT support requires 'paho.mqtt' installed
#     GPIO (on RPi) requires 'gpizero' and supporting system interaces (E.g.: RPi.gpio and/or pigpio)
STATUS_INDICATORS = "NULL"

When set to NULL the GPIO pin assignments, etc. are ignored.

@b-morgan
Copy link
Author

b-morgan commented Mar 3, 2024

I started with pip3 install callattendant as suggested in the installation section of the Wiki. The ~/.callattendent/app.cfg file (which I assume is the one used if nothing is specified) does not contain 'STATUS_INDICATORS'.

I'm guessing that installing from source is different than installing the latest package. Am I correct?

@b-morgan
Copy link
Author

b-morgan commented Mar 3, 2024

Is the expected change cosmetic (no attempts to initialize in the logs, etc.), or is there an operational problem when trying to invoke GPIO on a non-GPIO device?

I'm attempting to get callattendant operational. After the pip3 install, a reboot, and a callattendant --create-folder the next step, callattendant outputs the following:

li@libre:~/.callattendant $ callattendant
Command line options:
  --config=None
  --data-path=None
  --create-folder=False
[Configuration]
  BLOCKED_ACTIONS = ('greeting', 'record_message')
  BLOCKED_GREETING_FILE = /home/li/.local/lib/python3.9/site-packages/callattendant/resources/blocked_greeting.wav
  BLOCKED_RINGS_BEFORE_ANSWER = 0
  BLOCK_ENABLED = True
  BLOCK_NAME_PATTERNS = {'V[0-9]{15}': 'Telemarketer Caller ID'}
  BLOCK_NUMBER_PATTERNS = {}
  BLOCK_SERVICE = NOMOROBO
  DATABASE = callattendant.db
  DATA_PATH = /home/li/.callattendant
  DB_FILE = /home/li/.callattendant/callattendant.db
  DEBUG = False
  ENV = production
  GPIO_LED_APPROVED_BRIGHTNESS = 100
  GPIO_LED_APPROVED_PIN = 15
  GPIO_LED_BLOCKED_BRIGHTNESS = 100
  GPIO_LED_BLOCKED_PIN = 17
  GPIO_LED_MESSAGE_BRIGHTNESS = 100
  GPIO_LED_MESSAGE_COUNT_KWARGS = {'active_high': True}
  GPIO_LED_MESSAGE_COUNT_PINS = (8, 7, 27, 23, 10, 11, 9, 18)
  GPIO_LED_MESSAGE_PIN = 4
  GPIO_LED_RING_BRIGHTNESS = 100
  GPIO_LED_RING_PIN = 14
  PERMITTED_ACTIONS = ()
  PERMITTED_GREETING_FILE = /home/li/.local/lib/python3.9/site-packages/callattendant/resources/general_greeting.wav
  PERMITTED_RINGS_BEFORE_ANSWER = 4
  PERMIT_NAME_PATTERNS = {}
  PERMIT_NUMBER_PATTERNS = {}
  PHONE_DISPLAY_FORMAT = ###-###-####
  PHONE_DISPLAY_SEPARATOR = -
  ROOT_PATH = /home/li/.local/lib/python3.9/site-packages/callattendant
  SCREENED_ACTIONS = ()
  SCREENED_GREETING_FILE = /home/li/.local/lib/python3.9/site-packages/callattendant/resources/general_greeting.wav
  SCREENED_RINGS_BEFORE_ANSWER = 0
  SCREENING_MODE = ('whitelist', 'blacklist')
  TESTING = False
  VERSION = 1.1.0
  VOICE_MAIL_GOODBYE_FILE = /home/li/.local/lib/python3.9/site-packages/callattendant/resources/goodbye.wav
  VOICE_MAIL_GREETING_FILE = /home/li/.local/lib/python3.9/site-packages/callattendant/resources/general_greeting.wav
  VOICE_MAIL_INVALID_RESPONSE_FILE = /home/li/.local/lib/python3.9/site-packages/callattendant/resources/invalid_response.wav
  VOICE_MAIL_LEAVE_MESSAGE_FILE = /home/li/.local/lib/python3.9/site-packages/callattendant/resources/please_leave_message.wav
  VOICE_MAIL_MENU_FILE = /home/li/.local/lib/python3.9/site-packages/callattendant/resources/voice_mail_menu.wav
  VOICE_MAIL_MESSAGE_FOLDER = /home/li/.callattendant/messages
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from rpigpio: This module can only be run on a Raspberry Pi!
  warnings.warn(
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio'
  warnings.warn(
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from rpio: This module can only be run on a Raspberry Pi!
  warnings.warn(
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8888)

Did you start the pigpio daemon? E.g. sudo pigpiod

Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888

Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from pigpio: failed to connect to localhost:8888
  warnings.warn(
/usr/lib/python3/dist-packages/gpiozero/devices.py:288: PinFactoryFallback: Falling back from native: unable to locate Pi revision in /proc/device-tree or /proc/cpuinfo
  warnings.warn(
Traceback (most recent call last):
  File "/home/li/.local/bin/callattendant", line 8, in <module>
    sys.exit(main())
  File "/home/li/.local/lib/python3.9/site-packages/callattendant/__main__.py", line 20, in main
    sys.exit(main(sys.argv))
  File "/home/li/.local/lib/python3.9/site-packages/callattendant/app.py", line 444, in main
    app = CallAttendant(config)
  File "/home/li/.local/lib/python3.9/site-packages/callattendant/app.py", line 70, in __init__
    self.approved_indicator = ApprovedIndicator(
  File "/home/li/.local/lib/python3.9/site-packages/callattendant/hardware/indicators.py", line 274, in __init__
    super().__init__(gpio_pin, brightness)
  File "/home/li/.local/lib/python3.9/site-packages/callattendant/hardware/indicators.py", line 234, in __init__
    self.led = PWMLED(gpio_pin)
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 108, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 403, in __init__
    super(PWMOutputDevice, self).__init__(
  File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 83, in __init__
    super(OutputDevice, self).__init__(pin, pin_factory=pin_factory)
  File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 85, in __init__
    super(SourceMixin, self).__init__(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 540, in __init__
    super(GPIODevice, self).__init__(**kwargs)
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 250, in __init__
    Device.pin_factory = Device._default_pin_factory()
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 291, in _default_pin_factory
    raise BadPinFactory('Unable to load any default pin factory!')
gpiozero.exc.BadPinFactory: Unable to load any default pin factory!
li@libre:~/.callattendant $

@b-morgan
Copy link
Author

b-morgan commented Mar 3, 2024

I was able to get something working by temporarily repurposing an RPI 3B+ connected to my 3D printer and borrowing a USR5637 modem from duty as a fax machine. The settings page says 'VERSION': '1.1.0', so I'm guessing that the PyPi version isn't from this project (which makes sense when I think about it).

Started over using the Development Guide which failed as shown below. Not sure where to go from here.

pi@rpi3bplus:~/callattendant $ source venv/bin/activate
(venv) pi@rpi3bplus:~/callattendant $ which python
/home/pi/callattendant/venv/bin/python
(venv) pi@rpi3bplus:~/callattendant $ python --version
Python 3.9.2
(venv) pi@rpi3bplus:~/callattendant $ pip install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting Flask~=3.0.1
  Downloading https://www.piwheels.org/simple/flask/flask-3.0.2-py3-none-any.whl (101 kB)
     |████████████████████████████████| 101 kB 237 kB/s
Collecting flask-paginate~=2023.10.24
  Downloading https://www.piwheels.org/simple/flask-paginate/flask_paginate-2023.10.24-py2.py3-none-any.whl (7.4 kB)
Collecting requests~=2.31.0
  Downloading https://www.piwheels.org/simple/requests/requests-2.31.0-py3-none-any.whl (62 kB)
     |████████████████████████████████| 62 kB 181 kB/s
Collecting beautifulsoup4~=4.12.3
  Downloading https://www.piwheels.org/simple/beautifulsoup4/beautifulsoup4-4.12.3-py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 350 kB/s
Collecting bs4~=0.0.2
  Downloading https://www.piwheels.org/simple/bs4/bs4-0.0.2-py2.py3-none-any.whl (1.2 kB)
Collecting lxml~=5.1.0
  Downloading lxml-5.1.0.tar.gz (3.8 MB)
     |████████████████████████████████| 3.8 MB 3.2 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /home/pi/callattendant/venv/bin/python /tmp/tmpk2i3w896_in_process.py get_requires_for_build_wheel /tmp/tmpbs5iv7ls
       cwd: /tmp/pip-install-gf1xhhvz/lxml_2a5083a986944de687a29d4f429469ab
  Complete output (4 lines):
  <string>:67: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  Building lxml version 5.1.0.
  Building without Cython.
  Error: Please make sure the libxml2 and libxslt development packages are installed.
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/2b/b4/bbccb250adbee490553b6a52712c46c20ea1ba533a643f1424b27ffc6845/lxml-5.1.0.tar.gz#sha256=3eea6ed6e6c918e468e693c41ef07f3c3acc310b70ddd9cc72d9ef84bc9564ca (from https://pypi.org/simple/lxml/) (requires-python:>=3.6). Command errored out with exit status 1: /home/pi/callattendant/venv/bin/python /tmp/tmpk2i3w896_in_process.py get_requires_for_build_wheel /tmp/tmpbs5iv7ls Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement lxml~=5.1.0
ERROR: No matching distribution found for lxml~=5.1.0
(venv) pi@rpi3bplus:~/callattendant $

@thess
Copy link
Owner

thess commented Mar 3, 2024

The version (1.1.0) of Callattendant in the PyPi distribution repository is not this version of Callattendant. Since the original author, who is deceased, owns the old repository and no-one has access to it, I started this fork of the the original application last year to continue development. I have not created a distribution via PyPi yet. In order to do that, I will have to use a new name (Callattendant2 ?). In the meantime, you should follow the instructions in the README.

@thess
Copy link
Owner

thess commented Mar 3, 2024

Regarding the information in the Wiki... Currently it is only a copy of the original source (mostly to preserve history). I haven't had enough time to properly revise it to reflect the newer versions I have created. Until then, please refer to the source repository and the current README for installation and setup. I will try to find some time this month to do a proper revision of the Wiki in order to reflect development status and to remove obsolete and/or inaccurate information.

Also, please note that neither a Raspberry Pi nor a USR modem is required for Callattendant. I have been able to run Callattendant on just about any Linux system (my Dell laptop for example) both with and without a modem attached.

@thess
Copy link
Owner

thess commented Mar 3, 2024

Error: Please make sure the libxml2 and libxslt development packages are installed.

For a first time installation of lxml 5.x, you may need to install the development dependencies libxml2 and libxslt.

$ sudo apt install libxml2-dev libxslt-dev

Be patient, lxml install takes quite a bit of time on a RPi to build.

@b-morgan
Copy link
Author

b-morgan commented Mar 3, 2024

I am making progress thanks to #1. Web interface says version 1.7.1.

I have a
StarTech.com USB 2.0 Fax Modem - 56K External Hardware Dial Up V.92 Modem on order and I'll switch back to a Libre LePotato when that arrives as the "borrowed" RPi 3B+ and USR5637 need to go back to their original use.

I believe this issue can be closed.

@thess thess closed this as completed Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants