Zigbee module
Zigbee module description
Module provides an access to a zigbee functionality (include/exclude devices, set values, get value, etc.).
Zigbee module API ( require "zigbee"
)
start_include()
Start a procedure of including a new Zigbee device. If some Zigbee device has been included a node_added event gets sent.
call: zigbee.start_include()
params: none.
return: none.
example:
require "zigbee"
zigbee.start_include()
stop_include()
Stop a procedure of including a new Zigbee device.
call: zigbee.stop_include()
params: none.
return: none.
example:
require "zigbee"
zigbee.stop_include()
remove_node()
Start a procedure of removing a previously included Zigbee device.
call: zigbee.remove_node()
params: node id (number).
return: none.
example:
require "zigbee"
zigbee.remove_node(node_id)
start_mfg_specific_interview()
Start a procedure of requesting manufacturer specific data with specified manufacturer id from Zigbee device.
call: zigbee.start_mfg_specific_interview()
params: node id (number), mfg code (number).
return: none.
example:
require "zigbee"
zigbee.start_mfg_specific_interview(node_id, mfg_code)
subscribe()
Subscribe a script for Zigbee events. After subscribing the script will be launched for each event happens on a Zigbee addon and information about this event will be passed as a parameter.
call: zigbee.subscribe()
params: script name (string).
return: none.
example:
require "zigbee"
zigbee.subscribe( "HUB:zigbee/scripts/events_handling" )
unsubscribe()
Unsubscribe a script from Zigbee events.
call: zigbee.unsubscribe()
params: script name (string).
return: none.
example:
require "zigbee"
zigbee.unsubscribe( "HUB:zigbee/scripts/events_handling" )
get_node()
Get a Zigbee node by a node_id. (node_id is a part of data coming to a script subscribed for Zigbee events)
call: zigbee.get_node()
params: node id (number).
return: Zigbee node (table). Look at objects page to get a node table format.
example:
require "zigbee"
local node = zigbee.get_node( node_id )
if node then do
print( "node.is_reachable: " .. node.isReachable )
end
get_all_nodes_ids()
Get list of Zigbee node ids included into network.
call: zigbee.get_all_nodes_ids()
params: none.
return: list of Zigbee nodes ids.
example:
require "zigbee"
local node_ids = zigbee.get_all_nodes_ids()
for _, node_id in ipairs(node_ids) do
local node = zigbee.get_node( node_id )
if node then do
print( "node.is_reachable: " .. node.isReachable )
end
end
send_command()
Send command to a specified Zigbee pcp (pcp is specified by node_id, endpoint_id and cluster_name).
call: zigbee.send_command()
params: node_id (int), endpoint_id (int), cluster_name (string), command_name (string), command_params(int or string).
return: none.
example:
require "zigbee"
zigbee.send_command( node_id, endpoint_id, cluster_name, command_name, command_params )
ClusterName | Supported commands names | Supported parameters |
---|---|---|
on_off | On | |
Off | ||
level_control | MoveToLevelWithOnOff | 0 to 254 |
MoveWithOnOff | up | |
down | ||
StopWithOnOff | ||
color_control | MoveToColor | |
MoveToColorTemperature | 1 to 65279 | |
ias_ace | ArmResponse | all_zones_disarmed |
only_day_home_zones_armed | ||
only_night_sleep_zones_armed | ||
all_zones_armed | ||
invalid_arm_disarm_code | ||
not_ready_to_arm | ||
already_disarmed | ||
PanelStatusChanged | panel_disarmed | |
armed_stay | ||
armed_night | ||
armed_away | ||
exit_delay | ||
entry_delay | ||
not_ready_to_arm | ||
in_alarm | ||
arming_stay | ||
arming_night | ||
arming_away | ||
GetPanelStatusResponse | panel_disarmed | |
armed_stay | ||
armed_night | ||
armed_away | ||
exit_delay | ||
entry_delay | ||
not_ready_to_arm | ||
in_alarm | ||
arming_stay | ||
arming_night | ||
arming_away |
set_attribute_value()
Set a specific value for a specified Zigbee pcp (pcp is specified by node_id, endpoint_id, cluster_name and attribute_name).
call: zigbee.set_attribute_value()
params: node_id (int), endpoint_id (int), cluster_name (string), attribute_name (string), value (attribute value type).
return: none.
example:
require "zigbee"
value = true
zigbee.set_attribute_value( node_id, endpoint_id, cluster_name, attribute_name, value )
fields | type | description |
---|---|---|
node_id | int | an id of node |
endpoint_id | int | an id of endpoint |
cluster_name | string | cluster name |
attribute_name | string | attribute name |
value | attribute value type | attribute value to set |
request_attribute_value()
Ask the Zigbee addon to send a *_updated event for a specified pcp, that is get a pcp value asynchronously, by event. (pcp is specified by node_id, endpoint_id, cluster_name and attribute_name).
call: zigbee.request_attribute_value()
params: node_id (int), endpoint_id (int), cluster_name (string), attribute_name (string).
return: none.
example:
require "zigbee"
zigbee.request_attribute_value( node_id, endpoint_id, cluster_name, attribute_name )
request_mfg_specific_attribute_value()
Ask the Zigbee addon to send a *_updated event for a specified manufacturer specific pcp, that is get a pcp value asynchronously, by event. (pcp is specified by node_id, endpoint_id, cluster_id and attribute_id).
call: zigbee.request_mfg_specific_attribute_value()
params: node_id (int), endpoint_id (int), cluster_id (int), attribute_id (int).
return: none.
example:
require "zigbee"
zigbee.request_mfg_specific_attribute_value( node_id, endpoint_id, cluster_id, attribute_id )
configure_attribute_report()
Configure Zigbee pcp to report attribute value to Zigbee Addon. (pcp is specified by node_id, endpoint_id, cluster_name and attribute_name).
call: zigbee.configure_attribute_report()
params: node_id (int), endpoint_id (int), cluster_name (string), attribute_name (string), min_interval(int) (optional), max_interval(int) (optional), reportable_change(attribute value type) (optional).
min_interval
,max_interval
andreportable_change
parameters should be specified togather.return: none.
fields | type | optional | description |
---|---|---|---|
node_id | int | an id of node | |
endpoint_id | int | an id of endpoint | |
cluster_name | string | cluster name | |
attribute_name | string | attribute name | |
min_interval | int | true | the minimum reporting interval in seconds |
max_interval | int | true | the maximum reporting interval in seconds |
reportable_change | attribute value type | true | the minimum change to the attribute that will result in a report being issued |
example:
require "zigbee"
zigbee.configure_attribute_report( node_id, endpoint_id, cluster_name, attribute_name )
configure_mfg_specific_attribute_report()
Configure Zigbee pcp to report manufacturer specific attribute value to Zigbee Addon. (pcp is specified by node_id, endpoint_id, cluster_id and attribute_id).
call: zigbee.configure_mfg_specific_attribute_report()
params: node_id (int), endpoint_id (int), cluster_id (int), attribute_id (int), min_interval(int) (optional), max_interval(int) (optional), reportable_change(attribute value type) (optional).
min_interval
,max_interval
andreportable_change
parameters should be specified togather.return: none.
fields | type | optional | description |
---|---|---|---|
node_id | int | an id of node | |
endpoint_id | int | an id of endpoint | |
cluster_id | int | cluster id | |
attribute_id | int | attribute id | |
min_interval | int | true | the minimum reporting interval in seconds |
max_interval | int | true | the maximum reporting interval in seconds |
reportable_change | attribute value type | true | the minimum change to the attribute that will result in a report being issued |
example:
require "zigbee"
zigbee.configure_mfg_specific_attribute_report( node_id, endpoint_id, cluster_id, attribute_id )