Config

The config library allows for interaction between pilight configuration and especially pilight devices.

Warning

Not all devices are currently supported in the config library. More devices will be added in the future.

Devices

userdata pilight.config.device(string device)

The device parameter should correspond to a valid configured device. If the device isn’t configured a nil is returned.

boolean getActionId()

Gets the unique device identifier.

table getId()

Returns the device id multidimensional table.

local dev = pilight.config.device("dimmer");
local id = dev.getId();
print(id[1]['id']); -- 1
print(id[1]['unit']); -- 0
print(id[2]['id']); -- 6
print(id[2]['unit']); -- 2
userdata getName()

Returns the name of the device

table getType()

Returns the device types of the configured device in an array.

boolean hasSetting(string setting)

Checks if the device has a specific setting. If this is true, a corresponding getter and setter are present. E.g. hasSetting('dimlevel') corresponds to setDimlevel(1) and getDimlevel()

boolean setActionId()

Sets a unique identifier for this specific device. This identifier is used to check if an action execution should be aborted or not.

Datetime

number getDay()

Returns the day of the datetime device.

number getMonth()

Returns the month of the datetime device.

number getYear()

Returns the year of the datetime device.

number getHour()

Returns the hour of the datetime device.

number getMinute()

Returns the hour of the datetime device.

number getSecond()

Returns the seconds of the datetime device.

number getWeekday()

Returns the weekday of the datetime device.

number getDST()

Returns the daylight savings time of the datetime device.

number getTable()

Returns a datetime table with year, month, day, hour, minute, second keys with their corresponding values.

Dimmer

number getDimlevel()

Returns the dimlevel of the dimmer.

string getState()

Returns the state of the dimmer.

boolean hasState(string state)

Check if this dimmer can be set to a specific state.

boolean hasDimlevel(number dimlevel)

Check if this dimmer can be set to a specific dimlevel.

boolean setState(string state)

Set the dimmer to a specific device.

boolean setDimlevel(number dimlevel)

Set the dimmer to a specific dimlevel.

string send()

Sends the new settings to the dimmer.

Label

string getLabel()

Returns the label of the label.

string getColor()

Returns the color of the label.

boolean setLabel(string label)

Set the label to a specific label.

boolean setLabel(string label)

Set the label label to a specific color.

string send()

Sends the new settings to the label.

Switch

string getState()

Returns the state of the switch.

boolean hasState(string state)

Check if this switch can be set to a specific state.

boolean setState(string state)

Set the switch to a specific state.

string send()

Sends the new settings to the switch.

Screen

string getState()

Returns the state of the screen.

boolean hasState(string state)

Check if this screen can be set to a specific state.

boolean setState(string state)

Set the screen to a specific state.

string send()

Sends the new settings to the screen.

Settings

number | string pilight.config.setting(string device)

Returns the value of a specific setting in the pilight configuration. If a setting was not configured, a nil is returned.