Skip to content

The Config File

jbaumann edited this page Jan 24, 2021 · 26 revisions

The Structure

The configuration file is a simple textual file that begins with a header line denoting its purpose:

[attinydaemon]

Following this are the option. If an option is missing at startup, the daemon determines the value that is currently set in the ATTiny Daemon and copies it to the config file. An example config file can be found in the here.

If you change a value of an existing option in the configuration file, then the daemon writes to new value to the ATTiny Daemon after a restart of the daemon. You can either reboot the system or execute the following command (assuming you used the service file for the installation of the daemon):

sudo systemctl restart attiny_daemon.service

This simply stops and restarts the daemon.

By default the configuration file is assumed to be in the same directory as the daemon itself. By using the command line option

--cfgfile <file>

another file with an arbitrary path can be provided as a config file.

The Options

Option Name Default Comment
primed true This option arms the ATTiny Daemon. As long as this option is set to falseyou can experiment and read all values of the ATTiny Daemon without it influencing your system in any way (apart from showing up as an I2C device).
loglevel DEBUG This is the log level for all messages in the system log file. Available levels are DEBUG, INFO, WARNING, ERROR, CRITICAL.
button function shutdown The possible options are shutdown, reboot and nothing.
timeout 60 This is the time in seconds until the ATTiny decides that the RPi has shut down and has to be restarted by resetting it. This should be longer than a reboot cycle of the RPi takes in the worst case.
sleeptime 15 This is the sleep time in seconds for the daemon until it checks the ATTiny Daemon for the next time. The best value is between timeout/3 and timeout/4
force shutdown True If this option is set (and the option primed as well), then the system does a hard shutdown at the shutdown voltage by turning off the Geekworm UPS.
shutdown voltage 3200 Until v2.11.5: This is the voltage in Millivolts at which the ATTiny Daemon executes a hard shutdown. You should ensure that this voltage is sufficiently below the warn voltage (200mV should be safe).
ups shutdown voltage 3200 After v2.11.5.: This is the voltage in Millivolts at which the ATTiny Daemon executes a hard shutdown. You should ensure that this voltage is sufficiently below the warn voltage (200mV should be safe).
warn voltage 3400 This is the voltage in Millivolts at which the ATTiny Daemon warns the RPi to shut down.
restart voltage 3900 At this voltage (in Millivolts) the ATTiny tries to restart the RPi if it is not running.
battery voltage coefficient 1000 This is the coefficient used as a factor with which the battery voltage measurement is multiplied (times 1.000). See Compensating Measurement Errors for a detailed explanation.
battery voltage constant 0 This is the constant added to the battery voltage measurement after the multiplication (times 1.000). See Compensating Measurement Errors for a detailed explanation.
external voltage coefficient 1818 This is the coefficient used as a factor with which the external voltage measurement is multiplied (times 1.000). See Compensating Measurement Errors for a detailed explanation.
external voltage constant 0 This is the constant added to the external voltage measurement after the multiplication (times 1.000). See Compensating Measurement Errors for a detailed explanation.
temperature coefficient 1000 This is the coefficient used as a factor with which the temperature measurement is multiplied (times 1.000). See Compensating Measurement Errors for a detailed explanation.
temperature constant -270 This is the constant added to the temperature measurement after the multiplication (times 1.000). See Compensating Measurement Errors for a detailed explanation.
i2c address 0x37 This is the I2C address of the ATTiny, shouldn't have to be changed normally.
reset configuration 0|3 Until v2.11.5: This value configures how the ATTiny daemon tries to reset the system:
Bit 0 = 0: Reset using a voltage level change (pulling the line low turns off the UPS)
Bit 0 = 1: Reset by „pressing“ a switch twice (pulling the line down for the reset pulse lenght turns the switch once)
Bit 1 = 0: Do not check external voltage (external voltage is not connected to RPi Vcc)
Bit 1 = 1: Check external voltage: (external voltage is connected to RPi Vcc)
Recommended for Geekworm UPS1 is the value 0, for the Geekworm UPS2 the value 3 (including connecting the EXT_V pin to the RPi Vcc via the jumper)
(since v2.4)
ups configuration 0|3 After v2.11.5: This value configures how the ATTiny daemon tries to reset the system:
Bit 0 = 0: Reset using a voltage level change (pulling the line low turns off the UPS)
Bit 0 = 1: Reset by „pressing“ a switch twice (pulling the line down for the reset pulse lenght turns the switch once)
Bit 1 = 0: Do not check external voltage (external voltage is not connected to RPi Vcc)
Bit 1 = 1: Check external voltage: (external voltage is connected to RPi Vcc)
Bit 4-5: Encodes additional pulses for turning off the UPS
Bit 6-7: Encodes additional pulses for turning on the UPS
Recommended for Geekworm UPS1 is the value 0, for the Geekworm UPS2 the value 3 (including connecting the EXT_V pin to the RPi Vcc via the jumper). The Lusya UPS needs two pulse to turn off the UPS and one to turn it on. The value recommended is 0x13 i.e., one additional off pulse and measuring the ext_voltage (this includes connecting the EXT_V pin to the RPi Vcc via the jumper).
reset pulse length 200|4000 Until v2.11.5: This is the length of the pulse used to execute the reset (200ms if the reset is induced by a voltage level change, 4000ms if a switch has to be pressed). Will be overwritten by either pulse length on and pulse length off
(since v2.4)
pulse length 200|4000 After v2.11.5: This is the length of the pulse used to execute the reset (200ms if the reset is induced by a voltage level change, 4000ms if a switch has to be pressed). Will be overwritten by either pulse length on and pulse length off
(since v2.4)
pulse length on 0 This option allows to overwrite the pulse length value to implement an asymmetric pulse for turning on the UPS. If 0, pulse length will be used.
(since v2.10.5)
pulse length off 0 This option allows to overwrite the pulse length value to implement an asymmetric pulse for turning off the UPS. If 0, pulse length will be used.
(since v2.10.5)
switch recovery delay 200|1000 This is the time in ms to wait before consecutive actions, „pressing“ the switch again when in switch mode, changing the voltage to high again in low voltage mode
When in multiple-pulse mode (i.e. when setting the high 4 bits in ups configuration), then the time between the multiple pulses is a quarter of this value, and the pause between the changes (UPS off and UPS on) is the switch recovery delay. For instance, you configure 2 pulses for turning off the UPS (e.g. 0x13 for the Lusya UPS) and 1000ms for the switch recovery delay, then the second pulse for turning off the UPS comes 250ms after the first, then a pause of 1s and then the pulse to turn the UPS on again
(since v2.4)
led off mode false Set this to true if you do not want the LED to blink at all. This could be helpful to heighten the WAF.

Comments

The difference between timeout and sleeptime (in the default configuration 40 seconds) should allow the RPi to fully reboot. If the time is not sufficient, then the ATTiny Daemon might reset the system just before it comes online again.