cr0ybot / almond-adapter Goto Github PK
View Code? Open in Web Editor NEWUnofficial Securifi Almond adapter plugin for Mozilla IoT Gateway
License: Mozilla Public License 2.0
Unofficial Securifi Almond adapter plugin for Mozilla IoT Gateway
License: Mozilla Public License 2.0
https://wiki.securifi.com/index.php/Websockets_Documentation
Connect to websocket API using credentials provided in config.
This looks like the most extensive documentation for now: https://github.com/mozilla-iot/wiki/wiki/Adapter-API
The websocket periodically receives data about DynamicIndexUpdated
values. These should be treated as gateway device update events and should update their properties.
We'll need a utility for sending a request and listening for a matching response (using the mii
utility from #5) over the websocket.
Should probably return a Promise.
Using this DeviceList documentation, we should be able to map Almond devices to WoT Capabilities, and Almond device "values" to WoT Properties, more or less.
Unfortunately, this will include only the most generic information about each device; for instance, Philips Hue non-color bulbs show up for me as a MultilevelSwitchOnOff
which does not include that the device is a lightbulb. A Z-Wave in-wall dimmer switch shows up as just MultilevelSwitch
, but at least in that case it really is just a switch. The Hue bulbs also include a bunch of other "values" that aren't in the documentation for MultilevelSwitchOnOff
that are similar to Device ID 48, HueLamp
, but not in the same order.
Looks like UpdateDeviceIndex
is the Almond API endpoint for altering device values: https://wiki.securifi.com/index.php/Websockets_Documentation#Updatedeviceindex
https://wiki.securifi.com/index.php/Websockets_Documentation#Devicelist
DeviceValues
seem to mostly map to Properties for the most part. Not included in the sample below are Type
values (int) associated with each DeviceValue
entry. I haven't been able to find any public documentation of these Type
values, though I've determined that "SWITCH BINARY" is always type 1.
Sample response:
Response
{
"MobileInternalIndex":"<random key>",
"CommandType":"DeviceList",
"Action":"addAll",
"Devices":{
"1":{
"Data":{
"ID":"1",
"Name":"ContactSwitch #1",
"AssociationTimestamp":"1462172879",
"Type":"12",
"Location":"Default",
"LastActiveEpoch":"1462172879",
"Manufacturer":"Sercomm Co",
"Version":"16",
"Model":"Unknown"
},
"DeviceValues":{
"1":{
"Name":"STATE",
"Value":"true"
},
"2":{
"Name":"LOW BATTERY",
"Value":"0"
},
"3":{
"Name":"TAMPER",
"Value":"true"
}
}
},
"2":{
"Data":{
"ID":"2",
"Name":"BinarySwitch #2",
"FriendlyDeviceType":"BinarySwitch",
"Type":"1",
"ID":"2",
"Location":"Default"
},
"DeviceValues":{
"1":{
"Name":"SWITCH BINARY",
"Value":"true"
}
}
}
}
}
A MobileInternalIndex
(or mii
for short) is used in each request to the Websocket API in order to match a response. Since the Websocket will receive events and other data periodically, we'll need to know how to check if data received is for a specific response sent.
A mii
is a string of random numbers (all example requests use numbers only) up to 32 character long.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.