Headings from h1 through h6 are constructed with a # for each level:
# h1 Heading
## h2 Heading
### h3 Heading| var cflinkRegex = /\xF2([\s\S])\xF3([QCTR])(\w{3})(\w{3})\xF4([\s\S]*?)\xF5\xF5/g; // Capture groups: ID, Command Type, Device, Command, Data | |
| var rcvBuffer; | |
| function incomingData(fbName, rcv) { | |
| // Append new incoming data to buffer | |
| rcvBuffer += rcv; | |
| var matches; | |
| var matchedData = ""; | |
| // Loop through any complete CFLink packets |
| // Change these variables to suit your setup | |
| var username = "admin"; | |
| var password = "password"; | |
| var ipAddress = "192.168.0.100"; | |
| // Call this function from your button press like this: | |
| // sendToIPSymcon("SetValue", [12345, 42]); | |
| // sendToIPSymcon("SetValue", [12346, false]); | |
| function sendToIPSymcon(method, params) { | |
| CF.request("http://" + username + ":" + password + "@" + ipAddress + ":3777/api/", "POST", {"Content-Type": "application/json"}, {"jsonrpc": "2.0", "id": "0", "method": method, "params": params}, function (status, headers, body) { |
| // Create an object that we can update as we get data in, before adding a complete entry to a list | |
| var currentCallData = {}; | |
| CF.userMain = function() { | |
| // The regex for this feedback item should be: CallHistoryRecentResults Entry (\d+) | |
| CF.watch(CF.FeedbackMatchedEvent, "TELEPRESENCE", "HISTORY_CALL_FEEDBACK", function(fbName, data) { | |
| // We get three rows of data for each actual call: | |
| // CallHistoryRecentsResult Entry 0 CallbackNumber: "sip:[email protected]" | |
| // CallHistoryRecentsResult Entry 0 DisplayName: "5557777" |
| // Code to run on startup | |
| CF.userMain = function() { | |
| // watch the feedback coming from the system, adjust the values to match the system name and feedback name in your guiDesigner project | |
| CF.watch(CF.FeedbackMatchedEvent, "HeatmiserWired", "Capture", function(fbName, data) { | |
| dataBuffer += data; // Append the incoming data to the buffer, now process it | |
| var MessageCount = 0; | |
| while ((matches = dataRegex.exec(dataBuffer)) !== null) { | |
| if (matches) { | |
| var length = matches[1].charCodeAt(0); // Get the length decimal value | |
| if (dataBuffer.length >= (length + lengthAdd)) { |
| // Map a Fibaro device ID to a join number | |
| // The join number should be prefixed by the join type (a = analog, d = digital, s = serial, etc) | |
| var joinIDMap = { | |
| "12": "a1002", | |
| "1": "a1015", | |
| "45": "a1043", | |
| "23": "a1008" | |
| }; | |
| // Eg. doCommand("callAction", 168, "turnOn"); |
| var myJSON, baseURL = "http://192.168.1.90:3480/data_request?id=lu_status2&DataVersion=1&DeviceNum="; | |
| function requestData(deviceNum) { | |
| CF.request(baseURL + deviceNum, function(status, headers, body) { | |
| if (status == 200) { | |
| // OK response received, now grab the JSON string from body and turn it into an object | |
| myJSON = JSON.parse(body); | |
| // Now assign one of the known state variables to a serial join (if it will always be at a certain index in the state array) |
| function makeReadable(bytes) { | |
| var readable = "", i; | |
| for (i = 0; i < bytes.length; i++) { | |
| var byteVal = bytes.charCodeAt(i); | |
| if (byteVal < 32 || byteVal > 127) { | |
| readable += "\\x" + ("0" + byteVal.toString(16).toUpperCase()).slice(-2); | |
| } else { | |
| readable += bytes[i]; | |
| } | |
| } |
| var WTH={ | |
| weather: {}, | |
| setup: function (){ | |
| CF.log("Weather Module setup function has been called"); | |
| }, | |
| getData: function(url, dataReceivedCallback) { | |
| // to be able to access our variable, we need to keep a reference to |
| // To listen to feedback in JS, you need to use CF.watch within the userMain function, like this: | |
| // Note: "Incoming Alarm Data" is the name of the feedback item in guiDesigner, replace these with whatever name you are using in your GUI. | |
| // The regex you use in your feedback item determines WHEN the FeedbackMatchedEvent is triggered, but has no affect on the data sent to JavaScript. | |
| // Instead your script will be sent the full string of data that was received from your external system, so long as it matches the regex. | |
| // So if you wanted ALL data to be processed in JavaScript, you could use a "catch all" RegEx as simple as: (.*) | |
| CF.userMain = function() { | |
| CF.watch(CF.FeedbackMatchedEvent, "System Name", "Incoming Alarm Data", function(feedbackName, matchedString) { | |
| // Code for using the matched data goes here... | |
| }); |