Variable based virtual sensor devices

Posted on
Fri Apr 19, 2019 10:04 am
BonfireVA offline
Posts: 62
Joined: Sep 17, 2017

Variable based virtual sensor devices

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

Posted on
Fri Apr 19, 2019 3:41 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Variable based virtual sensor devices

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

Posted on
Fri Apr 19, 2019 7:36 pm
BonfireVA offline
Posts: 62
Joined: Sep 17, 2017

Re: Variable based virtual sensor devices

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.

Posted on
Fri Apr 19, 2019 8:03 pm
Korey offline
User avatar
Posts: 813
Joined: Jun 04, 2008
Location: Henderson, NV

Re: Variable based virtual sensor devices

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!

--
Korey

Posted on
Fri Apr 19, 2019 10:10 pm
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: Variable based virtual sensor devices

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.

Posted on
Sat Apr 20, 2019 2:22 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Variable based virtual sensor devices

I reckon I might have a play with a plugin for this.

Watch this space.


Sent from my iPhone using Tapatalk Pro

Posted on
Sat Apr 20, 2019 3:44 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Variable based virtual sensor devices

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

Posted on
Sat Apr 20, 2019 5:01 pm
BonfireVA offline
Posts: 62
Joined: Sep 17, 2017

Re: Variable based virtual sensor devices

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

Posted on
Sat Apr 20, 2019 5:17 pm
Korey offline
User avatar
Posts: 813
Joined: Jun 04, 2008
Location: Henderson, NV

Re: Variable based virtual sensor devices

howartp wrote:



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

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

--
Korey

Posted on
Mon Apr 22, 2019 5:57 am
BonfireVA offline
Posts: 62
Joined: Sep 17, 2017

Re: Variable based virtual sensor devices

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
Attachments
Screen Shot 2019-04-22 at 7.32.37 AM.png
Screen Shot 2019-04-22 at 7.32.37 AM.png (115 KiB) Viewed 4439 times

Posted on
Wed Apr 24, 2019 10:27 am
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: Variable based virtual sensor devices

This is pretty amazing, thank you, I cannot wait to play with it.

Posted on
Wed Apr 24, 2019 4:08 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Variable based virtual sensor devices

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!

Posted on
Thu Apr 25, 2019 12:27 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Variable based virtual sensor devices


Posted on
Thu Apr 25, 2019 3:08 am
CliveS offline
Posts: 770
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Re: Variable based virtual sensor devices

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)

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Thu Apr 25, 2019 11:54 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Variable based virtual sensor devices

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

Who is online

Users browsing this forum: No registered users and 1 guest