Thank you for your guidance. Your suggestion seemed the simplest.
For clarity:
- my App is a simple app I've written to do some string formatting.
- my Device driver is written by me and equally simple.
In the App I've added an "input" for the driver device. I chose a capability of "Variable"
input "UARTdriver", "capability.variable",title: "Select UART Driver", submitOnChange: true, required: true, multiple: false
I assume the "UARTdriver is somehow the wrapper I need to access the UARTdriver method "WriteAtt_"
Do you have an example of something similar?
Thanks
John
App:
/*
App to receive data from several sensors and send the data to a cc2530 via UART.
*/
definition(
name: "UART Data App-01",
namespace: "hubitat",
author: "JohnRob",
description: "Hub data to UART",
category: "Convenience",
iconUrl: "",
iconX2Url: "")
preferences {
page(name: "mainPage")
}
def mainPage() {
dynamicPage(name: "mainPage", title: " ", install: true, uninstall: true) {
section {
input "thisName", "text", title: "Name this UART data", submitOnChange: true
if(thisName) app.updateLabel("$thisName")
input "tempSensor", "capability.temperatureMeasurement", title: "Select Temperature Sensor", submitOnChange: true, required: true, multiple: false
input "humidSensor", "capability.relativeHumidityMeasurement", title: "Select Humidity Sensor", submitOnChange: true, required: true, multiple: false
input "UARTdriver", "capability.variable",title: "Select UART Driver", submitOnChange: true, required: true, multiple: false
log.debug "UARTdriver $UARTdriver"
} // section
} // dymanicPage
} // mainPage
def installed() {
initialize()
}
def updated() {
unsubscribe()
initialize()
}
def initialize() {
subscribe(tempSensor, "temperature", handlerTEMP)
subscribe(humidSensor, "humidity", handlerHUMID)
}
def handlerHUMID(evt) {
state.lastHUMID = evt.value
log.debug "handlerHUMID() called: ${evt.name} ${evt.value}"
}
def handlerTEMP(evt) {
int index = 1
log.info "index $index, event $evt.value"
//buildMsg(index,evt.value)
}
/*
Driver:
//import hubitat.device.HubAction
//import hubitat.device.HubMultiAction
//import hubitat.device.Protocol
metadata
{
definition(name: "Zigbee UART Data Driver", namespace: "johnrob", author: "johnr")
{
capability "Actuator"
capability "Switch"
capability "Variable"
attribute "variable", "string" // attempt at accessing driver method
command "ReadAttr_"
command "WriteAttr_"
}
preferences{
input "tempSensor", "capability.temperatureMeasurement", title: "Select Temperature Sensor", submitOnChange: true, required: true, multiple: false
}
}
def parse(String description){
log.info "Raw Description#$description"
Map map = [:]
def event = zigbee.getEvent(description)
//if (event) sendEvent(event)
if (description?.startsWith ('catchall')){ //('read attr -')){
def descMap = zigbee.parseDescriptionAsMap(description)
log.info " desc map $descMap"
if (descMap.cluster == "0014" && descMap.attrId == "000e"){
ZigbeeHexMap = descMap.value
log.info "Zigbee Msg#$ZigbeeHexMap"
float SensorValue = ConvertHexToFloat(ZigbeeHexMap)
def otherAttrs = descMap?.additionalAttrs
otherAttrs.each{
unitaddress = it.value
}
log.info ("$unitaddress")
def (units, address) = unitaddress.tokenize( ',' ) // <--- units and I2C address
} // --- if cluster ---
} // --- if "read attr" ---
} // --- parse ---
def WriteAttr_( ) { //<<<<<<< =========== this is the method I wish to access from the app
def serialdata = "0761626364616125"
"he raw ${device.deviceNetworkId} 0x01 0x01 0x0014 {104 3 02 0E00 42${serialdata}}"
}
def ReadAttr_(){
zigbee.readAttribute(0x0014, 0x000e, [destEndpoint: 1], 0)
}