<commit_before>defmodule Farmbot.CeleryScript.AST.Node.FactoryReset do
  @moduledoc false
  use Farmbot.CeleryScript.AST.Node
  allow_args [:package]
  use Farmbot.Logger

  def execute(%{package: :farmbot_os}, _, env) do
    env = mutate_env(env)
    Logger.warn 1, "Going down for factory reset!"
    Farmbot.BotState.set_sync_status(:maintenance)
    Farmbot.BotState.force_state_push()
    Farmbot.System.factory_reset "CeleryScript request."
    {:ok, env}
  end

  def execute(%{package: :arduino_firmware}, _, env) do
    env = mutate_env(env)
    params = Farmbot.System.ConfigStorage.get_config_as_map["hardware_params"]
    for {param, _val} <- params do
      Farmbot.Firmware.update_param(:"#{param}", -1)
    end

    Logger.warn 1, "Going down for factory reset!"
    Farmbot.BotState.set_sync_status(:maintenance)
    Farmbot.BotState.force_state_push()
    Farmbot.Firmware.read_all_params()
    Farmbot.System.reboot("Arduino factory reset.")
    {:ok, env}
  end
end<commit_msg>Reorder fw reset messages<commit_after>defmodule Farmbot.CeleryScript.AST.Node.FactoryReset do
  @moduledoc false
  use Farmbot.CeleryScript.AST.Node
  allow_args [:package]
  use Farmbot.Logger

  def execute(%{package: :farmbot_os}, _, env) do
    env = mutate_env(env)
    Farmbot.BotState.set_sync_status(:maintenance)
    Farmbot.BotState.force_state_push()
    Logger.warn 1, "Going down for factory reset!"
    Farmbot.System.factory_reset "CeleryScript request."
    {:ok, env}
  end

  def execute(%{package: :arduino_firmware}, _, env) do
    env = mutate_env(env)
    Farmbot.BotState.set_sync_status(:maintenance)
    Logger.warn 1, "Going down for factory reset!"
    params = Farmbot.System.ConfigStorage.get_config_as_map["hardware_params"]
    for {param, _val} <- params do
      Farmbot.Firmware.update_param(:"#{param}", -1)
    end

    Farmbot.BotState.force_state_push()
    Farmbot.Firmware.read_all_params()
    Farmbot.System.reboot("Arduino factory reset.")
    {:ok, env}
  end
end
{'fraction_non_alphanumeric': 0.1157684630738523, 'fraction_numerical': 0.0029940119760479044, 'mean_word_length': 4.114795918367347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '973788', 'n_tokens_mistral': 740, 'n_tokens_neox': 711, 'n_words': 136}