Text on Dashboard tile under program control

I know that there is a Dashboard data type of "Text". I am able to create a tile of type Text and I am able to type text into it.

I want to know how to inject text into my text tile under program control. Example: it would be nice if there were a device type "Text" that I could create and then be able to manipulate it.

My use case is that I want to be able to change the text in the tile under program control. Right now I have an Alexa command that runs a Webcore piston:

Alexa, give me a security report.

Answer:
Both Scott & Kat are home and the alarm is armed home-stay.
You last both left the house on 9/16 at 2:05PM and were gone for 3 hrs and 40 minutes.

My goal is to be able to format that answer data into a Hubitat dashboard Tile.

Does anyone have any ideas?

What you want sounds like it can be done with the "Attribute" tile, which lets you use any custom (or stock) attribute and display its value on that Dashboard tile. If you choose a string attribute that you're capable of manipulating from an app/rule/piston, then that should work. A Virtual Omni Sensor device has a "variable" attribute you can set to whatever you want, which would work if no other device you already have seems more appropriate for this, but that's just one a few options you can probably find (an RM string global variable connector would be another, even if you don't use RM for anything else).

3 Likes

You can create a device that has the attribute "message" or whatever. In Dashboard, create the tile with the device and the tile type "attribute" then select the attribute. See below for example tile:

image

Aww ok. I see how I can create a tile of type "attribute". I need a device type I can create of type "Text". The "Omni" sensor had about 15 different fields, but none of them for free form text. I literally want to format and display two or three lines of text as shown in my example. If I could create a device of type "Text", ideally it would have three fields named line 1, line 2 and line 3.

Then, I would want to create a tile, of type Attribute which uses my "text" device created above and formats the three lines into the tile. I would use webcore to set the data in the line 1, line 2 and line 3 fields of my device.

Maybe even a tile that would simply display the contents of a global variable. I looked at the Virtual Omni Sensor and the RM String global variable connector and created devices of both those types. Neither seems to have a free form text field that I can store data into. It's hard to believe that no one ever thought of displaying text into a tile under program control.

You can put whatever text you want into the string variable or the "variable" attribute of the ominsensor (use the setVariable() command for the lattter). I'm not sure why that wouldn't work, but maybe I don't understand your goal. If you are looking to combine multiple things from various sources into one attribute, your webCoRE piston should be able to do that and then set the text of this attribute tile appropriately. For Dashboard use, you will need HTML to get whatever formatting (including line breaks) you want, like <br>, and the length will need to remain under the Dashboard limit of 1024 characters (for the entire attribute value, not just "visible" characters after rendering). At least two community-created apps exist to help with this (SuperTile and Tile Master), but since you're already using webCoRE, you should also be able to do this work there.

I created a device named "test" with a type of "Virtual Omni Sensor". I exposed "test" to Webcore. I created a tile on one of my dashboaards with for device test with the type "attribute". In Webcore, I can see all of the fields you would expect in a virtual sensor.

I made a webcore call to set piston tile text call. It completed with good status. In the webcore dashboard, I see all the attributes of an omni sensor. None of them are "text" or any field like that. I see no way to make the dashboard display the text I set for the tile from webcore.

Maybe I should just build a website outside of HE and put the data there. Putting text in a tile seems to be outside the functionality of the Hubitat dashboard unless you create a text tile and type it in manually.

The attribute on the omnisensor is literally called variable, and it the command to set it is a custom command, setVariable(). However, I just tried this in a test webCoRE piston, and it seems like webCoRE wants to treat the setVariable() command as something special, perhaps confusing it with the built-in/location "Set variable..." command webCoRE offers. It should just allow you to pass a string, but this fails for me because webCoRE wants to pass two arguments (it wants to make you choose a variable, which should not be necessary).

Rule Machine or a custom app could handle this for sure, but your idea of doing this outside HE entirely would also work. This seems like an oddity in webCoRE, though:

image

I failed to mention that I got to that point also. If you define the tile for your TEST Virtual Omni Sensor and put it in a dashboard, you will also see there is no option to select a field called varaiable. I called my TEST Omni Sensor "SecurityStatusTile". When I go into that device and look at the fields, here is what I see.


You will note that there is no field named "variable" for the device which is also why webcore does not give you access to this field. Are you certain that "Virtual Omni Sensor" has a freeform text field?

Maybe I should simplify my question. I have three Webcore Global variables that have text values in them. I want to display them in a tile on a Hubitat dashboard. Am I making this too hard?

The variable attribute, apparently, does not appear until you run the "Set Variable" command once to provide it with a value. After that, however, you should see it. Adding it to Dashboard with the "Attribute" template should then work and allow you to choose the "variable" attribute. WebCoRE shouldn't need "access to the field" since it doesn't know the command ("Set Variable") and attribute (variable) are associated; all it needs to know to set the value is that the command exists, which seems to be failing in my tests, again likely because it's confusing it with a built-in webCoRE command of the same name, an unfortunate coincidence.

Unfortunately, RM global variable connectors also get set via a "Set Value" command, so they will likely run unto the same problem in webCoRE (I did not test this scenario but assume it's the same). [EDIT: this problem has since been fixed in webCoRE, and the custom command should work fine now.]

Someone who actually uses webCoRE for real automations might need to speak up regarding this. I can play around and see if I can figure anything out, but my guess is there isn't an easy way. (I only have webCoRE installed on my test hub for when questions come up about it. :slight_smile: )

A custom device with a custom (or stock) attribute that just happens to use a different command name to set the value would probably work--someone would just have to write one.

1 Like

I did the "set variable" command in the Webcore piston. I wasn't sure what to set because you have to choose "with some device" do "set variable". So, the device is the "virtual Omni Sensor". I set a local variable called "test" to a text string. Seems odd, but ok. After returning to the dashboard, I add a tile for my device called "SecurityStatusTile" (virtual Omni Sensor device). I set the tile type to be "attribute". My "pick an attribute pulldown is as follows":


So, from what you said, if I understand, is that the pulldown should have had an attribute literally named "attribute". As you can see, it does not. I did run the piston to initiate our setting as you indicated.

By the way, kudos on having a "test hub". I have tons of resources on my net but a spare hub is not one of them.

No, it would be named variable. I don't see that there, possibly because your Virtual Omni device doesn't have a value set (this is a bit odd, but setting a value manually yourself using the "Set Variable" command from the device page should work). Everything else looks good there, including the choice of the "Attribute" template.

However, I still think this is going to get in the way:

Again, I think webCoRE is confusing the device's own "setVariable" command with webCoRE's own built-in "Set Variable" command. There might be a fix that webCoRE might be able to do (@nh.schottfam?) to let devices with their own "setVariable" commands work, otherwise a custom driver that uses a different name might work. It shouldn't ask you to choose a variable here, only a device, so the oddity that you notice is, indeed, odd. :slight_smile:

1 Like

Aww, so we are getting closer. I discovered as you said, that I could go into editing the device and then I set the "setVariable" attribute to a value. Once I had done that, the dashboard attribute named "variable" showed up and upon setting it I could see the text in the dashboard tile that I edited in. So, my next challenge is to get a test piston working. My device is called "SecurityStatusTile". So, here is my test piston:


So, in Webcore, I used the "Restore Attributes" directive because normally you can only set the value of a variable based on a device. Normally the devices are readonly and do not allow setting in reverse. However, a virtual device may be different. So my virtual Omni Sensor, I restored the expression you see in the example back into SecurityStatusTile:variable. This should work, but I am not seeing the value set upon force executing the piston which at this point has no conditions, so I force it to run on demand.

Can someone point me to the device that has the command setVariable?

I'm not sure that restore command would work if you did not previously do a saveStateLocally command (ie loadStateLocally is an undo of previous save state).

webCoRE does have rules that is a virtual command and device (hasCommand()) are both present, it sets precedent to virtual command.

A quick fix is on the device handler to make the setVariable command to have a setVar command, as this would not match and cause the precedent rules to kick in. (any duplicate the command to another spelling...

I would like to see the device involved.

They're using the Virtual Omni Sensor

@nh.schottfam virtual omni sensor has the setVariable string field attribute.

so is the only reason to use this device is to be able to set an attribute to a string?

If so, we should just write another virtual device to do just that

My understanding is that it was driver that they knew had a text field available. I special driver would probably work best.

The end goal is to be able to set the text in a Hubitat Dashboard tile to the value of a string that changes in reaction to various states. In my example, for security, I want a tile that says, "The last time everyone left was August 15, at 4:05PM and you were gone for 90 minutes". I have a piston that tracks this info in global variables and can announce this today using Alexa. I wanted to have the same information presented in a dashboard tile.

Yes, and I agree. :slight_smile: I was trying to start simple by suggesting to the OP something that already exists. Unfortunately, both of those options have a command we need that happens to be named setVariable: a RM string GV connector or the Virtual Omni device.

I can throw something together if no one gets there before me.