Skip to content

Implement different adapters to control the miner #3

@markoceri

Description

@markoceri

Implement adapter that uses MinerControlPort to control the miner (using Home Assistant or the ASIC firmware's APIs).

Following the port (interface), the adapter should implements these methods that will be used by the application logic.

class MinerControlPort(ABC):
    """Port for the Miner Control."""

    @abstractmethod
    def start_miner(self) -> bool:
        """Attempts to start the miner. Returns True on success request."""
        raise NotImplementedError

    @abstractmethod
    def stop_miner(self) -> bool:
        """Attempts to stop the specified miner. Returns True on success request."""
        raise NotImplementedError

    @abstractmethod
    def get_miner_status(self) -> MinerStatus:
        """Gets the current operational status of the miner."""
        raise NotImplementedError

    @abstractmethod
    def get_miner_power(self) -> Optional[Watts]:
        """Gets the current power consumption, if available."""
        raise NotImplementedError

    @abstractmethod
    def get_miner_hashrate(self) -> Optional[HashRate]:
        """Gets the current hash rate, if available."""
        raise NotImplementedError

I imagine some extra data will needed, such as a URL and a TOKEN for Home Assistant API connection, or an IP address and port for firmware APIs. These parameters, and any other necessary one, can be provided through by adapter's constructor (its __init__() function)

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    In Progress 🏗️

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions