Dashboard integration and control of "kid's points"

Would love to have a display and control of points we give (or take) based on behavior. I assume this can be accomplished through variables? I'm so lost on where to start!

Depends on how elaborate you want to get but you could use either a variable tile or an attribute tile with a custom device driver to store the values. Easiest way is to create a custom device with an attribute for each kid, use the device to update the values, and the attribute tile to display.

For that scenario you could use the below as the device driver (1 device per kid):

 /*
 * Point Container
 *
 *  Licensed Virtual the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */

static String version()	{  return '0.1.0'  }

metadata {
    definition (
		name: "Point Container", 
		namespace: "thebearmay", 
		author: "Jean P. May, Jr."
    ) {
        	capability "Actuator"
		
		attribute "points", "number"

		command "setPoints", [[name:"points", type:"NUMBER", description:"Enter the value to store."]]
            
    }   
}

preferences {
	input("debugEnable", "bool", title: "Enable debug logging?")
}

def installed() {
	log.trace "installed()"
    setPoints(0)
}

def updated(){
	log.trace "updated()"
	if(debugEnable) runIn(1800,logsOff)
}

def setPoints(points) {
    if(debugEnable) log.debug "setPoints $points"
    sendEvent(name:"points", value:points)
}


void logsOff(){
     device.updateSetting("debugEnable",[value:"false",type:"bool"])
}
2 Likes

I think this may do it. As soon as I get into work in a couple hours I'm going to give it a spin and report back.

That's working beautifully. Thank you so much!

Now, to allow control from the dashboard...

I'm sure there are a multitude of ways to do this but essentially here is what I am working towards:

Ideally I would love to be able to click a tile and be able to manually enter a new value right from the dashboard but I suspect that is very difficult if not mostly impossible.

I would, however be just fine with a series of predefined plus and minus tiles. When I started to look at a new device(s) to do this I only came across specific numbers to set to and not adding or subtracting from current number.

That can be done, just need to change the driver and use a different tile. Use the driver from here:

https://raw.githubusercontent.com/thebearmay/hubitat/main/dashVariable.groovy

and then use the Number Variable tile from the dashboard to interact with it.

The right tile is normal display, if you click on it you get the option to change the value as seen in the left tile.

2 Likes

Oh cool, I didn't know that was possible.

I'm going to play around with the two and see if I can get something set up where the original device type is used to display a non interactive number on the main dashboard and then the second one can be used in a linked dashboard (behind a PIN) to change it.

I could combine the two drivers, but an easier way may be to use the Attrbute tile for the “locked” display, and the Number Variable tile for the update dashboard.

Right, that's what I was thinking of. I am just wondering how to make the number variable automatically update the attribute tile

Create each tile with the same device. Devices can be accessed from multiple tiles.

1 Like

Ah! ok I see now. One dashboard use attiribute template and the other use variable!

Thank you soooo much for you help!

Glad to help, good luck with the kiddos.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.