iot-logic/src/actuator/loudspeaker.py

32 lines
813 B
Python

#!/usr/bin/env python3
import random
import os
import os.path
from .abcactuator import AbcActuator
from birbnetes_iot_platform_raspberry import BirbnetesIoTPlatformPlaybackDriver, BirbnetesIoTPlatformStatusDriver
"""
Abstract base class for Sender
"""
__author__ = "@marcsello"
__copyright__ = "Copyright 2020, Birbnetes Team"
__module_name__ = "loudspeaker"
__version__text__ = "1"
class Loudspeaker(AbcActuator):
"""
A class that plays back various sounds.
"""
def __init__(self, sound_dir: str):
BirbnetesIoTPlatformPlaybackDriver.init(sound_dir)
def act(self):
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('blue', [1, 1, 1])
BirbnetesIoTPlatformPlaybackDriver.play_one_random()
def __del__(self):
BirbnetesIoTPlatformPlaybackDriver.cleanup()