# Simple terminal monitoring plugin
from energenie.Handlers import Handler
from energenie.Registry import DeviceRegistry


class TerminalEchoHandler(Handler):
    description = "Simple terminal output handler"

    def __init__(self, **kw_args):
        super(TerminalEchoHandler, self).__init__(**kw_args)

    def device_added(self, device_uuid):
        device = DeviceRegistry.singleton().get(device_uuid)
        print ("Added new device: %s" % str(device))

    def handle_reading(self, device_uuid, key, value):
        device = DeviceRegistry.singleton().get(device_uuid)
        print ("Received reading: %s -> %s = %s" % (str(device), str(key), str(value)))

    def handle_unknown(self, address, message):
        print ("Received unknown message: %s %s" % (str(address), str(message)))

    def ask(self):
        pass

# Simple terminal monitoring plugin
from energenie.Handlers import Handler
from energenie.Registry import DeviceRegistry


class TerminalEchoHandler(Handler):
    description = "Simple terminal output handler"

    def __init__(self, **kw_args):
        super(TerminalEchoHandler, self).__init__(**kw_args)

    def device_added(self, device_uuid):
        device = DeviceRegistry.singleton().get(device_uuid)
        print ("Added new device: %s" % str(device))

    def handle_reading(self, device_uuid, key, value):
        device = DeviceRegistry.singleton().get(device_uuid)
        print ("Received reading: %s -> %s = %s" % (str(device), str(key), str(value)))

    def handle_unknown(self, address, message):
        print ("Received unknown message: %s %s" % (str(address), str(message)))

    def ask(self):
        pass

# Simple terminal monitoring plugin