Capabilities - Joolee/Homey-unofficial-documentation GitHub Wiki

Remove uiQuickaction for OnOff capabilities

Source: https://github.com/martijnpoppen/com.synology/commit/95022932b3acd0609e1652d9cf549f047e43e59d

The Homey app is terribly slow and users often short-click a device by accident when they try to open the device card. This toggles the onOff action, which can be an expensive or unwanted operation. You can disable this default action while keeping the onOff action in the device cards available for the user.

For custom capabilities, you can use the uiQuickAction property to change this behaviour. Unfortunately, it is not possible to override this property using capabilitiesOptions for default capabilities like OnOff. It is possible though, to completely override a default capability.

To do this, simply redefine the whole OnOff capability in your app.json or driver.compose.json and set the uiQuickAction property to false. I have not tried applying this to a single device though and I don't know whether it is even possible.

The default definition is available and always up-to-date on: https://github.com/athombv/node-homey-lib/blob/master/assets/capability/capabilities/onoff.json

Show formatted value in sensor view and usable value in flow tags

For example; My ESP Easy app has an 'uptime' capability for the 'unit' device. In the sensor view I want to have a nice formatted string showing the date/time when the unit booted up. This would be useless in a flow tag though. There I want to have the 'seconds elapsed since boot' value available for use.

  • Sensor view: 2022-02-15 13:07
  • Tag: 12957 seconds

Another use case would be a 'percentage' value which would be available in a tag with a value between 0..100 integer instead of the default 0..1 float.

Unfortunately, it is technically not possible to define a different value for the sensor view and for flow tags. A workaround is possible though, using two custom capabilities. For one of those you set the uiComponent property to null so it will be hidden from the sensor view. (This capability id should be prefixed with measure_ to auto-generate flow cards.) For the other capability, you set the preventTag property to true to prevent making it a tag.

  • measure_value: {"uiComponent": false}
  • pretty_value: {"preventTag": true, "insights": false}

Note that it might be convenient for the user to also have the formatted value available in a flow (for example, to use in notifications or logs). So you might not want to set the preventTag property. I do however advice to set the insights value to false for one of the capabilities if they're both number values.

It is up to the programmer to keep the values in sync though!

Example

Note: I did not use the preventTag property here and I set the insights value to false for both capabilities. This suits my use-case, it might not suit yours.