Page 1 of 2

Variable based virtual sensor devices

PostPosted: Fri Apr 19, 2019 10:04 am
by BonfireVA
Hello all,

I am still looking for a good, simple way to set up virtual sensor devices (temp, humidity, motion, etc) in Indigo. Currently I am using node-red to write DIY sensor values to variables in Indigo (via indigo RESTapi) , that is working very well but I would like to be able to create a virtual sensor device that has its states / values driven by these variables. Previously I tried both of the MQTT plugins in combination with the masquerade plug in, but I ran into reliability issues and that solution had to many moving parts and was cumbersome to set up new devices.

I would think the addition of variable based sensors could be a nice addition to the built in virtual device plugin!

Anyone have a good solution for adding virtual devices that are not just on/off devices?

-Eric

Re: Variable based virtual sensor devices

PostPosted: Fri Apr 19, 2019 3:41 pm
by howartp
Have you considered writing a plugin for your devices, and (if necessary) using node red to set the device states instead of the variables?

Honest question: What value do you see in having them in a device rather than variable?


Sent from my iPhone using Tapatalk Pro

Re: Variable based virtual sensor devices

PostPosted: Fri Apr 19, 2019 7:36 pm
by BonfireVA
I would love to be talented enough to write my own plugins, but sadly I am only good enough to hack together bits and pieces of things that others have already done :D

The variable approach works ok but there are some annoyances such as not having a great way to quickly see sensor status on the IOS app along with other devices (I could address this if I ever got around to setting up control pages), also I am using grafana and influxdb and there isn't consistency in how I need to query sensors that are actual devices in Indigo and ones that are only variables . Nothing earth shattering, and I can certainly kick off automations just fine based on variable changes, or in Node red before it even gets to indigo for that matter. I'ts really just one of those little annoyances, seems like every system has them.

Re: Variable based virtual sensor devices

PostPosted: Fri Apr 19, 2019 8:03 pm
by Korey
I was thinking just the same thing, I was hoping that I could have used a Virtual Device to pull values from Variables into a device, but no joy. :(

I have a bunch of stuff that I am doing with Variables, that I would love to be able to write plugins for, perhaps one day if I ever have time to breathe!

Re: Variable based virtual sensor devices

PostPosted: Fri Apr 19, 2019 10:10 pm
by mundmc
BonfireVA wrote:
I would love to be talented enough to write my own plugins, but sadly I am only good enough to hack together bits and pieces of things that others have already done :D

The variable approach works ok but there are some annoyances such as not having a great way to quickly see sensor status on the IOS app along with other devices (I could address this if I ever got around to setting up control pages), also I am using grafana and influxdb and there isn't consistency in how I need to query sensors that are actual devices in Indigo and ones that are only variables . Nothing earth shattering, and I can certainly kick off automations just fine based on variable changes, or in Node red before it even gets to indigo for that matter. I'ts really just one of those little annoyances, seems like every system has them.


I can’t echo this sentiment enough. I use a Device/Trigger/Variable/Action naming schema that approximates what a plugin can do, but my one swing at writing a plugin hit a problem that was over my head (or at least, requiring 10+ hours of reading and experimentation).

I would LOVE to have virtual devices with custom states.

Re: Variable based virtual sensor devices

PostPosted: Sat Apr 20, 2019 2:22 am
by howartp
I reckon I might have a play with a plugin for this.

Watch this space.


Sent from my iPhone using Tapatalk Pro

Re: Variable based virtual sensor devices

PostPosted: Sat Apr 20, 2019 3:44 pm
by howartp
Have a go with https://github.com/howartp84/VariableDeviceBeta/releases

Create a new device > Variable Device

Pick which variable(s) you want to monitor within that device.

Then pick which of the variables should be the displayState, ie the value that shows in the UI.

Having spent all evening on it, i've just realised that "states" aren't visible in the Indigo Touch UI which is now annoying me greatly!

However the plugin does show the chosen displayState, together with the appropriate coloured blobs as it would for other devices, and does bring variables together into a nice device within the client UI so it's not a complete waste of time.

Comments welcome.

Peter

Re: Variable based virtual sensor devices

PostPosted: Sat Apr 20, 2019 5:01 pm
by BonfireVA
howartp wrote:
Have a go with https://github.com/howartp84/VariableDeviceBeta/releases

Create a new device > Variable Device

Pick which variable(s) you want to monitor within that device.

Then pick which of the variables should be the displayState, ie the value that shows in the UI.

Having spent all evening on it, i've just realised that "states" aren't visible in the Indigo Touch UI which is now annoying me greatly!

However the plugin does show the chosen displayState, together with the appropriate coloured blobs as it would for other devices, and does bring variables together into a nice device within the client UI so it's not a complete waste of time.

Comments welcome.

Peter



Awesome! Thanks for putting in the time to help figure this out! I am tied up most of the weekend with a volleyball tournament for my daughter, but I will give this a look asap!

-Eric

Re: Variable based virtual sensor devices

PostPosted: Sat Apr 20, 2019 5:17 pm
by Korey
howartp wrote:



You Peter.. Kick Ass! would be my first comment! :) :)

Thanks for this, I'll play with it this weekend!

Re: Variable based virtual sensor devices

PostPosted: Mon Apr 22, 2019 5:57 am
by BonfireVA
howartp wrote:
Have a go with https://github.com/howartp84/VariableDeviceBeta/releases

Create a new device > Variable Device

Pick which variable(s) you want to monitor within that device.

Then pick which of the variables should be the displayState, ie the value that shows in the UI.

Having spent all evening on it, i've just realised that "states" aren't visible in the Indigo Touch UI which is now annoying me greatly!

However the plugin does show the chosen displayState, together with the appropriate coloured blobs as it would for other devices, and does bring variables together into a nice device within the client UI so it's not a complete waste of time.

Comments welcome.

Peter



Ok so I had some time to try this out, I think this gets us most of the way there. I did noticed a couple things as I played around with this.

First the devices don't have the ability to tell Indigo what device type they are (ie motion sensor, temp sensor, etc) so the display in the UI is generic, ie the motion sensor looks like an on/off switch. After adding variable devices for four sensors values (motion, temp, humidity, and lux) I then added masquerade devices for each of the variable devices to apply proper formatting in the UI, In the image you can see how the masquerade plugin applies the proper device types and they are displayed as such in the UI.

Next you will notice in the attached image, the variable device for LUX is properly displaying the current ambient light value, but for some reason the Masquerade device that is based on the variable device is displaying 0. I have no idea why as it is set up exactly the same as the other three devices. I am guessing this has more to do with the masquerade plugin than variable devices.

If it would not be to difficult to add the ability to define the type of sensor directly in the variable devices plugin (or merge the two plugins together in some way?), that would eliminate the need to create a second device using masquerade making things less complex when adding /managing these devices and they would look like natively supported zwave/insteon sensors in the UI.

Thanks again for the work on this!

-Eric

Re: Variable based virtual sensor devices

PostPosted: Wed Apr 24, 2019 10:27 am
by mundmc
This is pretty amazing, thank you, I cannot wait to play with it.

Re: Variable based virtual sensor devices

PostPosted: Wed Apr 24, 2019 4:08 pm
by howartp
Just uploaded v1.0.2 with icon types and value formatting.

Apologies that i've used an apostrophe instead of °c/°f for temperature at the moment as i'm getting a unicode error!

Re: Variable based virtual sensor devices

PostPosted: Thu Apr 25, 2019 12:27 am
by howartp

Re: Variable based virtual sensor devices

PostPosted: Thu Apr 25, 2019 3:08 am
by CliveS
howartp wrote:
Apologies that i've used an apostrophe instead of °c/°f for temperature at the moment as i'm getting a unicode error!


Peter, this sorts out the unicode error, I originally used it when I was modifying your Z-Wave Sensor logger https://forums.indigodomo.com/viewtopic.php?f=254&t=21399&p=171334#p171334

Code: Select all
degreeC       = u"\u00b0C"
degreeF       = u"\u00b0F"

dev.updateStateOnServer("displayState", str(varValue), uiValue=str(varValue) + u"\u00b0F")
or
dev.updateStateOnServer("displayState", str(varValue), uiValue=str(varValue) + degreeC)

Variable based virtual sensor devices

PostPosted: Thu Apr 25, 2019 11:54 am
by howartp
Thanks I wondered about the \u00 format.

Strange thing is, Joe’s masquerade plugin is using exactly the same line of code to format the degree sign and it doesn’t error for him. :-(


Sent from my iPhone using Tapatalk Pro