This library contains functions and maps for KNX devices
static_project_devices:
List of initial projects containing KNX Device Addresses.
dynamic_project_devices:
List of added projects containing KNX Device Addresses.
Iterates through every valid KNX device address with 3 seconds intervals and pings it.
If there is a response, it's saved to a list and then stored.
The 3 second delay is choosen in order to decrease the load on the KNX bus, the bus load increases by about 8% while the scan is active.
Can be used to initialize the static_project_devices list.
NOTE: The total elapsed time between each ping alone is almost 54 hours. Because of this, it's recommended to create a separate script for this function alone.
Takes 1 parameter (4 byte UNIT) and converts it into a valid KNX Device Address or nil (if the KNX Device Address is invalid).
The last 3 digits is used to specify how many digits there are for each address component (Area/Line/Device).
This function is meant to be used in a Event-based script,
so that you can write the address value to an group address which will trigger the script.
For readability I recommend writing the address value as such: 15 15 255 2 2 3, instead of: 15152552223.
ETS will automatically format the value.
Pings every address from the choosen static project.
Every successfull ping is added to a list.
The list is saved as: <projectname>_pinged.
The list is also returned as a result.
Restarts every device in the choosen dynamic device list and returns either:
- nil, if the project doesn't exist,
- false, if 1 or more device didn't restart
- true, if every device was restarted
Takes 1 parameter (project name) and returns either a static list of device addresses or nil.
Takes 2 parameters (project name, device address list) and creates / updates a static device list.
Takes 1 parameter (project name) and removes that project from the static device list.
Returns a list containing every project in the dynamic device list.
Takes 1 parameter (project name) and returns a boolean based on if the project exists.
Takes 2 parameters (project name, address).
Creates a new project if it doesn't exist.
Then the address is added if it doesn't already exist.
Takes 2 parameters (project name, list of addresses)
Creates a new project if it doesn't exist.
Then each address is added if they doesn't already exist.
___
Takes 1 parameter (project name) and returns either a list of dynamic device addresses or nilTakes 2 parameters (project name, address) and returns a boolean based on if the address exists in that project.
Takes 1 parameter (project name) and clears all addresses within that project.
Removes every project and associated addresses that isn't included in that static project list from the dynamic project list.
Required:
devices = require('user.deviceAddressesLib')devices.scan_all_devices()-- You can't use whitespaces if you write the uint_addresses like this:
local uint_address1 = 10103221
local uint_address2 = 1515255223
local uint_address3 = 0150112
log(devices.byte4_uint_to_address(uint_address1))
log(devices.byte4_uint_to_address(uint_address2))
log(devices.byte4_uint_to_address(uint_address3))
-- From a Event trigger:
local unint_address = event.getvalue() -- Inputted value in ETS: 3 10 80 1 2 2, formatted value: 31080122
local knxAddress = devices.byte4_uint_to_address(unint_address)
log(knxAddress)
devices.add_address('test', knxAddress)
uint_address1 (10 10 3 2 2 1):
2 2 1 specifies that:
The main component has 2 digits (10),
the line component has 2 digits (10)
and the device component has 1 digit (3)
uint_address2 (15 15 255 2 2 3):
2 2 3 specifies that:
The main component has 2 digits (15),
the line component has 2 digits (15)
and the device component has 3 digits (255)
uint_address3 (0 1 50 1 1 2):
1 1 2 specifies that:
The main component has 1 digit (0),
the line component has 1 digit (1)
and the device component has 2 digits (50)
uint_address (3 10 80 1 2 2):
1 2 2 specifies that:
The main component has 1 digit (3),
the line component has 2 digits (10)
and the device component has 2 digits (80)
10.10.3
15.15.255
0.1.50
3.10.80
project = 'project2'
addresses = devices.ping(project)
if addresses then
log(addresses)
end'2.0.0',
'2.1.0',
'2.2.0'
project = 'project2_pinged'
result = devices.restart(project)
if not result then
log('Error, project doesnt exist')
elseif result == true then
log('All devices have been restarted')
else
log('Error, failed to restart some devices')
end'Error, project doesn't exist' or
'All devices have been restarted' or
'Error, failed to restart some devices'
'project1' = {
'1.0.0',
'1.1.0',
'1.2.0'
},
'project2' = {
'2.0.0',
'2.1.0',
'2.2.0'
},
'project3' = {
'3.0.0',
'3.1.0',
'3.2.0'
}
local static_project_1 = devices.get_static_list('project1')
log(static_project_1)'1.0.0',
'1.1.0',
'1.2.0'
local projectName = 'project7'
local deviceList = {}
for i = 0, 2 do
for j = 0, 10 do
table.insert(deviceList, '7.' .. i .. '.' .. j)
end
end
devices.add_static_list(projectName, deviceList)
log(devices.get_static_list(projectName))
'7.0.0',
'7.0.1',
'7.0.2',
'7.0.3',
'7.0.4',
'7.0.5',
'7.0.6',
'7.0.7',
'7.0.8',
'7.0.9',
'7.0.10',
'7.1.0',
'7.1.1',
'7.1.2',
'7.1.3',
'7.1.4',
'7.1.5',
'7.1.6',
'7.1.7',
'7.1.8',
'7.1.9',
'7.1.10',
'7.2.0',
'7.2.1',
'7.2.2',
'7.2.3',
'7.2.4',
'7.2.5',
'7.2.6',
'7.2.7',
'7.2.8',
'7.2.9',
'7.2.10'
local projectName = 'project7'
devices.clear_static_list(projectName)
log(devices.get_static_list(projectName))
nil
projects = devices.get_dynamic_projects()
log(projects)'project1',
'project2',
'project3',
'project4',
'project5',
'project6'
myProject1 = 'project1'
myProject2 = 'Test'
log(devices.dynamic_project_exists(myProject1))
log(devices.dynamic_project_exists(myProject2))true
false
project = 'project2'
address = '5.0.10'
devices.add_dynamic_address(project, address)project = 'project2'
address = '5.0.10'
devices.remove_dynamic_address(project, address)project = 'project2'
listOfAddresses = {
'5.0.10',
'5.0.11',
'5.0.12',
'5.0.13'
}
devices.add_dynamic_list(project, listOfAddresses)project = 'project2'
listOfAddresses = get_dynamic_list(project)
log(listOfAddresses)'5.0.0',
'5.0.5',
'5.0.6',
'5.0.1',
'5.0.2',
'5.0.3',
'5.0.7',
'5.0.8',
'5.0.9',
'5.0.10',
'5.0.11',
'5.0.12',
'5.0.13'
projectName1 = 'project1'
projectName1 = 'Test'
deviceAddress1 = '1.1.0'
deviceAddress2 = '20.1.0'
log(devices.dynamic_exists(projectName1, deviceAddress1))
log(devices.dynamic_exists(projectName1, deviceAddress2))
log(devices.dynamic_exists(projectName2, deviceAddress1))
log(devices.dynamic_exists(projectName2, deviceAddress2))true
false
false
false
project = 'project1'
devices.clear_dynamic_data(project)devices.clear_all_dynamic_data()