FEATURE: Add shutdown card

This commit is contained in:
Dominique Barton 2019-02-23 19:49:26 +01:00
parent 41f24fb6a1
commit 5d15197f42
2 changed files with 43 additions and 20 deletions

View file

@ -61,20 +61,26 @@ Prepare Raspberry Pi
--------------------
Before you can install and use Mopidy Pummeluff, you need to configure your Raspberry Pi.
Just follow these steps:
We want to enable the ``SPI`` interface and give the ``mopidy`` user access to it. This is required for the communication to the RFID module. Enter this command:
.. code-block:: bash
sudo raspi-config
In the configuraton utility, **Enable the SPI** under ``5 Interfacing Options P4 SPI``.
In the configuraton utility, **Enable the SPI** under ``5 Interfacing Options P4 SPI``.
After that, add your ``mopidy`` user to the ``spi`` group and reboot the RPi:
After that, add your ``mopidy`` user to the ``spi`` and ``gpio`` group:
.. code-block:: bash
sudo usermod -a -G spi,gpio mopidy
sudo reboot
If you're planning to use a card to shutdown the system, you also need to create a sudo rule, so that the ``mopidy`` user can shutdown the system without a password prompt:
.. code-block:: bash
echo "mopidy ALL = NOPASSWD: /sbin/shutdown" > /etc/sudoers.d/mopidy
Install via pip
---------------

View file

@ -7,12 +7,14 @@ from __future__ import absolute_import, unicode_literals, print_function
__all__ = (
'Card',
'VolumeCard',
'TracklistCard',
'VolumeCard',
'PauseCard',
'StopCard',
'ShutdownCard',
)
from os import system
from logging import getLogger
from .registry import REGISTRY
@ -228,21 +230,6 @@ class VolumeCard(Card):
LOGGER.error(str(ex))
class StopCard(Card):
'''
Stops the playback.
'''
def action(self, mopidy_core): # pylint: disable=no-self-use
'''
Stop playback.
:param mopidy.core.Core mopidy_core: The mopidy core instance
'''
LOGGER.info('Stopping playback')
mopidy_core.playback.stop()
class PauseCard(Card):
'''
Pauses or resumes the playback, based on the current state.
@ -262,3 +249,33 @@ class PauseCard(Card):
else:
LOGGER.info('Resuming the playback')
playback.resume()
class StopCard(Card):
'''
Stops the playback.
'''
def action(self, mopidy_core): # pylint: disable=no-self-use
'''
Stop playback.
:param mopidy.core.Core mopidy_core: The mopidy core instance
'''
LOGGER.info('Stopping playback')
mopidy_core.playback.stop()
class ShutdownCard(Card):
'''
Shutting down the system.
'''
def action(self, mopidy_core): # pylint: disable=no-self-use,unused-argument
'''
Shutdown.
:param mopidy.core.Core mopidy_core: The mopidy core instance
'''
LOGGER.info('Shutting down')
system('sudo /sbin/shutdown -h now')