New Plugin: Cynical Behaviors

Posted on
Wed Mar 30, 2016 7:20 am
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: New Plugin: Cynical Behaviors

Hi Perry - I started testing with your Behaviors Plug-in - I have had success with the Keypad Buttons functions and I'm starting to use the Battery Monitor capability now.

I can change the threshold value and watch the list of LOW devices populate and I can trigger an email on any change to that value but I don't understand how to get the list of devices into an email.

I'm not sure it is possible with the organic Indigo email but I also tried Better Email and I'm not having any luck understanding what needs to go in the message field to get the list emailed to me.

Everything I have tried does not work. Can you let me know how you process the information (BTW, I'm still learning Indigo so don't assume too much). I have a complex system of checks set up to monitor my leak detectors but I wanted to understand how your plug-in works before I dismantle that and simplify it with your Leak check routine.

Also do you have a list of devices that are being monitored by both the battery routine and leak routine?

Thanks in advance for any help with this - Indigo is the bedrock of my HA setup but the plug-ins (like yours) are what really make it fun and rewarding :)

_______
Norm

Posted on
Wed Mar 30, 2016 9:11 am
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: New Plugin: Cynical Behaviors

Londonmark wrote:
Perry The Cynic wrote:

What plugin and device type specifically is this?

Cheers
-- perry


The plugin is RFXCOM and the device type is LightwaveRF switch.

From looking at the LightWave Switch device in the RFXCOM plugin, this is a custom device, not a sensor. That is why it doesn't "fit" that position. I suggest you talk to the maintainer of the RFXCOM plugin about the best way to deal with that. Feel free to invite him or her to post on this forum (in a separate thread) or send me email.

Cheers
-- perry

Posted on
Wed Mar 30, 2016 9:59 am
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: New Plugin: Cynical Behaviors

norcoscia wrote:
Hi Perry - I started testing with your Behaviors Plug-in - I have had success with the Keypad Buttons functions and I'm starting to use the Battery Monitor capability now.

I can change the threshold value and watch the list of LOW devices populate and I can trigger an email on any change to that value but I don't understand how to get the list of devices into an email.

First of all, make sure you can send email at all from Indigo. Test that independently until you see it work (i.e. you're receiving actual email with a test message). If you have trouble with that, consult the fine Indigo crew (for the built-in email sending) or the plugin maintainer for your email plugin. I'm using the built-in email sender because it does all I need it to.

There are many ways to pull the values out of the device state. Here's how I do this for myself, which is pretty simple. I have a trigger, on changes to the Active Leaks state of the leak monitor device (or whatever it is we're monitoring), with a condition of "that state isn't empty" (to deal with the last leak disappearing). The action is a Python script:
Code: Select all
monitor=indigo.devices["Your device name or id"]
recipient="redacted@redacted.com"
subject="LEAKS DETECTED"
body="Leaks have been detected in the house: " + monitor.states["wet"]
indigo.server.sendEmailTo(recipient, subject=subject, body=body)
That could be made much prettier, but it's serviceable (and when my house springs a leak, I probably don't care too much about the refined presentation :-)). This email goes out immediately when a leak appears, and then repeatedly as the state string changes (it contains a "3 hours ago" clause which provides convenient spacing of messages on its own, if you're not picky. If you use a "changed to not empty" trigger instead, it will only send a single email upon the first leak. And so forth.)

For the less-important things, I have a nightly schedule that collects maintenance advisories like this:
Code: Select all
recipient = "redacted@redacted.com"
subject = "Indigo maintenance reminders"

leaks=indigo.devices["leak monitor device name"]
battery=indigo.devices["battery monitor device name"]

message=""

wet_sensors=leaks.states["wet"]
if wet_sensors:
   message += "Leak sensors that are WET: " + wet_sensors + "\n"
overdue_sensors=leaks.states["overdue"]
if overdue_sensors:
   message += "Leak sensors that are not responding: " + overdue_sensors + "\n"

low_battery = battery.states["low"]
if low_battery:
   message += "Devices with low batteries: " + low_battery + "\n"

if message:
   indigo.server.sendEmailTo(recipient, subject=subject, body=message)
Again, there are many variations on this theme. Note that this only sends an email if there's something to report.
Also do you have a list of devices that are being monitored by both the battery routine and leak routine?

Battery Watch watches all devices for which Indigo reports a battery level at all. (Technically, for which the battery level is not None.) Leak Watch watches all INSTEON Leak Sensor devices in your Indigo database (and only those, at the moment).

Cheers
-- perry

Posted on
Wed Mar 30, 2016 11:09 am
roquej offline
User avatar
Posts: 608
Joined: Jan 04, 2015
Location: South Florida, USA

Re: New Plugin: Cynical Behaviors

Perry,

I assume the problem with the ad2usb plugin (Berkinet's version) is the same as for the RFXCOM - the devices are defined as custom and not as indigo sensors. Will follow your advice and suggest Berkinet joins this discussion. Alarm sensors are much more reliable than either z-wave or INSTEON sensors. It would be a shame not to be able to use them with your plugin.

JP

Posted on
Wed Mar 30, 2016 11:25 am
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: New Plugin: Cynical Behaviors

Thanks Perry, that was what I was looking for, I got the message w/ info working via normal Indigo email - looks like I'll need to learn some Python to really make Indigo work for me :D

_______
Norm

Posted on
Wed Mar 30, 2016 11:53 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Plugin: Cynical Behaviors

roque wrote:
...I assume the problem with the ad2usb plugin (Berkinet's version) is the same as for the RFXCOM - the devices are defined as custom and not as indigo sensors. Will follow your advice and suggest Berkinet joins this discussion. ...

If the Cynical Behaviors plugin is filtering its list of usable devices to certain device types (like Sensors) then it would not see a Custom device. If that is the case, the issue noted by @rogue could be fixed in two ways: Custom devices could be re-defined as Sensors in their respective plugins, or, the Cynical Behaviors plugin could perform a lower level test to see if a Custom device were usable.

In the first case, I am not sure it makes sense to use a specific device type in a plugin just for the purpose of creating readability in another plugin. The Sensor device has it's own set of implied semantics, like assuming the physical device does not maintain state, and it also has custom UI elements. In the ad2usb plugin, and I'd imagine any other alarm plugin, the physical "device" is, because of the nature of alarm systems, a Zone. A Zone can consist of one or more physical inputs. Thus, a Zone named "Living Room" might have multiple inputs: door sensors, glass break sensors, motion sensors, etc. Each Zone has two simple states: normal (closed, ready to arm, etc) and faulted. It is by it's nature binary. To try to map such a fluid concept as a Zone to a "sensor" device is bound to create problems. Like, for example, assuming that all alarm inputs were stateless, while door and window sensors are usually stateful.

On the other hand, I would think a plugin like the Cynical Behaviors plugin could look to see if a given device supported some usable state to use for it's own purposes. In the case of the ad2usb Zone device, onOffState is supported and should provide the necessary state change to use as an input trigger. In this case, a plugin writer would need only assure that their devices supported onOffState.

Making the coding change in the Cynical Behaviors plugin (if it can be done) would also make a lot of sense since it would be much less work to change one plugin than several.

Just my 2¢ worth.

Posted on
Wed Mar 30, 2016 1:17 pm
JohnS offline
Posts: 25
Joined: Mar 26, 2014

Re: New Plugin: Cynical Behaviors

Perry,
I know you are busy answering queries on your “Cynical Behaviors” but, Is there anyway for a user of your plugin to suppress logging of the Relay Device that I use with your Blinking Relay plugin. The log fills up quickly with notifications of the Relay Device toggling between on-state and off-state. If there currently is no way, are you open to adding a setup parameter to allow this if desired by the user. I currently use a python script to do the Blinking which suppresses the logging of the Relay Device toggling, but my goal is to use plugin’s as much as possible and this one fits so nicely.
Your Leak Watch Device has simplified life for me, eliminating numerous timers and triggers and a script that was a pain to maintain as I added Leak Sensors.
I’m also awaiting your incorporation of the I/O-Linc device into your Garage Door Device to further simplify my life.

Thanks for your Cynical Behaviors,
John

Posted on
Wed Mar 30, 2016 10:27 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: New Plugin: Cynical Behaviors

Version 0.9.3 quiets the Indigo logging caused by blinking devices, well, blinking a lot. That was just an oversight.

It also enables I/O-Linc devices as both relays (Garage Door) and sensors (Garage Door and Switch Control).

I/O-Lincs are thinly tested. I dug out my one device from its box and convinced myself that it seems to work in principle, but there's a bunch of configuration options to I/O-Lincs and I sure didn't try them all. Give it a spin and let me know how it goes.

Cheers
-- perry

Posted on
Wed Mar 30, 2016 10:35 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: New Plugin: Cynical Behaviors

Hi, Berkinet! Sorry to drag you over here. :-)
berkinet wrote:
On the other hand, I would think a plugin like the Cynical Behaviors plugin could look to see if a given device supported some usable state to use for it's own purposes. In the case of the ad2usb Zone device, onOffState is supported and should provide the necessary state change to use as an input trigger. In this case, a plugin writer would need only assure that their devices supported onOffState.

I'm a big fan of using the standard device types whenever it's at all reasonable, because it allows composition of devices. For example, in my Cynical Lutron plugin, window blinds are technically dimmer devices; not because they've anything to do with light, but because that lets any user add them to virtual Device Groups and have them work. That's not to say that you shouldn't add all kinds of additional functionality to your devices - Cyncical Lutron blinds have their own custom move actions and states, but they also respond to standard dimmer controls and report standard dimmer state to integrate better with Indigo.

Consider yourself proselytized to this point of view. I think that in the long run, making standard-supporting devices that can be cleanly composed makes all our plugins work better together. :-)

Now I could change my filter to accept any device with an onOffState state, hook state change notifications, and hope for the best. It'll probably work fine with the ad2usb device. The downside is that it'll also show light switches and dimmers that really aren't meant to be sensors because they also have onOffStates, and so my users will have to scroll through this thicket of devices, most of which obviously (to them) don't make sense in a sensor slot. The sad truth is that onOffState is grossly overloaded and can mean, depending on circumstances, either sensor state or last commanded output state, with no way to tell without looking at the device type (and "custom" doesn't help here).

I'd love for Indigo to have an extensible protocol support facility. For example, an I/O-Linc could say "I'm a relay and a sensor." But in the concrete case of an alarm sensor, how is this not a sensor? Shouldn't it look and feel like one? I'm not just preaching here; the alarm sensors in Cynical Honey are, in fact, sensor devices for exactly this reason. (That's also why this was never a problem for me, though half of my zone sensors are, in fact, alarm system sensors.)

Making the coding change in the Cynical Behaviors plugin (if it can be done) would also make a lot of sense since it would be much less work to change one plugin than several.

In the short run, this may be true. But you're basically saying "any plugin should just accept all my devices and try to make the combination work." I'm pretty sure that doesn't scale without explicit support from Indigo to do the match-making. And the only match-making facility I see today is the device type and the associated behavior (command/device) promises...

Anything shiny and new coming in that area in Indigo 7? Unofficially speaking, of course? :-)

Cheers
-- perry

Posted on
Thu Mar 31, 2016 3:38 pm
JohnS offline
Posts: 25
Joined: Mar 26, 2014

Re: New Plugin: Cynical Behaviors

Perry,
I exercised version 0.9.3 of your “Cynical Behaviors” . Your Blinking Relay plugin resulted in minimum log file data. I really appreciated that change.

Furthermore, I exercised your Garage Door Device incorporating I/O-Linc devices. I have two 8 ft garage doors and one 6ft garage door for my shed. The 6ft door work right on the first try. I had trouble with the two 8ft doors. After playing with it for hours it dawned on me that the working Garage Door Device was for the smaller door. After changing the default parameters for my 8ft doors everything appears to be working just great.

Thanks you again for your Cynical Behaviors,

John

Posted on
Thu Mar 31, 2016 5:32 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: New Plugin: Cynical Behaviors

Perry The Cynic replied wrote:
...you're basically saying "any plugin should just accept all my devices and try to make the combination work." I'm pretty sure that doesn't scale without explicit support from Indigo to do the match-making. ...

Actually, I think I was saying, Be conservative in what you send and liberal in what you expect. :wink:

Posted on
Thu Mar 31, 2016 8:42 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: New Plugin: Cynical Behaviors

berkinet wrote:
Perry The Cynic replied wrote:
...you're basically saying "any plugin should just accept all my devices and try to make the combination work." I'm pretty sure that doesn't scale without explicit support from Indigo to do the match-making. ...

Actually, I think I was saying, Be conservative in what you send and liberal in what you expect. :wink:

I know; I love Jon too. :-) But even he has over the years hedged this a bit, because being indiscriminately liberal in what you accept is actually dangerous - for security and stability. Essentially, be liberal in what you accept really means be really conservative with some well-designed superset of your expectations and then work really hard to shape the deviations into something useful while being completely predictable. That is the hard part...

Cheers
-- perry

Posted on
Fri Apr 01, 2016 1:48 am
Londonmark offline
Posts: 509
Joined: Feb 29, 2012

Re: New Plugin: Cynical Behaviors

Perry - would it be possible to have a configuration setting in your plugin to include sensors only or include all devices? The default could be sensors only. That way - until other plugin developers have had a chance to update their plugins - we would be able to use your plugin?

Posted on
Mon Apr 04, 2016 12:02 am
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: New Plugin: Cynical Behaviors

Londonmark wrote:
Perry - would it be possible to have a configuration setting in your plugin to include sensors only or include all devices? The default could be sensors only. That way - until other plugin developers have had a chance to update their plugins - we would be able to use your plugin?

All right. Version 0.9.4 adds a checkbox in the plugin preferences to show "more" sensor devices. In fact, it'll show all devices with an on/off state, which is probably most of them. Sadly, there doesn't seem to be a way to filter just the sensible ones. (Well, there is, but it requires the plugin authors to declare them as sensors...)

Please keep in mind that I have no way to test or predict whether those "extra" devices will work (right) with my plugin.

Cheers
-- perry

Posted on
Mon Apr 04, 2016 12:38 am
Londonmark offline
Posts: 509
Joined: Feb 29, 2012

Re: New Plugin: Cynical Behaviors

Thanks Perry. Will give it a try.

Who is online

Users browsing this forum: No registered users and 4 guests