-
If you have questions about the App Device Capabilities or seek help with an Flow or with the Flow Exchanger, please see the Device Capabilities Topic.
-
If you have questions about the Advanced Virtual Device or seek help with the Exchanger File, please see the Advanced Virtual Devices Topic.
This topic! -
If you want to post a AVD as a Template for others to use, please post it on Share Your Device! - Advanced Virtual Devices.
-
If you want to post a Flow(s) as a Template for others to use, please post it on The Flow Exchange(r) - Exchange Your Flows with Others!.
Thanks!
If you also want a status text on your device tile, please continue reading!
Device Capabilities 2.0 App voor Homey | Homey
It’s live!
This Addendum to Device Capabilities (Forum topic) is for explanation on, and examples, for the newly created free fully customisable virtual device.
Fully Customisable Advanced Virtual Device with Unique Text Status Indicator for Device Tile.
You yourself can completely customise these virtual devices, the way you want!
Also allows for the creation of Insights for capabilities of existing devices that have no insights.
To explain how far this goes and how this works, i will create a Livingroom Device, which i will configure to accommodate multiple devices in my livingroom.
I will be using the Web App for this example and Advanced Flows, but neither are needed.
Because of the length of this article, i placed the texts inside summaries, click on them to open to open.
Living Room Example
Create a device
Summary
Goto create a device, then select Device Capabilities, then Virtual Device (the name is up for suggestions and could be changed).
A list with one device will be shown (allthough you can create more if you wish, one by one).
Click continue.
Next you can select a icon from the list, or you can upload your own icon.
After that, click continue.
The device will now have been created and you can change the name to Living Room.
Enter the Device Settings
Summary
Because there are a lott of Device Settings, i’m gonna do this step by step.
The status field is unique, and can be used as a textual (and number) status on the device tile in the Web/Mobile App.
I am gonna turn button 1 into an indicator. That means that the device tile in the Web/Mobile App will be light/dark based on that buttonvalue.
You remove a field by removing its name.
Only button 1 can be a hidden button, so i will first use other buttons, until i know what i will use it for.
After removing all fields and pressing save, my device looks empty:
Create Media Buttons
Summary
Firstly, i want my media to show on this device, firstly from my sonos, but we can later overrule that to also show TV info.
We first need a few buttons for this:
Create a Flow
Summary
Now we need a flow to handle this virtual device.
We need to setup the status and reactions to the music buttons.
- Because the Playing button can be false or true, we need to check the value (waarde)
After this, the playing button on the LivingRoom device can be used to start the music, and it will also show it if music is playing or not.
Next up we need to react to the previous and next button being pushed.
- No need here to check for the value, it will always be true
Textfields
Volume
Summary
First we add a Volume to the settings.
And then we write the next flow.
And, tada, we are done with the Media!
Lets now add the four Curtains that we have in our livingroom to this same device.
Four Curtains
Summary
Again we go into the device settings to add four number fields:
And for those we need flows, two ways.
First a reaction to us change the slider in the Living Room device:
Then we need to update its status:
And now we have, within this one device, my music and my curtains from the livingroom in one device
Custom Buttons
Summary
Lets continue with Buttons for the TV and Xbox.
First we define the buttons in the device settings:
This gives us two on-off buttons on the small button tab, next to each other, so we see tham al at once.
We could actually do the exact same thing with the Yes/No fields, when set to Button
Would result in:
But back to the Buttons, lets add a flow for the TV first:
And next for the xbox:
And the final result us now:
One Main Curtain Button
Summary
Now i want one button for all my curtains, which should be a light button when one is open, and dark when all are closed.
Will result in:
And now for the flows.
First a flow, that when i push the button, i want them to all close/open:
Setting and Using Functions
Summary
And now for the button status to be set.
But for this we first add a function in App settings.
We go to the bottom, fill in average
and press add function:
Then we scroll down and press on edit, and fill in the function:
function () {
var sum = 0.00;
for( var i = 0; i < arguments.length; i++ ){
sum += parseFloat( arguments[i], 10 );
}
return sum/arguments.length;
}
Please note that you don’t give the function a name in the codefield, but in the namefield.
No we go back to the flow for the curtains.
For this we use a Set field to Expression card:
And here we use the average function from the App Settings.
All the number tags are not from the flowcards (because only one trigger triggers the flow), but the tags from the curtain-devices.
And once again, tada! We can now close all curtains in the Living room with one button, next to the tv button
let dcApp = await Homey.apps.getApp({id:'nl.qluster-it.DeviceCapabilities'});
Added an API call to set the value of AVD fields:
await dcApp.apiPost('setvalue', {device:'Day-Amount', field:'number1', value:21});
await dcApp.apiPost('setvalue', {device:'Day-Amount', field:'measure_devicecapabilities_number-custom_1.number1', value:22});
await dcApp.apiPost('setvalue', {device:'c34dc5b4-3c30-48a9-8a4e-014aea93d00d', field:'measure_power', value:501});
Added an API call to set the name of AVD fields:
await dcApp.apiPost('setfieldname', {device:'Day-Amount', field:'number1', name:'Day-More'});
await dcApp.apiPost('setfieldname', {device:'Day-Amount', field:'measure_devicecapabilities_number-custom_1.number1', name:'Day-More'});
await dcApp.apiPost('setfieldname', {device:'c34dc5b4-3c30-48a9-8a4e-014aea93d00d', field:'measure_power', name:'Day-More'});
If you would like to add an example, please feel free to do so.