more G-Labs products

Author Topic: Motion sensors need device type, widget, .Each() support?  (Read 1074 times)

January 18, 2016, 04:54:41 PM
Read 1074 times

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330

Working on a widget to summarize my sensors and I can't seem to get ".Each" to work for them:
Code: [Select]

Modules.OfDeviceType("Sensor.MotionDetect").Each( (module) => {

I have had other "consistency" problems with motion sensors (as compared to door sensors).  I have tried other variations of "Motion", "MotionDetect" with no luck.  By contrast, these work for doors and lights:
Code: [Select]


Modules.OfDeviceType("DoorWindow").Each( (module) => { 


Modules.OfDeviceType("Light,Dimmer,Switch").Each( (module) => {


Do we need a device type just for MotionDetect rather than having it be subordinate(?) to Sensors?  Also for the widget if there was a standalone type and widget, then we could use Status.Level=1 for indicating motion.  Currently I set Sensor.MotionDetect=1 to indicate motion in my arduino modules.
Code: [Select]


Program.RaiseEvent(module4, "Sensor.MotionDetect", motion.ToString(), "Garage Motion");
This seeems to be different than how zwave motion sensors indicate motion (Status.level).

Attached shows my zwave vs. arduino motion sensor widgets.

Also shows my new Summary widget so I can remove the individual sensor widgets from the dashboard and have all condensed into one.
« Last Edit: January 18, 2016, 07:04:49 PM by kevin1 »

January 18, 2016, 07:31:21 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I have several X10 motion sensors and one connected to the RPi GPIO.  The X10 sensors act like any other X10 module and only provide a Status.Level parameter.  The GPIO sensor is set the same way (GPIO Status.Level).  I suppose I could have some code somewhere duplicate this to the Sensor.MotionDetect parameter, but I never saw the need.  It would be better to do that way for consistency if other systems were being used though.  I'm not sure if it would help having a Motion subtype of Sensors so that status.level was set at motiondetect or if that would just complicate things.

January 18, 2016, 08:21:41 PM
Reply #2

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
For your GPIO motion sensor, how is it configured (a program just for it)?  And a generic sensor widget?

My zwave seems to behave like your x10 motion which makes sense (I think, neither are virtual modules).  I guess I'm just wondering if I did my arduino motion sensor correct by using Sensor.MotionDetect=1 (should be similar implementation to your GPIO).  If I were to just use status.level=1, there would be no way to indicate that the widget is motion sensor from how I understand it.

Hence I'd like some more specific widgets, like icons to show motion/no motion, widget with garage door icons.  Need to play around with the widget editor sometime I guess.

Thanks!

January 18, 2016, 11:06:51 PM
Reply #3

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
The only way to know that a sensor is a motion sensor is by the name.  Otherwise, it is simply a device that toggles on/off like any other switch without the ability to set the state from the interface.  There are some multi-sensors that are available and I believe they must support the motion.detect parameter.  I believe Gene had one of those in mind with his Smart Lights APP since it uses motion.detect and luminescence.  From memory, the Aeon Labs sensor has 5 or 6 types that it reports (light level, motion, temperature, etc.).

My GPIO based motion sensor is a custom unit that I originally built to use X10.  I have a Heath-Zenith 120VAC sensor that triggers on motion.  It triggers a relay that is connected to the GPIO header.  Internally to HG, I simply use the RPi GPIO APP to configure the module which links it to a GPIO virtual module.