     GenServer.cast(rule_id, {:trigger, params})
   end
 
+  def stop(what), do: stop(what, :normal, :infinity)
+  def stop(what, reason), do: stop(what, reason, :infinity)
+  def stop(pid, reason, timeout) when is_pid(pid) do
+    # Logger.info("STOP #{inspect pid}")
+    GenServer.stop(pid, reason, timeout)
+  end
+  def stop(uuid, reason, timeout) when is_binary(uuid) do
+    # Logger.info("STOP #{inspect uuid}")
+    GenServer.stop(via(uuid), reason, timeout)
+  end
+
   ## Server impl
 
   def init(rule) do
     Logger.info("Starting rule #{inspect rule}")
-    uuid = rule["uuid"]
-
-    {:ok, trigger} = start_trigger(uuid, rule["when"])
+    uuid = rule.uuid
+
+    {:ok, trigger} = start_trigger(uuid, rule.rule["when"])
 
     Logger.debug("Got trigger #{inspect trigger}")
 

require Logger

defmodule Serverboards.RulesV2.Rule do
  def start_link(rule, options \\ []) do

    options = [name: via(rule["uuid"])] ++ options

    GenServer.start_link(__MODULE__, rule, options)
  end

    stop_id = if stop_id do stop_id else uuid end

    {:ok, %{
      trigger: trigger,
      plugin_id: plugin_id,
      stop_id: stop_id,
    }}
