ArjanKranenburg / virtual-devices

Homey-app to add Virtual Devices that can trigger your flows.
Other
25 stars 17 forks source link

How to use virtual motion sensor? #61

Closed igitlin closed 6 years ago

igitlin commented 6 years ago

I try to use motion sensor but doesn't work flow if open contact sensor ( door) then virt motion sensor is true

MP-ICT-Diensten commented 6 years ago

And then with Heimdall support please, like this: https://forum.athom.com/discussion/comment/74831/#Comment_74831

daneedk commented 6 years ago

Replacing

https://github.com/ArjanKranenburg/virtual-devices/blob/12451f002ad89408d1f7c93f45fbb4ce22b4f8e1/drivers/virtual_switch/driver.js#L54-L58

with

if( isNaN(value) ) {
  var boolValue = value.toLowerCase() == 'true' ? true : false;
  this.log(device.getName() + ' -> Value:  ' + boolValue); 
  device.setCapabilityValue(sensor, boolValue) // Fire and forget
    .catch(this.error);
} else {
  this.log(device.getName() + ' -> Value:  ' + parseFloat(value, 10));
  device.setCapabilityValue(sensor, parseFloat(value, 10)) // Fire and forget
    .catch(this.error);
}

Will make setting alarm_motion to true or false work.

image

Numbers for other capabilities will work as it was, I did not check if there are other possible values then boolean or numeric for other capabilities, just looked at alarm_motion.

ArjanKranenburg commented 6 years ago

This is now released in the beta-channel with version 0.7.4

MP-ICT-Diensten commented 6 years ago

I installed the Beta and now it works.

I made an test button (trigger) and when pressed VirtPir is True and after 10 seconds switched back to False.

2018-09-11_20-17-37

2018-09-11_20-18-00

ArjanKranenburg commented 6 years ago

And now as stable