Struggling a little with new version of RM

I have a device that @thebearmay made for me that allows us to display, add, and take points that we give the kids for good behavior etc. I am trying to figure out a way to use RM to automatically add points at a specific time every week.

I have the trigger all ready sorted. I just am not sure how the management of variables would work.


This what the device page looks like if that is helpful at all.

Every Sunday at 9 pm I want to add 500 points to whatever the current value is.

See if the setVariable command is under custom actions…

It is but I'm not sure how to accomplish "+500"


Is there a way to enter something here that adds to current value instead of overwriting it?

Try this version of the driver and use the custom command increment

Custom Dashboard Connector
/*
 * Dashboard Variable w/Increment
 *
 *  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.
 *
 *  Change History:
 *
 *    Date        Who            What
 *    ----        ---            ----
 * 
 */

static String version()	{  return '0.2.0'  }

metadata {
    definition (
		name: "Dashboard Variable Device 2", 
		namespace: "thebearmay", 
		author: "Jean P. May, Jr.",
	        importUrl:"https://raw.githubusercontent.com/thebearmay/hubitat/main/dashVariable.groovy"
	) {
        	capability "Actuator"
	    	capability "Sensor"
		
		attribute "variable", "string"

     		//This one works with the dashboard
		command "setVariable", [[name:"variable", type:"STRING", description:"Both commands store the same variable.  Dashboard tile type applies constraints at the dashboard."]]
		//This one works in webCore without generating a warning message
        	command "setVariableAlt", [[name:"variable", type:"STRING", description:"Both commands store the same variable.  Dashboard tile type applies constraints at the dashboard."]]   
            command "increment", [[name:"incValue", type:"NUMBER"]]
        
    }   
}

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

def installed() {
	log.trace "installed()"
    	setVariable("installed")
}

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

def setVariable(varStr) {
    if(debugEnable) log.debug "setVariable() $varStr"
    sendEvent(name:"variable", value:varStr)
}

def setVariableAlt(varStr) {
    if(debugEnable) log.debug "setVarALt() $varStr"
    setVariable(varStr)
}

def increment(incValue){
    try {
        incWork = device.currentValue("variable").toFloat() + incValue
        sendEvent(name:"variable", value:incWork)
    }catch (ignore) {
        log.error "Parsing error - variable value '${device.currentValue("variable")}' is not a number"
    }
}

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

Amazing! I was not at all expecting a custom solution! Thank you so much! I'll give it a shot on my lunch break today.

1 Like