Example #1
0
def setup(monitor):
    ''' setup the module'''

    if not monitor.config.get("ENABLE_MODULE_MQTT", False):
        LOGGER.debug("module is not enabled")
        return False
    # default config entries init
    mqtt_topic_base = u"%hostname%"
    mqtt_client = monitor.config.get("MQTT_CLIENT_ID", u"pimonitor-%hostname%")
    monitor.config.get("MQTT_HOST", u"192.168.1.1")
    monitor.config.get("MQTT_PORT", 1883)
    monitor.config.get("MQTT_USERNAME", u"")
    monitor.config.get("MQTT_PASSWORD", u"")
    monitor.config.get("MQTT_TOPIC_COMMAND", u"%s/cmd" % mqtt_topic_base)
    monitor.config.get("MQTT_TOPIC_STAT", u"%s/stat" % mqtt_topic_base)
    monitor.config.get("MQTT_TOPIC_AVAILABILITY", u"clients/%s" % mqtt_client)
    monitor.config.get("MQTT_QOS", 1)
    monitor.config.get("MQTT_RETAIN", False)
    monitor.config.get("MQTT_CLEAN_SESSION", False)
    # conditional import of globals
    import_or_install("paho.mqtt.client",
                      "Client",
                      True,
                      installpip="paho-mqtt")
    return MQTT(monitor)
Example #2
0
def setup(monitor):
    '''setup the module'''
    if not monitor.config.get("ENABLE_MODULE_ROON", False):
        LOGGER.debug("Roon module is not enabled!")
        return False
    is_armv6 = "armv6" in PLATFORM
    enable_squeezelite = monitor.config.get("ROON_USE_SQUEEZELITE", is_armv6)
    player_name = monitor.config.get("ROON_PLAYER_NAME", u"%hostname%")
    if not player_name:
        LOGGER.warning("Roon player name is empty")
        return False
    if "armv6" in PLATFORM and not enable_squeezelite:
        LOGGER.warning("unsupported platform! %s" % PLATFORM)
        return False
    if enable_squeezelite and not check_software(dietpi_id="36", bin_path="/usr/bin/squeezelite", installapt="squeezelite"):
        LOGGER.warning("Squeezelite is not installed, please install manually.")
        return False
    elif not enable_squeezelite and not check_software(dietpi_id="121", bin_path="/opt/RoonBridge/RoonBridge"):
        LOGGER.warning("RoonBridge is not installed, please install manually.")
        return False
    if enable_squeezelite and monitor.config.get("ENABLE_MODULE_SQUEEZELITE", False):
        LOGGER.debug("Squeezelite module is enabled. You can not use Roon in squeezelite mode at the same time!")
        return False
    import_or_install("roon", "RoonApi", True, installpip="roonapi>=0.0.16")
    return RoonPlayer(monitor, player_name, enable_squeezelite)
Example #3
0
def setup(monitor):
    '''setup this module'''
    if not monitor.config.get("ENABLE_MODULE_GPIO", False):
        LOGGER.debug("GPIO module is not enabled!")
        return False
    # Check we have the necessary module
    model_info = ""
    if IS_DIETPI:
        # dietpi detected
        with open("/DietPi/dietpi/.hw_model") as hw_file:
            model_info = hw_file.read()
    if "RPi" in model_info:
        import_or_install("RPi.GPIO", "gpio_mod", installpip="RPi.GPIO")
    else:
        # fall back to orangepi version of GPIO module which also supports other boards.
        import_or_install("OPi.GPIO", "gpio_mod", installpip="OPi.GPIO")

    # default config entries init
    monitor.config.get("GPIO_PINS_IN", [])
    monitor.config.get("GPIO_PINS_OUT", [])
    monitor.config.get("GPIO_AUDIO_RELAY_PIN", 0)
    monitor.config.get("GPIO_BUZZER_PIN", 0)
    monitor.config.get("GPIO_INVERTED_PINS", [])
    monitor.config.get("GPIO_NEGATIVE_PINS", [])
    monitor.config.get("GPIO_CUSTOM_LAYOUT", {})

    # hack for orangepi/nanopi boards
    try:
        test_pud_up = gpio_mod.PUD_UP
    except AttributeError:
        gpio_mod.PUD_UP = 2

    return GPIO(monitor, gpio_mod)
Example #4
0
def setup(monitor):
    '''setup the module'''
    if not monitor.config.get("ENABLE_MODULE_LCD_DISPLAY", False):
        LOGGER.debug("LCD Display module is not enabled!")
        return False
    # TODO: add config entries for type of display and hardware address
    # currently hardcoded to 20x4 display at address 0x3f
    import_or_install("RPLCD.i2c", "CharLCD", True, "RPLCD")
    return LCDDisplay(monitor)
Example #5
0
def setup(monitor):
    '''setup the module'''
    if not monitor.config.get("ENABLE_MODULE_BLUETOOTH", False):
        LOGGER.warning("Bluetooth module is not enabled!")
        return False
    if not check_software(bin_path="/usr/bin/bluealsa-aplay",
                          installapt="bluetooth bluez-firmware bluealsa"):
        LOGGER.warning("Bluez Alsa is not installed, please install manually.")
        return False

    import_or_install("gi.repository", "GObject", installapt="python-gobject")

    return BluetoothPlayer(monitor)
Example #6
0
def setup(monitor):
    '''setup the module'''
    if not monitor.config.get("ENABLE_MODULE_WEBCONFIG", True):
        LOGGER.debug("Webconfig module is not enabled!")
        return False
    import_or_install("flask", ["Flask", "render_template", "flash", "request", "send_file", "redirect", "jsonify"], True, installpip="Flask")
    import_or_install("wtforms", ["StringField", "TextAreaField", "StringField", "SubmitField", "BooleanField", "IntegerField", "FloatField", "SelectField"], True, installpip="WTForms")
    import_or_install("flask_wtf", "FlaskForm", True, installpip="")
    import_or_install("bjoern", installpip="bjoern", installapt="libev-dev python-dev")
    return WebConfig(monitor)
Example #7
0
def setup(monitor):
    '''setup the module'''
    if not monitor.config.get("ENABLE_MODULE_OLED_DISPLAY", False):
        LOGGER.debug("OLED Display module is not enabled!")
        return False
    # TODO: add config entries for type of display and hardware address
    # currently display is hardcoded
    import_or_install("luma.core.render", "canvas", True, "luma.core")
    import_or_install("luma.core.image_composition",
                      ["ImageComposition", "ComposableImage"], True,
                      "luma.core")
    import_or_install("luma.core.interface.serial", "i2c", True, "luma.core")
    import_or_install("luma.oled.device", "ssd1306", True, "luma.oled")
    return OLEDDisplay(monitor)
Example #8
0
def setup(monitor):
    '''setup the module'''
    if not monitor.config.get("ENABLE_MODULE_AIRPLAY", False):
        LOGGER.debug("Airplay module is not enabled!")
        return False

    if not check_software(dietpi_id="37", bin_path=EXEC_BIN):
        LOGGER.warning(
            "shairport-sync is not installed, please install manually.")
        return False

    import_or_install("DictObject")
    import_or_install("magic", installpip="python-magic")
    global_import("resources.lib.shairportdecoder.remote", "AirplayRemote",
                  True)
    global_import(
        "resources.lib.shairportdecoder.decoder",
        ["Processor", "VOLUME", "COVERART", "META", "CLIENT_REMOTE_AVAILABLE"],
        True)
    global_import("resources.lib.shairportdecoder.metadata", "Infos", True)

    return AirPlayPlayer(monitor)
Example #9
0
def setup(monitor):
    '''setup the module'''
    import_or_install("alsaaudio",
                      installapt="libasound2-dev",
                      installpip="pyalsaaudio")
    return AlsaVolume(monitor)
Example #10
0
#!/usr/bin/env python
from __future__ import absolute_import, print_function, unicode_literals
import os
import time
import threading
import thread
import subprocess
from resources.lib.utils import PlayerMetaData, json, DEVNULL, HOSTNAME, requests, PLATFORM, run_proc, check_software, import_or_install, PAUSED_STATE, PLAYING_STATE, STOPPED_STATE
import_or_install("dbus", installapt="python-dbus")
import dbus.service
import dbus.mainloop.glib
"""
    BluetoothPlayer
    player implementation for Bluetooth
    very basic which uses bluez alsa
"""

AGENT_INTERFACE = "org.bluez.Agent1"
AGENT_PATH = "/test/agent"


def setup(monitor):
    '''setup the module'''
    if not monitor.config.get("ENABLE_MODULE_BLUETOOTH", False):
        LOGGER.warning("Bluetooth module is not enabled!")
        return False
    if not check_software(bin_path="/usr/bin/bluealsa-aplay",
                          installapt="bluetooth bluez-firmware bluealsa"):
        LOGGER.warning("Bluez Alsa is not installed, please install manually.")
        return False
Example #11
0
def setup(monitor):
    '''setup the module'''
    if not "armv7" in PLATFORM:
        LOGGER.warning("unsupported platform! %s" % PLATFORM)
        return False
    enabled = monitor.config.get("ENABLE_MODULE_GOOGLE_ASSISTANT", False)
    if not enabled:
        LOGGER.debug("Google Assistant module is not enabled!")
        return False
    dummy_mic = "Dummy" in monitor.config["ALSA_CAPTURE_DEVICE"]
    mute_mic = monitor.config.get("GOOGLE_ASSISTANT_MUTE_MIC", dummy_mic)

    import_or_install("pathlib2", "pathlib", installpip="pathlib2")
    import_or_install("google.assistant.library", "Assistant", True, installpip="google-assistant-library google-assistant-sdk[samples]", installapt="portaudio19-dev libffi-dev libssl-dev")
    import_or_install("google.assistant.library.event", "EventType", True, installpip="google-assistant-sdk[samples]")
    import_or_install("google.assistant.library.file_helpers", "existing_file", True, installpip="google-assistant-sdk[samples]")
    import_or_install("google.assistant.library.device_helpers", "register_device", True, installpip="google-assistant-sdk[samples]")
    import_or_install("google.oauth2.credentials", "Credentials", True, installpip="google-auth-oauthlib[tool]")
    
    model_id="voice-kit-208321-voice-kit-kftedd"
    project_id="voice-kit-208321"
    client_secrets = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","resources", "googlecreds.json")
    credentialsfile = None
    devconfig_file = None
    return GoogleAssistantPlayer(credentialsfile, model_id, project_id, devconfig_file, client_secrets, monitor, mute_mic)