[APP][Pro] Virtual Devices - Virtual Devices to simulate 1 or more real devices

Hi Arie,
thanks for your feedback. I hoped it could be possible, but understand that big changes for such a special case are not useful/rational for app consitency. I’ll just create single VDs for each sensor value.
Btw… other measure-types (liter, gramm instead of m³, kg) are not possible I think because of Atoms predefined types, right?
Kind regards
Ronny

Correct!

1 Like

Is it possible to change the units? I created a virtual wind strength sensor. The unit is in km/h. I would like to have it in m/s

The units of capabilities are set by Athom and cannot be changed to my knowledge.

1 Like

Does Alexa still support only lights, switches and heating VDs?
I tried adding a curtain virtual device and it’s not showing up in Alexa upon discovery

I have a question, is there a way to force Homekit to see VD as per category that I picked? I want to have a garage door, but Homekit sees it always as a switch.

I have been using some virtual devices to trigger my (custom) lights for years now, but somehow after upgrading it stopped working as before.

Now I already had the flow separated between turning the lights on or off (on -> start a Homey script, off -> call a URL), but it looks like switching the lights off doesn’t trigger anything at all anymore.
I tried removing the separation between switching on and off and just call my script when the device is changed:

My flow:

According to the logs (and the output of my script) this flow is only triggered when I switch the device off. When I switch it on, nothing happens.

Maybe your system needs a PTP (pull the plug for 15 minutes, put the plug back, wait another 30 miutes)

I just tried this, but it didn’t make any difference.

The script I call is:

const deviceId = "17eb6e87-54b8-4bfb-a7b7-93aa3fc7cc22";
let device = await Homey.devices.getDevice({id: deviceId});
let on = device.makeCapabilityInstance('onoff').value;

console.log( "onoff: " + on);

var rgb = [0, 0, 0];
if (on) {
    var hue = device.makeCapabilityInstance("light_hue").value * 360;
    var saturation = device.makeCapabilityInstance("light_saturation").value;
    var lightness = device.makeCapabilityInstance("dim").value;
    if (hue != null && saturation != null && lightness != null) {
        rgb = hslToRgb(hue, saturation, lightness);
    }
}

console.log( "RGB: " + rgb[0] + ", " + rgb[1] + ", " + rgb[2]);
fetch("<url>?id=<id>&red=" + rgb[0] + "&green=" + rgb[1] + "&blue=" + rgb[2]);

The function ‘hslToRgb’ is hidden for clarity.

This seems alright to me, so the problem seems to be in the Homey flow itself. This is confirmed by the fact that the logs (Papertrails) only show my turning the lights off.

Extra strange is my other virtual light (same sort of device, same script) works exactly opposite! It doesn’t respond when turning on, but it works fine when turning off.

I recreated both virtual devices and then both acted the same: it did trigger the flow when switching off, but not when switching on. I added a second flow with a trigger ‘device switched on’ which executes the same script. I also updated the script to accept arguments: a string to indicate the device triggering the script and the tag ‘turned on’ of that device.
Now everything works as expected.

So I guess the problem lies in the device being switched on not firing the changed-trigger. The device does have capabilities for dim and hue, maybe that is part of the issue.

I created two virtual devices (roller shutters) - one delivers values from 0-100 and another delivers 0.0 - 0.9 - where can I change the units/values into an area 0 - 100?

Use a logic card for calculation:
image

1 Like

thx @JPe4619 but any glue, why one virtual device delivers correct values and the other virtual device not? I have created both virtual devices the same way…

Create them “more” the same way, then they will work the same (remove spaces in the calculation part).

1 Like

@JPe4619

this works good but in the shutters move into the wrong direction now :wink: so I expanded a bit the calculation

thx a lot

I am happy with this app. I only miss arrow keys for my TV can you make this in the tv knobs mode ?

I really love VD and having a bunch of flows using them. The only thing i would like to have is more icons, is that possible?

2 Likes

I do not know if you have found a solution yet, but from my experience with Homeyscript I might shed some (RGB)light on the strange behaviours.

Keep in mind that Homeyscripts runs against the WEB api, and isn’t looking at the Homey directly. From my experience, device state isn’t always properly reflected immediately through the web api. When I’m in the HomeyScript editor, usually things look alright most of the time, but when I’m not, delays seem to add up, or state is at time not properly reflected for hours. Mind you, I didn’t use the same way you did, but the effect might be similar.
.
So it could be that the missing commands and reverse behaviour is that the script is often reacting on the previous state, not the one you’re triggering at the time.

I have not figured out how to force Homeyscript to fetch the actual state of any device. I solved this (a bit awkwardly) by sending the device status I need as a parameter to the Homeyscript (usually by json notation if I need more states at the same time).

Can someone explain how to map buttons within a virtual device, to trigger other stuff?

I have a Broadlink rm mini and I can make individual devices for each ir command as I understand it, but I would like to collect all the buttons under a single device. Is it possible? Or am I just stupid? :roll_eyes:

I’ve tried using amplifier as VD but in the flows I don’t understand how I can “map” the volume up/down etc in the VD (other then “when a button is pressed”, but what button?)

No, you cannot. You can make separate virtual buttons.