- Files:
-
- 67 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
/trunk/S_TCPLightingGateway1.xml
r20 r30 22 22 <actionList> 23 23 <action> 24 <name> Login</name>24 <name>Pair</name> 25 25 </action> 26 26 <action> -
/trunk/I_TCPLighting1.xml
r20 r30 133 133 local current_value = luup.attr_get (attr_name, device_number) 134 134 if (not current_value) or (new_value ~= current_value) then 135 luup.log ("TCPLighting: update_attr - device_number=" .. device_number)136 luup.log ("TCPLighting: update_attr - attr_name=" .. attr_name)137 luup.log ("TCPLighting: update_attr - new_value=" .. new_value)135 luup.log ("TCPLighting: update_attr - device_number=" .. tostring(device_number)) 136 luup.log ("TCPLighting: update_attr - attr_name=" .. tostring(attr_name)) 137 luup.log ("TCPLighting: update_attr - new_value=" .. tostring(new_value)) 138 138 luup.attr_set (attr_name, new_value, device_number) 139 139 end … … 309 309 -- for subsequent calls 310 310 -- --------------------------------------------------------------------- 311 function login_to_gateway (lul_device)312 313 luup.log ("TCPLighting: login_to_gateway - start")311 function pair_with_gateway (lul_device) 312 313 luup.log ("TCPLighting: pair_with_gateway - start") 314 314 315 315 local device_number = tonumber(lul_device) … … 337 337 338 338 -- login to the gateway 339 luup.log ("TCPLighting: login_to_gateway - IP=" .. tostring(gateway.gateway_ip))340 luup.log ("TCPLighting: login_to_gateway - UUID=" .. tostring(gateway.gateway_uuid))341 tcplighting_gateway_ login(gateway)342 luup.log ("TCPLighting: login_to_gateway - Token=" .. tostring(gateway.gateway_token))339 luup.log ("TCPLighting: pair_with_gateway - IP=" .. tostring(gateway.gateway_ip)) 340 luup.log ("TCPLighting: pair_with_gateway - UUID=" .. tostring(gateway.gateway_uuid)) 341 tcplighting_gateway_pair (gateway) 342 luup.log ("TCPLighting: pair_with_gateway - Token=" .. tostring(gateway.gateway_token)) 343 343 344 344 if (gateway.gateway_token) then 345 345 346 -- update device variables 346 347 update_variable (GATEWAY_SERVICE_ID, "GatewayToken", gateway.gateway_token, device_number) 347 348 update_variable (GATEWAY_SERVICE_ID, "GatewayUUID", gateway.gateway_uuid, device_number) 348 349 update_variable (GATEWAY_SERVICE_ID, "ErrorText", gateway.error_text, device_number) 350 351 -- initiate a sync 352 luup.log ("TCPLighting: pair_with_gateway - synchronizing") 353 return synchronize_gateway (lul_device) 349 354 350 355 else 351 356 352 357 -- flag that there was an error 353 luup.log ("TCPLighting: login_to_gateway - error: " .. gateway.error_text)358 luup.log ("TCPLighting: pair_with_gateway - error: " .. gateway.error_text) 354 359 update_variable (GATEWAY_SERVICE_ID, "ErrorText", gateway.error_text, device_number) 355 360 356 361 end 357 362 358 luup.log ("TCPLighting: login_to_gateway - end")363 luup.log ("TCPLighting: pair_with_gateway - end") 359 364 360 365 return true … … 379 384 local gateway_token = luup.variable_get (GATEWAY_SERVICE_ID, "GatewayToken", device_number) 380 385 if (not gateway_token) or (gateway_token == "") then 381 gateway.error_text = "No gateway token assigned, use device configuration UI to loginfirst"386 gateway.error_text = "No gateway token assigned, use device configuration UI to pair first" 382 387 update_variable (GATEWAY_SERVICE_ID, "ErrorText", gateway.error_text, device_number) 383 388 return true … … 523 528 <action> 524 529 <serviceId>urn:pmcode-org:serviceId:TCPLightingGateway1</serviceId> 525 <name> Login</name>526 <run>return login_to_gateway (lul_device)</run>530 <name>Pair</name> 531 <run>return pair_with_gateway (lul_device)</run> 527 532 </action> 528 533 -
/trunk/L_TCPLighting1.lua
r20 r30 47 47 48 48 -- ---------------------------------------------------------------------------- 49 -- Login toa Connected by TCP gateway49 -- Pair with a Connected by TCP gateway 50 50 -- 51 51 -- Note: User must put gateway into "pairing" mode by pressing 52 52 -- green sync button (green on the model I have anyway) 53 53 -- ---------------------------------------------------------------------------- 54 function tcplighting_gateway_ login(gateway)54 function tcplighting_gateway_pair (gateway) 55 55 56 56 -- Bail if we don't a gateway 57 57 if (not gateway) then 58 gateway.error_text = "No gateway object provided, loginfailed"58 gateway.error_text = "No gateway object provided, pairing failed" 59 59 return gateway 60 60 end … … 62 62 -- Bail if we don't a gateway IP 63 63 if (not gateway.gateway_ip) then 64 gateway.error_text = "No gateway IP address specified, loginfailed"64 gateway.error_text = "No gateway IP address specified, pairing failed" 65 65 return gateway 66 66 end … … 68 68 -- Bail if we don't have a gateway UUID 69 69 if (not gateway.gateway_uuid) then 70 gateway.error_text = "No gateway UUID address derived, loginfailed"70 gateway.error_text = "No gateway UUID address derived, pairing failed" 71 71 return 72 72 end … … 96 96 97 97 if (not gateway.gateway_token) then 98 gateway.error_text = "No gateway token extracted, loginfailed"98 gateway.error_text = "No gateway token extracted, pairing failed" 99 99 if status then gateway.error_text = gateway.error_text .. " - HTTPS status=" .. status end 100 100 if rc_value then gateway.error_text = gateway.error_text .. " - Gateway RC=" .. rc_value end -
/trunk/D_TCPLightingGateway1.json
r20 r30 57 57 { 58 58 "ControlType": "label", 59 "Label": {"lang_tag": " login_desc","text": "Securely Login/Pair with the gateway - Press the green sync button on the gateway first "},59 "Label": {"lang_tag": "pair_desc","text": "Securely Login/Pair with the gateway - Press the green sync button on the gateway first "}, 60 60 "Display": {"Top": 20,"Left": 50,"Width": 200,"Height": 20} 61 61 }, 62 62 { 63 63 "ControlType": "button", 64 "Label": {"lang_tag": " login_command","text": "Login"},64 "Label": {"lang_tag": "pair_command","text": "Pair"}, 65 65 "Display": {"Top": 37,"Left": 50, "Width": 100, "Height": 20 }, 66 "Command": {"Service": "urn:pmcode-org:serviceId:TCPLightingGateway1", "Action": " Login", "Parameters": []}66 "Command": {"Service": "urn:pmcode-org:serviceId:TCPLightingGateway1", "Action": "Pair", "Parameters": []} 67 67 }, 68 68 {
Note: See TracChangeset
for help on using the changeset viewer.