Originally posted by Ltek
View Post
Announcement
Collapse
No announcement yet.
vDevice state based on states from multiple devices - easier way?
Collapse
X
-
Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.548, NUC i3
HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti
-
Originally posted by Monk View PostSO - my value for
hs.DeviceValueByName(devw)
must be something other than 100 or 255.
It runs and changes my virtual device to off because the Motions_count always states 0 in the log regardless of the state of the motion sensor device being off or on.
OK - I see I'm missing something - in testing I was manually triggering the event.
This might be to advanced for me
dim array_motion() as string = {"Hall Motion Sensor","Front door motion sensor","Garage Motion Sensor"}
in the command
for each devw as string in array_motion
so the first time it runs devw = Hall Motion Sensor which then gets the status of the Hall Motion Sensor, next loop Hall Motion Sensor and so on. So if you have more motion sensors or add mor at a later stage you just add them to the array
and Hall Motion Sensor,Front door motion sensor,Garage Motion Sensor are just the names of my motion sensor devices. Its not the root deice, see below
Hope that makes sense
Comment
-
Originally posted by mikee123 View Postdevw is set to a string from the
dim array_motion() as string = {"Hall Motion Sensor","Front door motion sensor","Garage Motion Sensor"}
in the command
for each devw as string in array_motion
so the first time it runs devw = Hall Motion Sensor which then gets the status of the Hall Motion Sensor, next loop Hall Motion Sensor and so on. So if you have more motion sensors or add mor at a later stage you just add them to the array
and Hall Motion Sensor,Front door motion sensor,Garage Motion Sensor are just the names of my motion sensor devices. Its not the root deice, see below
Hope that makes sense
The motion sensors I monitor do not have a value of 100. Like a virtual device or other device might have to indicate they are on.
so within here:
for each devw as string in array_motion
if hs.DeviceValueByName(devw) = 255 or hs.DeviceValueByName(devw) = 100 then
motions_count = motions_count + 1
motion_name = devw
wstr = wstr & motion_name & " <span style='color:red'>MOTION</span>" & "<br>"
Else If hs.DeviceValueByName(devw) = 0 then
end if
When it gets to:
motions_count = motions_count + 1
mine never increments.
here is what I have for my motion devices
dim array_motion() as string = {"Motion 2 BSMT","Motion 3 BSMT","Motion Stairs"}
So here are what my device info looks like and I think the "advanced tab" where it shows "supports status" might be the answer why - ?
Thanks so much for your time!
Comment
-
Originally posted by Uncle Michael View PostWhile I agree with you on a script being more efficient for something like this, I'm nonetheless reminded of the book by Richard Carlson, "Don't Sweat the Small Stuff... and It's All Small Stuff." I find the a great deal of what I want HS to do is very easily done without scripts. (I'd say about 75% of the tasks in my HS installation are accomplished with script-less events.)
https://en.wikipedia.org/wiki/Systemantics
Comment
-
Originally posted by vasrc View Post
And also sometimes fun -
https://en.wikipedia.org/wiki/Rube_Goldberg_machine
Comment
-
Originally posted by Monk View PostIts a good way for me to learn things. And also sometimes fun
Sometimes the trip is more important than the destination. Or, as Tom Brokaw observed, "What we learn is more important that what we set out to do."Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.548, NUC i3
HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti
Comment
-
If violated is motion in your case, you would have to change 100 or 255 to 3. If all your motion sensors show violated, and on the status page that is represented by 3, then you are there. I was going to suggest to look in the status page of the device what value you have for motion. Then just replace 100 or 255 by that number.
If it was for example trouble or violated, change 100 or 255 to 2 or 3
Comment
-
Greetings!
Giving this another try - problem that I didn't have before is the HS warning when I run it:
VB.Net script exception(0), re-starting: Object reference not set to an instance of an object.
Here is what I run:
Code:dim array_motion() as string = {"Hall Motion Sensor","Front door motion sensor","Garage Motion Sensor"} dim motions_count as integer = 0 dim motion_name as string = "" dim wstr as string = "" sub motion(ByVal Parms as Object) Try motions_count = 0 motion_name = "" wstr = "" for each devw as string in array_motion if hs.DeviceValueByName(devw) = 255 or hs.DeviceValueByName(devw) = 100 then motions_count = motions_count + 1 motion_name = devw wstr = wstr & motion_name & " <span style='color:red'>MOTION</span>" & "<br>" Else If hs.DeviceValueByName(devw) = 0 then end if next If motions_count > 0 then hs.SetDeviceValueByRef(2136,100,true) hs.SetDeviceString(2136, wstr,true) Else hs.SetDeviceValueByRef(2136,0,true) hs.SetDeviceString(2136, "No Motion",true) End If hs.writelog("Array", "Motion Sensor Count: " & motions_count) Catch ex As Exception hs.WriteLog ("Array", "Error: " & ex.Message) End Try End Sub
Comment
-
@monk
I built a script for this a year ago. Have you seen it? Search for Composite Device Status, in script library.
It's super easy to use and pretty flexible. You don't need to call out every device, it uses devices naming (rooms, name, etc) structure and exclusions (optional)
Simular to Tags plugin - which is more extensive. but my script is free so if you don't need more, it should save you time and money
- Likes 2
Comment
-
Thanks all. Especially those who saw the error of my ways!
Note to self -
There are two things I did not realize which kept me from success here.
1 - I was not calling the function "motion" from the event I was using to run the script. I had entered in in the "Parameters" section - NOT the "Sub or Function" section where it should have been. This allowed the script to run, but brought me back to my original problem.
2 - Originally I was not getting any data from the devices. This was because I was using only the device name. DeviceValueByName requires the location be provided as well.
So - when I added the "Location" to the device name all was good
Comment
Comment