Question about timeline, energy and tiles

Working on an App as a beginner with Homey and Javascript and have some questions.

My device is classified as ‘other’ in the driver.compose.json file, and I noticed that when defining the following:

"energy": {
    "approximation": {
      "usageOn": 15, 
      "usageOff": 1   
    }
  },

it doesn’t show up in the Settings of the device, it only shows ‘Constant Energy usage’ (see pic).

Does this have anything todo with the device class? As it’s not accepting the settings in the .json file?

2nd question. I noticed some devices from other brands include a timeline when jou click the device (see pic below)

How would this be implemented in the app? does it again have to do with the Class or capabilities (I am using defined .json capabilities and not the standard ‘onoff’)

and 3rd,

Some tiles have the option to show a status, either a message, power, or dim value, is there anyway to add a custom value on the tile as status value?

Thanks! :slight_smile:

Q1)
Have you added an onoff or dim capability? Based on the docs it is the requirement for Approximated power usage.

Q2)
The device shows a timeline for boolean capabilities (like onoff).
You can add descriptions for on or off state in capabilityOptions (insightsTitleTrue/insightsTitleFalse) if you don’t want to get standard “switched on/off” text.

Q3)
Every numeric or alarm capability can be selected (only!) in mobile app in device settings. That’s nothing you can predefine. The user has to select a value. It’s not possible to select/show string capabilities on a tile.

Maybe soon™ it will be :magic_wand:

Yes, would be really nice.
But currently it’s only used for numbers and alarms ( :warning: symbol)

1 Like

Thanks for the quick reply. As mentioned, I am using capabilities defined in .json file, like this;

{
    "type": "boolean",
    "title": { 
      "en": "turned on",          
      "nl" : "aangezet" },
    "insightsTitleTrue" : {
      "en": "turned On",
      "nl":"aangezet"
    },
    "insightsTitleFalse": {
      "en": "Turned off",
      "nl":"Uitgezet"
    },  
    "getable": true,
    "setable": true,
    "uiComponent": "toggle",
    "uiQuickAction": true,
    "icon": "/assets/power.svg"
  }

That doesn’t do the job unfortunately. Not sure where to define the ‘onoff’ capability, as device.compose.json contains this:

...
"class": "other",
  "capabilities": [
       "button_power",
       "button_down",
       "button_up",
       "button_light"
	],
...

You have defined custom capabilities. Only benefit would be to use a custom icon.
I suggest to use onoff capability for the main switch.
Then define own title/insightTitle as capabilityOptions.

Benefit is: you get flow trigger/actions/conditions for free fot this switch. But you can’t change the icon in capabilityOptions.

Example:

"class": "other",
  "capabilities": [
       "onoff",
       "button_down",
       "button_up",
       "button_light"
	],

"capabilitiesOptions":{
  "onoff":{
    "title": { 
      "en": "turned on",          
      "nl" : "aangezet" },
    "insightsTitleTrue" : {
      "en": "turned On",
      "nl":"aangezet"
    },
    "insightsTitleFalse": {
      "en": "Turned off",
      "nl":"Uitgezet"
    }
  }

But you only need capabilitiesOptions when you define different titles. If you are happy with default titles, just use:

"class": "other",
  "capabilities": [
       "onoff",
       "button_down",
       "button_up",
       "button_light"
	]

Here you can find standard capabilities:

Btw. you can also use subcapabilities like:

"class": "other",
  "capabilities": [
       "onoff",
       "onoff.sub1",
       "button_down",
       "button_up",
       "button_light"
	],

"capabilitiesOptions":{
  "onoff":{
    "title": { 
      "en": "turned on",          
      "nl" : "aangezet" },
    "insightsTitleTrue" : {
      "en": "turned On",
      "nl":"aangezet"
    },
    "insightsTitleFalse": {
      "en": "Turned off",
      "nl":"Uitgezet"
    },
  "onoff.sub1":{
    "title": { 
      "en": "Sub1 turned on",          
      "nl" : "Sub1 aangezet" },
    "insightsTitleTrue" : {
      "en": "Sub1 turned On",
      "nl":"Sub1 aangezet"
    },
    "insightsTitleFalse": {
      "en": "Sub 1Turned off",
      "nl":"Sub 1 Uitgezet"
    }
  }

PS: please use direkt repsonse on a post or addd someone using @name that we get an information about your response.

Thanks, will do. And will have a look at it.

As for the sub capabilities, let’s say the main onoff would be for a fan, second onoff for a light, would that need any other definitions as well? I did notice some tiles show a light when it’s on and I guess that only works when it’s classed as a light? since this device is both I use the ‘other’ class.

Yes, the light icon (right upper corner of device tile) is only shown for a light class.
In your case you have to choose what’s the main usage, fan or light. Based on this I would select the class.

Then I would only use one onoff capability (to switch the light if class=light or switch fan if class=others).
The onoff capability addes a quick action (you can press the tile), so the user should know if it’s acting on the light or fan.

The other switch I would not define as onoff because this way you will get several “big” switches on device view you have to select via dropdown.
So additional switches I would add to the button view (smaller buttons, but acting as switch).
I defined a custom capability for:

Then it looks like:


For this button-like switch you could use a custom icon (e.g. fan).

Thanks, will have a play with it.

Wouldn’t it be nice to have the insights and power usage also working for custom capabilities? Not sure if that topic is already addressed?

In most cases Athom is reading the standard capabilities for such things (power settings). Subcapabilities won’t work, too.

But device insights will work also for custom capabilitites - if they are boolean. Numeric capabilities will be stored in insights.

Ok thanks,

Must be doing something wrong, wanted to try the onoff capability, but when defining it in the .json and then trying to execute the following;

this.setCapabilityValue('onoff', false).catch(MyDevice.error);

the following error appears

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error: Invalid Capability: onoff
    at Remote Process
    at HomeyClient.emit (/node_modules/@athombv/homey-apps-sdk-v3/lib/HomeyClient.js:44:23)
    at Object.emit (/node_modules/@athombv/homey-apps-sdk-v3/manager/drivers.js:78:54)
    at Object.emit (/node_modules/@athombv/homey-apps-sdk-v3/lib/Driver.js:126:50)
    at /node_modules/@athombv/homey-apps-sdk-v3/lib/Device.js:570:27
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at MyDevice.setCapabilityValue (/node_modules/@athombv/homey-apps-sdk-v3/lib/Device.js:562:23)
    at MyDevice.onInit (/app/drivers/test/device.js:27:10)
    at MyDevice._onInit (/node_modules/@athombv/homey-apps-sdk-v3/lib/Device.js:148:18)
    at /node_modules/@athombv/homey-apps-sdk-v3/lib/Driver.js:180:34
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  statusCode: 404
}

If you use an existing device and just add the capability in driver json, the device won’t get it added. You have to create a new device or check/add the capability in device.onInit() with if (!this.hasCapability(‘onoff’){this.addCapability(‘onoff’)}.

And catch the error in right way to avoid unhandled exceptions that would crash the app.
.catch(error){this.log(“Error blabla”, error.message)}

Great! many thanks and once again much appreciated for the patience and help.

I noticed the on/off capability delivers flowcards automatically as you mentioned before.

Is there anyway to tap into these standard cards (action, trigger, condition) programatically? I do need some additional code when turning the device on/off. If not possible, can the default flowcard perhaps be disabled or removed?

The flow is triggered on capability change.
You can register a capabilityListener for the capability. Then you can react on changes (via device tile or flow) and do your stuff.

1 Like

Wow that’s cool and great news, Emile. Thanks!
Did I miss a publication :upside_down_face: ?
EDIT:
Yes I missed it, while I never connected this message with the status indicator :face_with_peeking_eye: :

It leaves me one thought / request though:
With a device class ‘thermostat’ one can´t select the status indicator, it’s just fixed to the target temperature capability;
Is it somehow possible to make the status indicator for thermostats selectable, while setting the target temperature as default status indicator?
In that case one can choose between room temp, target temp, and string values mode (i.e. Auto/Weekend/Scheduled) and status (i.e. Heating/Off/Cooling)

F.i. when I create a sensor class device with all my thermostat sensors, I can select ‘Status’ for instance. Would be nice to have in a thermostat class device:
Screenshot from 2023-08-22 15-22-55

Screenshot from 2023-08-22 15-23-41

1 Like

Your sensor has a string capability (only text)?
The thermostat mode is a enum list with strings as ID and language dependent descriptions. I guess the tile only presents text/numeric/bool capabilities but no enum capabilities.

Yes, think I got that for the custom capabilities, but for the standard ‘onoff’ I meant. since it creates the flows automatically and there is no specific code needed for it right? so this; this.homey.flow.getActionCard('onoff'); will not work?

This is only needed to react on the flow. I think inside the capability gets changed and you can react on this with creating a capability listener. So you can react on every change (flow and device).

It is a sensor device with custom added entities, Ronny:



When one adds a climate device, the Status Indicator can´t be selected, while it has the thermostat class



The capabilities of the climate device are present, but if only Athom made the status indicator for Thermostat class freely selectable…

How can I test with Enum type capabilities you think?