# Chapter 4: Scenario of basic system configuration

This chapter goes through initial system configuration tasks using the CLI. These tasks are required for almost any scenario in which you might use Enapter's shell. These include the following:

  • Overview
  • Logging on
  • Checking system logs
  • Activating rule engine plugins
  • Configuring devices (EL, Dryer, Inverters, etc.)
  • Setting devices groups
  • Setting standard rules actions and conditions
  • Examples

# Logging On

The first step is to log on using web management console.

Example 4-1 Log in and entering configuration mode.


Possible completions:
   exit         Exit shell
   help         Display help message
 > services     Services operations
 > show         Show system information
   bash         Run Bash shell
   configure    Enter configuration mode
   reboot       Reboot server

[d0a09d] $

In configuration mode you can set, delete and show information. Enter configuration mode by typing configure at the command prompt in operational mode.

[d0a09d] $ configure
[d0a09d] conf $

[d0a09d] conf $ exit
[d0a09d] $

You can use completion with <TAB> key at any moment to check available commands.

# Checking System Logs

Looking into logs helps you to understand what is happening with the system. To do this you need to open operational mode and type command show logs.

Example 4-2 Show logs

[d0a09d] $ show logs
2019-09-29T12:25:40Z [I] mosquitto             1569759940: Saving in-memory database to /user/var/lib/mosquitto/data/mosquitto.db.
2019-09-29T12:26:41Z [I] mosquitto             1569760001: Saving in-memory database to /user/var/lib/mosquitto/data/mosquitto.db.
2019-09-29T12:27:10Z [N] gateway-controller    Property Discoverable modify to 1

# Activating Rule Engine Plugins

You can activate Rule Engine Plugins by running the set rule-engine plugin <plugin_name> enabled true command:

[d0a09d] conf # set rule-engine plugin electrolyser enabled true
[d0a09d] conf # set rule-engine plugin dryer enabled true

List of supported plugins:

Plugin Name Description
electrolyser Enapter Electrolyser EL 2.0 / EL500 / ELS 1000 device support
electrolyser-v21 Enapter Electreolyser EL 2.1 support
dryer Enapter dryer device support
dryer-management-rule Enapter dryer management rule
changeover-switch Relay switch module device support
power-meter Power meter module device support
tank Enapter Tank module device support
enp-ai4 Enapter ENP-AI4 UCM support
enp-rl6 Enapter ENP-RL6 UCM support
gas-sensor Hydrogen sensor support
electrolyser-v21-el-output-based-production-pid Enapter EL 2.1 PID control based on production rate
electrolyser-v21-dryer-output-based-production-pid Enapter EL 2.1 PID control based on dryer output pressure

To apply changes and activate selected plugins please commit and save changes, exit configuration mode and re-enter configuration mode with conf command.

# Configuring Devices

To add devices you need set command. It allows Rule Engine to use rules to automatically control a device.

[d0a09d] conf # set rule-engine devices electrolyser <EL_DEVICE_ID> enabled true
[d0a09d] conf # set rule-engine devices electrolyser <EL_DEVICE_ID> power 2400
[d0a09d] conf # set rule-engine devices dryer <DRYER_DEVICE_ID> enabled true

# Setting Devices Groups

[d0a09d] conf # set rule-engine groups electrolyser ELS device <EL_DEVICE_ID> 

# Setting Standard Rules Actions and Conditions

You can configure custom rules by:

[d0a09d] conf # set rule-engine rule 10-dryer-rule action 10 start-dryer device <DRYER_DEVICE_ID>

You can do many things with rules.

Action Description
lua Evaluate custom LUA script
start-dryer Start dryer
stop-dryer Stop dryer
start-electrolyser Start electrolyser
stop-electrolyser Stop electrolyser
start-electrolyser-group Start electrolysers group
stop-electrolyser-group Stop electrolysers group

For writing new rule you need to set action (as described above), condition and description (optional).

Condition

[d0a09d] conf # set rule-engine rule 10-dryer-rule condition 10 electrolyser <EL_DEVICE_ID> if "device:is_running()"

Possible conditions:

Conditions Description
description Description
disable Disable
time Time condition
lua LUA script
battery SMA Battery Inverter condition
changeover-switch Relay switch status condition
dryer Enapter dryer condition
electrolyser Enapter Electrolyser condition
irradiance-sensor Irradiance Sensor condition
power-meter Power meter module condition
tank Enapter tank module condition

Now you can look into your rule engine configuration by running show rule-engine command.

plugin dryer {
  enabled true
}
plugin electrolyser {
  enabled true
}
devices {
  electrolyser BE24AADBEB35CB53814620E1CA98D6A4F9DBC72F {
    enabled true
    power 2400
  }
  dryer EB7AD544D0F4BC2BEDE7BA0C7EC2EBE048239035 {
    enabled true
  }
}
groups {
  electrolyser ELS {
    device BE24AADBEB35CB53814620E1CA98D6A4F9DBC72F
  }
}
rule 10-dryer-rule {
  action 10 {
    start-dryer {
      device EB7AD544D0F4BC2BEDE7BA0C7EC2EBE048239035
    }
  }
  condition 10 {
    electrolyser BE24AADBEB35CB53814620E1CA98D6A4F9DBC72F {
      if device:is_running()
    }
  }
}

# Examples

# Rules for Automatic Dryer Start/Stop

[d0a09d] $ conf
[d0a09d] conf # set rule-engine plugin electrolyser enabled true
[d0a09d] conf # set rule-engine plugin dryer enabled true
[d0a09d] conf # save
[d0a09d] conf # commit
[d0a09d] conf # exit
[d0a09d] $ conf
[d0a09d] conf # set rule-engine devices electrolyser <EL_DEVICE_ID> enabled true
[d0a09d] conf # set rule-engine devices electrolyser <EL_DEVICE_ID> power 2400
[d0a09d] conf # set rule-engine devices dryer <DRYER_DEVICE_ID> enabled true
[d0a09d] conf # set rule-engine rule 10-start-dryer-rule action 10 start-dryer device <DRYER_DEVICE_ID>
[d0a09d] conf # set rule-engine rule 10-start-dryer-rule condition 10 electrolyser <EL_DEVICE_ID> if "device:is_running()"
[d0a09d] conf # set rule-engine rule 20-stop-dryer-rule action 10 stop-dryer device <DRYER_DEVICE_ID>
[d0a09d] conf # set rule-engine rule 20-stop-dryer-rule condition 10 electrolyser <EL_DEVICE_ID> if "not device:is_running()"
[d0a09d] conf # save 
[d0a09d] conf # commit
[d0a09d] conf # show rule-engine
devices {
  dryer EB7AD544D0F4BC2BEDE7BA0C7EC2EBE048239035 {
    enabled true
  }
  electrolyser BE24AADBEB35CB53814620E1CA98D6A4F9DBC72F {
    enabled true
    power 2400
  }
}
plugin dryer {
  enabled true
}
plugin electrolyser {
  enabled true
}
rule 10-start-dryer-rule {
  action 10 {
    start-dryer {
      device EB7AD544D0F4BC2BEDE7BA0C7EC2EBE048239035
    }
  }
  condition 10 {
    electrolyser BE24AADBEB35CB53814620E1CA98D6A4F9DBC72F {
      if device:is_running()
    }
  }
}
rule 20-stop-dryer-rule {
  action 10 {
    stop-dryer {
      device EB7AD544D0F4BC2BEDE7BA0C7EC2EBE048239035
    }
  }
  condition 10 {
    electrolyser BE24AADBEB35CB53814620E1CA98D6A4F9DBC72F {
      if "not device:is_running()"
    }
  }
}

# Checking Rule Engine Logs

[d0a09d] # show logs service gateway-rule-engine
2020-03-31T17:03:29Z [I] gateway-rule-engine   Rule 1/2 (10-start-dryer-rule):
2020-03-31T17:03:29Z [I] gateway-rule-engine    Condition result: false
2020-03-31T17:03:29Z [I] gateway-rule-engine    Condition execution log: 
2020-03-31T17:03:29Z [I] gateway-rule-engine            [INFO] Device offline, exiting condition with `false` result