### Shelly Relay Control Examples (curl) Source: https://context7.com/tyosgood/jtapi-lightcontrol/llms.txt Command-line examples using curl to control Shelly smart relays. Shows how to turn a relay on, off, or toggle its state. Requires the "curl" utility and the correct relay URL. ```bash # Turn relay on: # curl http://192.168.1.60/relay/0?turn=on # Turn relay off: # curl http://192.168.1.60/relay/0?turn=off # Toggle relay: # curl http://192.168.1.60/relay/0?turn=toggle ``` -------------------------------- ### Environment Configuration (.env) Example Source: https://context7.com/tyosgood/jtapi-lightcontrol/llms.txt Example of an environment configuration file (.env) for setting up CUCM connection details. It specifies the CUCM server address and JTAPI user credentials, including required user roles. ```dotenv # .env file configuration # CUCM server IP address or hostname CUCM_ADDRESS=10.10.20.1 # JTAPI application user credentials # User must have roles: "Standard CTI Enabled" and "Standard CTI Allow Control of all Devices" JTAPI_USERNAME=jtapi_user JTAPI_PASSWORD=jtapi_password ``` -------------------------------- ### CyberData Strobe Control Examples (curl) Source: https://context7.com/tyosgood/jtapi-lightcontrol/llms.txt Command-line examples using curl to control CyberData strobe devices. Demonstrates stopping the strobe and starting it with specific patterns and brightness. Requires the "curl" utility and appropriate device IP addresses. ```bash # Stop strobe (idle state): # curl -k -X POST https://192.168.1.55/command \ # -H "Authorization: Basic YWRtaW46YWRtaW4=" \ # -H "Content-Type: application/x-www-form-urlencoded" \ # -d "request=stop_strobe" # Start strobe with pattern (active state): # curl -k -X POST https://192.168.1.55/command \ # -H "Authorization: Basic YWRtaW46YWRtaW4=" \ # -H "Content-Type: application/x-www-form-urlencoded" \ # -d "request=start_strobe&red=255&green=255&blue=255&pattern=slow_blink&brightness=128" ``` -------------------------------- ### Device Mapping Configuration (monitorList.csv) Example Source: https://context7.com/tyosgood/jtapi-lightcontrol/llms.txt Example format for a CSV configuration file (monitorList.csv) used to map Cisco phone device names to their corresponding light control URLs. The device name must exactly match the registered name in CUCM. ```csv # Format: DEVICE_NAME, LIGHT_URL # Device name must match CUCM registered device name exactly ``` -------------------------------- ### Control Shelly Smart Relays via HTTP GET (Java) Source: https://context7.com/tyosgood/jtapi-lightcontrol/llms.txt This Java code controls Shelly Plus smart relays using simple HTTP GET requests. It constructs the URL by appending the action to the base URL, without requiring authentication. Dependencies include standard Java networking libraries. ```java package com.cisco.jtapi.lightControl; import java.util.concurrent.CompletableFuture; import java.net.URI; import java.net.http.*; public class shelly { public static void lightAction(String action, String URL) { HttpClient client = HttpClient.newHttpClient(); // Shelly uses simple GET requests with action appended to URL // Example: http://192.168.1.60/relay/0?turn=on URI myUri = URI.create(URL + action); HttpRequest request = HttpRequest.newBuilder(myUri).build(); CompletableFuture> response = client.sendAsync(request, HttpResponse.BodyHandlers.ofString()); } } ``` -------------------------------- ### Deploy JTAPI JAR to Local Maven Repository Source: https://github.com/tyosgood/jtapi-lightcontrol/blob/master/README.md This bash command demonstrates how to use Maven to deploy a JTAPI JAR file to a local Maven repository. This is useful when you have a specific JTAPI version that is not available in remote repositories or needs to be managed locally. Ensure you replace placeholders with your actual version and file path. ```bash mvn deploy:deploy-file -DgroupId=com.cisco.jtapi -DartifactId=jtapi -Dversion={version} -Durl=file:./lib -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile={/path/to/jtapi.jar} ``` -------------------------------- ### Initialize JTAPI and Monitor Phone States in Java Source: https://context7.com/tyosgood/jtapi-lightcontrol/llms.txt This Java code snippet initializes the JTAPI connection to Cisco Unified Communications Manager (CUCM), reads device mappings from a CSV file, creates terminal objects for monitored phones, and sets up event observers to react to device state changes. It requires JTAPI and dotenv libraries. ```java // Main application startup - connects to CUCM and monitors phone states package com.cisco.jtapi.lightControl; import javax.telephony.*; import com.cisco.jtapi.extensions.*; import io.github.cdimascio.dotenv.Dotenv; import java.util.*; public class superProvider_deviceStateServer { // Device state mapping for human-readable output public static Map stateName = new HashMap<>(); // Device-to-light URL mapping from CSV public static Map deviceList = HashMapFromTextFile(); public static void main(String[] args) throws Exception { // Initialize state name mappings stateName.put(CiscoTerminal.DEVICESTATE_IDLE, "IDLE"); stateName.put(CiscoTerminal.DEVICESTATE_ACTIVE, "ACTIVE"); stateName.put(CiscoTerminal.DEVICESTATE_ALERTING, "ALERTING"); stateName.put(CiscoTerminal.DEVICESTATE_HELD, "HELD"); stateName.put(CiscoTerminal.DEVICESTATE_WHISPER, "WHISPER"); // Load environment configuration Dotenv dotenv = Dotenv.load(); // Initialize JTAPI and connect to CUCM Handler handler = new Handler(); CiscoJtapiPeer peer = (CiscoJtapiPeer) JtapiPeerFactory.getJtapiPeer(null); // Provider connection string format: "cucm_ip;login=user;passwd=pass" String providerString = String.format("%s;login=%s;passwd=%s", dotenv.get("CUCM_ADDRESS"), dotenv.get("JTAPI_USERNAME"), dotenv.get("JTAPI_PASSWORD")); CiscoProvider provider = (CiscoProvider) peer.getProvider(providerString); provider.addObserver(handler); handler.providerInService.waitTrue(); // Create terminals for each device and set up monitoring List terminalList = new ArrayList<>(); for (Map.Entry entry : deviceList.entrySet()) { terminalList.add((CiscoTerminal) provider.createTerminal(entry.getKey())); } // Configure event filters for each terminal for (CiscoTerminal terminal : terminalList) { terminal.addObserver(handler); CiscoTermEvFilter termFilter = terminal.getFilter(); termFilter.setDeviceStateIdleEvFilter(true); termFilter.setDeviceStateActiveEvFilter(true); termFilter.setDeviceStateAlertingEvFilter(true); termFilter.setDeviceStateHeldEvFilter(true); terminal.setFilter(termFilter); } } } ``` -------------------------------- ### Configure Java Runtime in VS Code Source: https://github.com/tyosgood/jtapi-lightcontrol/blob/master/README.md This JSON configuration snippet is used in VS Code's settings.json to specify the Java runtime environment for the project. It ensures that the correct JDK version is used for compilation and execution, which is crucial for projects relying on specific Java versions. ```json { "java.configuration.runtimes": [ { "name": "JavaSE-1.8", "path": "/usr/lib/jvm/java-8-openjdk-amd64" } ] } ``` -------------------------------- ### JTAPI Event Handling and Light Control (Java) Source: https://context7.com/tyosgood/jtapi-lightcontrol/llms.txt Implements JTAPI ProviderObserver and TerminalObserver to react to telephony events. It translates device states like idle, active, alerting, and held into corresponding light control actions by calling a cyberData.lightAction method with specific patterns and light URLs derived from device information. ```java package com.cisco.jtapi.lightControl; import javax.telephony.*; import javax.telephony.events.*; import com.cisco.jtapi.extensions.*; import com.cisco.cti.util.Condition; public class Handler implements ProviderObserver, TerminalObserver { public Condition providerInService = new Condition(); public Condition phoneTerminalInService = new Condition(); // Handle provider connection events public void providerChangedEvent(ProvEv[] events) { for (ProvEv ev : events) { if (ev.getID() == ProvInServiceEv.ID) { providerInService.set(); // Signal provider is ready } } } // Handle terminal/device state change events public void terminalChangedEvent(TermEv[] events) { for (TermEv ev : events) { String deviceName = ev.getTerminal().toString(); String lightUrl = superProvider_deviceStateServer.deviceList.get(deviceName); switch (ev.getID()) { case CiscoTermInServiceEv.ID: phoneTerminalInService.set(); break; case CiscoTermDeviceStateIdleEv.ID: // Phone idle -> turn off light cyberData.lightAction("idle", lightUrl); break; case CiscoTermDeviceStateActiveEv.ID: // Phone active (on call) -> slow blink cyberData.lightAction("active", lightUrl); break; case CiscoTermDeviceStateAlertingEv.ID: // Phone ringing -> fast blink cyberData.lightAction("alerting", lightUrl); break; case CiscoTermDeviceStateHeldEv.ID: // Call on hold -> fade pattern cyberData.lightAction("held", lightUrl); break; } } } } ``` -------------------------------- ### Specify JTAPI Version in Maven POM Source: https://github.com/tyosgood/jtapi-lightcontrol/blob/master/README.md This XML snippet shows how to define the JTAPI library as a dependency in a Maven project's pom.xml file. It allows you to select a specific version of the JTAPI library to be used by the project, enabling compatibility with different CUCM versions. ```xml com.cisco.jtapi jtapi 12.5 ``` -------------------------------- ### Control CyberData Strobe Lights via HTTPS POST (Java) Source: https://context7.com/tyosgood/jtapi-lightcontrol/llms.txt This Java code controls CyberData RGB LED strobe devices using HTTPS POST requests. It handles SSL for self-signed certificates and maps phone states to specific strobe actions like blinking or fading. Dependencies include standard Java networking and security libraries. ```java package com.cisco.jtapi.lightControl; import java.util.*; import java.util.concurrent.CompletableFuture; import java.net.URI; import java.net.http.*; import javax.net.ssl.*; import java.security.*; public class cyberData { public static void lightAction(String action, String URL) { // SSL context for self-signed certificates (CyberData devices) SSLContext sslContext = SSLContext.getInstance("TLS"); TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} } }; sslContext.init(null, trustAllCerts, new SecureRandom()); HttpClient client = HttpClient.newBuilder() .sslContext(sslContext) .build(); // Map phone states to CyberData strobe commands // Pattern options: slow_blink, fast_blink, slow_fade, fast_fade // RGB values: 0-255, brightness: 0-255 switch (action) { case "idle": action = "stop_strobe"; break; case "active": action = "start_strobe&red=255&green=255&blue=255&pattern=slow_blink&brightness=128"; break; case "alerting": action = "start_strobe&red=255&green=255&blue=255&pattern=fast_blink&brightness=128"; break; case "held": action = "start_strobe&red=255&green=255&blue=255&pattern=fast_fade&brightness=128"; break; } // Async POST request to CyberData device // Example URL: https://192.168.1.55/command HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(URL)) .POST(HttpRequest.BodyPublishers.ofString("request=" + action)) .header("Authorization", "Basic " + Base64.getEncoder().encodeToString("admin:admin".getBytes())) .header("Content-Type", "application/x-www-form-urlencoded") .build(); CompletableFuture> response = client.sendAsync(request, HttpResponse.BodyHandlers.ofString()); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.