Make a custom device type with custom states

Posted on
Wed Jun 20, 2018 1:48 pm
mundmc offline
User avatar
Posts: 550
Joined: Sep 14, 2012

Make a custom device type with custom states

I don’t believe virtual devices allow for this yet.

Use case: I track occupancy with pibeacon, fingscan, and unifi plugins. I may add more methods for redundancy. This yields 3 variables for each house occupant (5 of us).

I want devices for each person with custom states (e.g. pibeacon up/down/expired, last seen, last home, etc). In my more industrious moments, I want to automate adding new devices for baby-sitters, regular guests, etc..

Do I need to bite the bullet and learn how to write the plugin? I love to code, but I am most definitely not a software developer.


Sent from my iPhone using Tapatalk

Posted on
Wed Jun 20, 2018 4:47 pm
Different Computers offline
User avatar
Posts: 1906
Joined: Jan 02, 2016
Location: East Coast

Re: Make a custom device type with custom states

Maybe I'm missing some feature of what you want, but if you create a virtual device group of virtual devices that each follow a variable, and have that group be "on when any device is on" wouldn't that do it?

Never tried to nest virtual devices myself.

SmartThings refugee, so happy to be on Indigo. 10.13.6 on an i5 MBP w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKit Bridge, MatplotLib, Plex, uniFAP, Wunderground, Nanoleaf, LED Simple Effects, Airfoil Pro, Grafana.

Posted on
Wed Jun 20, 2018 4:55 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Make a custom device type with custom states

In my ongoing development of Device Extensions that I intend to grant public access to as an official update, I have added a custom sensor for doing miscellaneous stuff that's very similar to what you want. I suppose it wouldn't be difficult for me to simply add a few extra states to a new version of the sensor that is tailored for this kind of thing. I mean, it's already there and fully functional and adding a half dozen states is just adding a half dozen lines to the device def.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 20, 2018 8:05 pm
DaveL17 offline
User avatar
Posts: 4997
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Make a custom device type with custom states

Do it! I double dog dare you. :D

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Jun 20, 2018 8:41 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Make a custom device type with custom states

DaveL17 wrote:
Do it! I double dog dare you. :D

LOL

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 20, 2018 9:35 pm
mundmc offline
User avatar
Posts: 550
Joined: Sep 14, 2012

Make a custom device type with custom states

You all rule.

Different Computers- based on reading many of your posts over the past year or two, you seem to have a remarkable ability engineering existing plugins to do what you want them to do. I’ll try this and be embarrassed if it works (because it had not yet occurred to me).

C4W- big fan and gracious offer. I think, if above doesn’t work, it might be time for me to learn how to play with other people’s code (not just their API’s) and finally try a plug-in.

Dave- big fan, new icon for you, always appreciate egging somebody on.

My full use case:
1) somebody I know (probably an in-law), joins my gust wifi (a unifi ap) for the first time
2) Pushover sends me a control page with the device name, asking for a confirmation and a free text to name a new device, representing that person
3) A new device is created with their name, and a state for their wifi mac address, a state for their unifi connection, and a state for their fing connection
4) I can enable or disable a state that contains their coveted XY Findit beacon UUID

It’s all probably overkill, but it’s kinda how my Indigo has been working for some time. Heck, I used to run a PHP script to grab my lat and lon from iCloud in xml, then did some fun trigonometry to estimate my distance from home and put it into indigo (circa 2012). Anything is simpler than that.


Sent from my iPhone using Tapatalk after drinking too much

Posted on
Thu Jun 21, 2018 6:50 am
Different Computers offline
User avatar
Posts: 1906
Joined: Jan 02, 2016
Location: East Coast

Re: Make a custom device type with custom states

Hey thanks!

Not sure what I do is remarkable, but the compliment is appreciated. In my mind it's more "Hey, I have no idea how to program in Python, so how can I make it work with the tools that exist?"

But that ability to use Indigo's flexibility to solve a problem in multiple ways is one of its great strengths. Of course it's also a challenge to new users--look at my first couple of posts when I was trial-ing the software and I was fumbling around attempting to understand best practices for what was properly a device, what was a variable, and what was an Action Group.

SmartThings refugee, so happy to be on Indigo. 10.13.6 on an i5 MBP w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKit Bridge, MatplotLib, Plex, uniFAP, Wunderground, Nanoleaf, LED Simple Effects, Airfoil Pro, Grafana.

Posted on
Thu Jun 21, 2018 3:51 pm
mundmc offline
User avatar
Posts: 550
Joined: Sep 14, 2012

Re: Make a custom device type with custom states

Different Computers wrote:
Of course it's also a challenge to new users--look at my first couple of posts when I was trial-ing the software and I was fumbling around attempting to understand best practices for what was properly a device, what was a variable, and what was an Action Group.


I’ve read them- you’ve come far grasshopper!


Sent from my iPhone using Tapatalk

Posted on
Tue Jul 03, 2018 9:30 am
mundmc offline
User avatar
Posts: 550
Joined: Sep 14, 2012

Re: Make a custom device type with custom states

Different Computers wrote:
Maybe I'm missing some feature of what you want, but if you create a virtual device group of virtual devices that each follow a variable, and have that group be "on when any device is on" wouldn't that do it?

Never tried to nest virtual devices myself.


The nesting didn’t allow me to choose a virtual on/off as a member of another virtual on/off, good idea though.

Ultimately, I want to simplify tracking presence, and have a device where I can link DIRECTLY to data that determines it’s state. Main reason is it is crazy-making to replace somebody’s phone or beacon and to have this accurately reflected in Indigo

For example, I have a trigger script that 1) runs whenever the variable value (taken from device state and made boolean) changes for pibeacon/unifi/fing. 2) It checks every other variable value for that person to see if all of the variables are false. 3) If all three are false, it updates a variable for that person, to say whether they are near or not. 4) If somebody leaves/ returns, an “ocupants” variable is decremented/ incremented. 5) If “occupants” = 0, the house shuts down and security turns up.

All the above could be much easier with a device with user-definable states for each device state that occupant is associated with.

Also, it could allow for rapid creation of new devices for trusted occupants, and custom house states (e.g. the baby sitter is there, so leave the indoor cams on).


Sent from my iPhone using Tapatalk

Posted on
Fri Jul 06, 2018 11:37 am
mundmc offline
User avatar
Posts: 550
Joined: Sep 14, 2012

Make a custom device type with custom states

Different Computers wrote:
Maybe I'm missing some feature of what you want, but if you create a virtual device group of virtual devices that each follow a variable, and have that group be "on when any device is on" wouldn't that do it?

Never tried to nest virtual devices myself.


A-ha! Apparently they don’t nest by design! Include a virtual on/off device within a virtual group devic
https://r.tapatalk.com/shareLink?share_ ... are_type=t


Sent from my iPhone using Tapatalk

Posted on
Mon Jul 09, 2018 9:58 am
kw123 offline
User avatar
Posts: 6567
Joined: May 12, 2013
Location: Dallas, TX

Re: Make a custom device type with custom states

Fingscan events can be setup to have an AND of
X fingscan devices
Y UniFi devices
Z pibeacon devices

All home would be all device up
All away would be all devices down
One home is at least one home
One away at least one away





Sent from my iPhone using Tapatalk

Posted on
Mon Jul 09, 2018 11:08 am
mundmc offline
User avatar
Posts: 550
Joined: Sep 14, 2012

Re: Make a custom device type with custom states

Hey Karl!
I contemplated this. While I have no doubt it would work, my main difficulty is adding new people and/or replacing current phones with new phones.

Right now, I am using your plugins to id new people:
1) get new fing device info
2) get new unifi device info (same MAC address)
3) move devices to a new folder and name according to the name attribute from unifi
4) manually sort out occupants, guests, family, etc

Next step is to Pushover a control page to my phone for new devices, assigning names and essentially security clearance.

I know this can be scripted with Events, but it gets unwieldy for me!


Sent from my iPhone using Tapatalk

Posted on
Mon Jul 09, 2018 12:01 pm
kw123 offline
User avatar
Posts: 6567
Joined: May 12, 2013
Location: Dallas, TX

Re: Make a custom device type with custom states

Fingscan Events can not handle new devices. When setting up an event the devices have to exist.

But I see your isssue. Will think about it.





Sent from my iPhone using Tapatalk

Posted on
Tue Jul 24, 2018 8:59 pm
mundmc offline
User avatar
Posts: 550
Joined: Sep 14, 2012

Re: Make a custom device type with custom states

Just a follow up on this post...

1) As stated, virtual devices cannot contain other virtual devices, per Matt and Jay for debugging/ stability/ possibly-super-secret-clearance reasons
2) I flirted with making my own plugin for custom devices BUT...
3) Using FlyingDiver's plugin "Masquerade" (lets you make custom devices that act as wrappers for other devices), I made new MASQUERADE devices (totally, honest-to-god, not-legally-virtual devices), which can now be used as on/off states for a VIRTUAL DEVICE

The longer part and explanation:
I manage occupancy using Karl's plugions fingsan, unifi, and pibeacon. I have two rasbpi's with pibeacon images running on them, and the aforementioned plugins. This gives me excellent occupancy detection, and redundancy for thing like: dead cell phones, dead Bluetooth beacons (worn on keychains).

Whenever I have a new trusted person for the house, I need a way for Indigo to know when they are home or not. A practical example: My sister-in-law was caring for our children, and the three adult members of the household were out. I over-road Indigo so it didn't shut everything off (as it would if the adult occupants were gone), but I needed a quick in easy way to have Indigo identify my sister-in-law (or her phone, in this case), as a known, trusted person.

The amount of code and device/ trigger/ variable creation involved in adding a new "person" was laborious, hence the desire to quick-add a "person" device.
Long story short:
"Person" device = a virtual device group, where the group contains Masquerade devices for OTHER relevant plugins that monitor for occupancy. If ANY are on, then that "person" is on (home).

Now, I can define new "Person" virtual devices that monitor relevant variables/ device states. Adding a new person is easier. Replacing new phones or beacons is WAY easier.
Last edited by mundmc on Wed Jul 25, 2018 4:47 pm, edited 1 time in total.

Posted on
Wed Jul 25, 2018 4:30 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Make a custom device type with custom states

mundmc wrote:
Using Colorado 4-Wheeler's plugin "Masquerade"

Mine is Device Extensions, Flying Diver wrote Masquerade.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Who is online

Users browsing this forum: No registered users and 1 guest