Smart Living Made Brilliant!
Develop with CastleOS
Introduction & Overview
Interested in developing with the CastleOS platform? Here is everything you need to get started!
CastleOS offers several ways to develop on the platform. First, we offer a powerful web services API, with both WCF and REST endpoints. With these web services, you can do anything in the system, including building your own user interface. In fact, our own apps are built on the same API!
Second, we offer built in C# scripting capabilites. Scripts can be called as part of a scheduled or triggered Event, a Scene, or in response to a voice command being issued to the system. In addition, scripts can be used as a Condition within an Event, allowing the flexibility to condition the execution of an event based on any data source, not just those built into CastleOS.
Third, we are currently developing a custom device and protocol plugin capability, where anyone will be able to write device drivers to expand the number of smart devices CastleOS can interface with. This third development capability will be released in the coming months.
To get started, we offer several downloads that provide examples and/or reference DLLs to include in your own project:
Web Services
Our Windows Communication Foundation (WCF) API uses the web service functionality built into .NET. This allows you to easily integrate CastleOS into any .NET project. We offer two downloads, a full working project which includes an example of using the WCF API in addition to the DLL library, and the DLL library in standalone form for referencing into your own project.
Our REST web service API is for use with all non-.NET projects. The example provided uses JQuery, but it can be used with any framework or langauge capable of calling REST services. Asynchronous calls are supported and recommended. The example is provided in the form of a standalone HTML file. To run the example, simply open the HTML page in a browser.
A full documentation of all web service methods is available here.
Core Service
Core Service Action Script Example
The Core Service Action Script can be used anytime you want to call a script that does something. The script can be called from Events, Scenes, and directly through the API.
Core Service Condition Script Example
The Core Service Condition Script can be used anytime you want to call a script that checks something. While it is in fact possible to do something as well as check something in a Condition script, unlike a pure action script it is required that the script passes back a value to the system. This value could be anything, such as a simple true or false, or something precise like a number or text string. When an Event Condition is based on a Condition Script, the event will only proceed if the value returned by the script matches the value expected by the event.
Core Service Scripting SDK
In addition, we offer a reference DLL for use in Visual Studio 2015 to assist in writing scripts that access the Core Service Scripting API. This DLL allows you to add a reference to the Core Service in your code as well as access all methods and properties that are provided by the Scripting API from within the development environment.
To use this DLL, simply add a reference to it in your Visual Studio project, add a using statement in the relevevant code file (i.e. using CastleOSCoreService), and then access the ScriptingAPI class. Note that this file should only be used a reference during development; it should not be uploaded to CastleOS.
A full plugin capability is currently under development. This will allow members of the community to develop drivers to support smart device and protocols not currently built into CastleOS. While it is our intention to always natively support all of the "major" protocols and devices, the plethora of less common and currently installed legacy devices is quite extensive, and we plan to augment our support of those via our plugin feature. Stay tuned!
Have you developed an integration you'd like featured here? Let us know!
PHP Wrapper by Phil Hawthorne