Some basic configuration can be set via the command line, some of these are required for communication so can only be supplied by this method.
- -h to get help
- -m to set the MQQT server address
- -c to set a client name (also used in MQTT topics)
- -i to set the accumulation interval for energy collection and output The parameters would normally be set in the PowerMonitor.service file, as the PowerMonitor should be run as a service. see example below.
ExecStart=/bin/sh -c "exec sudo java -jar /opt/PowerMonitor/Software/deployment/PowerMonitor.jar -m 10.0.128.2 -i 5 -c PMon10"
PowerMonitor can receive commands via MQTT, the commands need to be sent in JSON format on the topic /emon/device name/cmnd. Replies will be sent on the topic /emon/device name/response. NB currently data changes are not persisent through restarts of the service. NB All fields must be completed, as "" if not required. The command structure is:
{
"command":"<command>",
"subject":"<subject>",
"key":"<key>",
"data":"<data>"
}
The following commands are available -
- Get - gets some data from the PowerMonitor
- Set - Sets some data on the PowerMonitor
The following subects are available
- circuit - parameters for circuits
- clamp - parameters for current clamps
- metricreading - A metric reading
- powerdata - Multiple basic and power latest readings for a circuit
- energydata - Latest energy and cumulative energy readings for a circuit
The following key values are permitted
- for a circuit: the channel number of the circuit as a string, the circuit tag (the name with spaces replaced by underscores)
- for a clamp: the clamp name
- for a metric reading: the same keys as for circuit (but see data section)
- for powerdata: the same keys as for circuit
- for energydata: the same keys as a circuit
Only get metric optionally requires information in the data field, if "" is specified the "Amps" will be used. possible values are : volts, milli_volts, amps, milli_amps, watt_hours, kilowatt_hours, va, var, kilowatt, powerfactor.
For set commands a pair of values are required within the data string
- "offset <floating point number (up to double precision)>" - added to the reading to correct offset errors
- "scale <floating point number (up to double precision)>" - multiplied by the reading to correct scaling errors
- "displayname <new display name (may contain spaces)" - essentially renaming the circuit
- "clampname " - changing the type of clamp associated with the circuit
- "monitor " - changing if data is collected for the circuit anything that is not true is considered as false
- "publishpower " - if not true basic & power data is collected without being streamed
- "publishenergy " - if not true energy data is collected without being streamed
Successful Get and Set commands will respond with the current value of the subject identified.
Errors will result in a reponse record wich has the following fields
- command - the full command that generated the response.
- result - normally "Error", could be "Info" if the request was valid but can't be satisfied
- detail - normally further information about the result
- location - where the response was generated from (normally a method name)