Hi All,
I’m a beginner in Homey app development and also not having ease with object oriented coding in JS. But I’d love to learn. Also sorry if this topic have already been explained in forum or docs, I read a lot of things and didn’t found a clear answer.
What I would like to achieve is to build a device with more or less 20 capabilities in order to get my boiler information (BUS adapter connected to an ESP32 pushing MQTT params). But I didn’t found out on the existing available apps if something could fit this. If someone know how to do, it will be nice.
Thus my idea is to build an app, just for one device, having almost custom capabilities. Then with 20 flows, updating them with mqtt subcribed topics. Sure I will prefer to put mqtt subscription into my app, but I’m already struggling with basics. But why not.
So, I create an actionCard in which I have an argument that will be filled by mqtt msg. But my device capability value is not updated, I didn’t fount out how to do this. I tried to figure out looking at some piece of code on github, but that’s far away my understanding capability for the moment.
driver.js
const { Driver } = require('homey');
const Homey = require('homey');
class MyDriver extends Driver {
async onInit() {
this.log('MyDriver has been initialized');
const card8700 = this.homey.flow.getActionCard('setvaluetemp1');
card8700.registerRunListener(async (args) => {
const { val8700 } = args;
this.log(val8700);
this.setCapabilityValue('measure_temp1', val8700); // NOT WORKING
})
}
action card: setvaluetemp1.json
{
"title": {
"en": "setValueTemp1"
},
"args": [
{
"type": "text",
"name": "val8700"
}
]
}
device.js
'use strict';
const { Device } = require('homey');
class MyDevice extends Device {
async onInit() {
this.registerCapabilityListener('measure_temp1', async (value) => {
this.log('Changes to :', value);
});
}
capapility measure_temp1.json
{
"type": "number",
"title": { "en": "temp1" },
"uiComponent": "sensor",
"getable": true,
"setable": false,
"units": { "en": "°C" },
"min": -20,
"max": 40,
"step": 0.1
}
How & where to put the “setCapabilityValue” ?
If someone could help on this, or redirect me to another way to achieve my requirement it would be appreciated.
Regards,