     Regex.replace(regexp, s, "")
   end
 
-  # def parse("[bluetooth]# \r" <> event), do: parse_event(event)
+  def is_parsed_event?({:new, _}), do: true
+  def is_parsed_event?({:change, _}), do: true
+  def is_parsed_event?(_), do: false
+
   def parse("[NEW] " <> new_event), do: {:new, parse_device(new_event)}
   def parse("[CHG] " <> chg_event), do: {:change, parse_device(chg_event)}
-  def parse(output), do: {output}
+  def parse(output) do
+    case String.split(output, "[bluetooth]#", parts: 2) do
+      [_prefix, cmd] -> parse(cmd)
+      [_] -> {output}
+    end
+  end
 
   def parse_device(<<"Device ", uuid :: binary-size(17), " ", rest::binary>>) do
-    {:device, uuid, rest}
+    {:device, uuid, device_state(rest)}
   end
   def parse_device(<<"Controller ", uuid :: binary-size(17), " ", rest::binary>>) do
-    {:controller, uuid, rest}
+    {:controller, uuid, controller_state(rest)}
   end
+
+  def controller_state("Powered: " <> "yes"), do: [powered: true]
+  def controller_state("Powered: " <> "no"), do: [powered: false]
+  def controller_state("Discovering: " <> "yes"), do: [discovering: true]
+  def controller_state("Discovering: " <> "no"), do: [discovering: false]
+  def controller_state("Discoverable: " <> "yes"), do: [discoverable: true]
+  def controller_state("Discoverable: " <> "no"), do: [discoverable: false]
+  def controller_state(any_state), do: any_state
+
+  def device_state("RSSI: " <> number), do: [rssi: Integer.parse(number, 10)]
+  def device_state(any_state), do: any_state
+
+
 end

    Port.command(port, data)
    |> reply(state)
  end

  defp reply(ret_value, state) do
    {:reply, ret_value, state}

  """
  use GenServer
  require Bluetooth.Ctl.Macros
  require Logger
  alias Bluetooth.Ctl.Macros
  alias Bluetooth.GenBle

  def start_link(:power_on) do
    start_link()
    power :on
  end
  def start_link() do
    GenServer.start_link(__MODULE__, [], [name: __MODULE__])
  end
