Basic template for cloud query SmartApp or DH

does any one have a basic smartapp template, ive never played with smartapps yet, just DH.
I need a basic log on page, all i want to log into yale, run a quiry, refresh the quiry, store the response so that a few DH can quiry the stored data.

At the moment the my 10 deveces (through the DH) run the quiry indpendently, but the quirys are the same, i just pull out the specific device parameters.

thanks

In one DH, you can just use httpGet().

https://docs.smartthings.com/en/latest/ref-docs/device-handler-ref.html#httpget

You could have a SmartApp subscribe to that Device and update all the others.

Or use the pattern Service Manager SmartApp with child Devices, but that’s a bit more complicated.

thanks, what would the best way to have the smartapp update all the DH, i looked for some sort of push command?

This would be easier if you tell us more about the project. What type of Devices are they that you are updating? What SmartThings Capabilities will they claim? https://docs.smartthings.com/en/latest/capabilities-reference.html

Regardless, in the current API you can add any number of custom “Commands” implemented as Groovy methods which can be called from the SmartApp. You would use these Commands to send the updated data to the DH, which in turn can do a sendEvent("attribute_name") on itself to update its own Attributes.

For example, a Contact Sensor has no Commands: only an Attribute “contact [open,closed]”, but writing a custom DH, you can add Command “open”, and def open() { sendEvent( "contact", "open") } … etc.

i took you advace on another job so this is the DH calling a nested map/arry from the parent smart app

def resppar = parent.state.data
    log.debug "full data = ${resppar}"

messag back - full data = [data:[[aggregated_daily_at:2018-10-15T17:17:28.000Z, aggregated_hourly_at:2018-10-16T10:27:38.000Z, container_number:null, controlling_thermostat_id:null, created_at:2018-03-15T18:17:28.000Z, device_groups:[[id:8754, name:All, user_id:8332]], device_id:983, device_type:etrv, energenie_thermostat_id:null, extra_data:null, firmware_version:null, frequency:null, hardware_version:null, id:122977, label:Front room SMALL eTRV, last_diagnostic_flags:[created_at:2018-10-13T01:09:58.000Z, diagnostic_flags:512, id:207491, subdevice_id:122977, updated_at:2018-10-13T01:09:58.000Z], last_temperature:18, nest_thermostat_id:null, optimise_warm_up_schedule:false, parent_device_last_seen_at:2018-10-16T10:47:14.000Z, power_state:0, power_state_1:null, power_state_2:null, power_state_3:null, power_state_4:null, rate_limit_tokens_updated_at:null, rate_limit_tokens_used:null, reactive_power:null, real_power:null, remote_id:1, side:null, socket1_label:null, socket2_label:null, socket3_label:null, socket4_label:null, startup_mode:0, target_temperature:16, timer1_enabled:null, timer1_friday:null, timer1_monday:null, timer1_off_time:null, timer1_on_time:null, timer1_saturday:null, timer1_sunday:null, timer1_thursday:null, timer1_tuesday:null, timer1_wednesday:null, timer2_enabled:null, timer2_friday:null, timer2_monday:null, timer2_off_time:null, timer2_on_time:null, timer2_saturday:null, timer2_sunday:null, timer2_thursday:null, timer2_tuesday:null, timer2_wednesday:null, timer3_enabled:null, timer3_friday:null, timer3_monday:null, timer3_off_time:null, timer3_on_time:null, timer3_saturday:null, timer3_sunday:null, timer3_thursday:null, timer3_tuesday:null, timer3_wednesday:null, updated_at:2018-10-16T10:28:30.000Z, voltage:2.82812, voltage_reported_at:2018-10-16T04:31:52.000Z], [aggregated_daily_at:2018-10-15T17:26:30.000Z, aggregated_hourly_at:2018-10-16T10:22:58.000Z, container_number:null, controlling_thermostat_id:null, created_at:2018-03-15T18:26:30.000Z, device_groups:[[id:8754, name:All, user_id:8332]], device_id:98…[TRUNCATED]

log.debug "drill data id = ${resppar.data?.id}"

log.debug "device id NOT from the response = ${device.deviceNetworkId}"

log.debug "temp - ${resppar.data.subdevice_id['122977'].last_temperature}"
log.debug "temp1 - ${resppar.data.last_temperature}"
log.debug "temp3 - ${resppar.data.subdevice_id.last_temperature['122977']}"

i cant work out how to just have list the values for just the device i want ie id ‘1222977’ temparture ‘18’

drill data respones - drill data id = [122977, 122981, 122982, 122996, 122997, 122999, 123000, 123001, 123004, 123008, 123009, 127535, 127548,

temp1 data response - temp1 - [18, 17, 18, null, null, null, null, null, null, null, null, 19, null, null, null]

ive tryed these, but cant get them to work

def bob = people.find { it.value.name == ‘Bob’ } // find a single entry
def females = people.findAll { it.value.gender == ‘F’ }

// both return entries, but you can use collect to retrieve the ages for example
def ageOfBob = bob.value.age
def agesOfFemales = females.collect {
it.value.age
}

assert ageOfBob == 32
assert agesOfFemales == [21,54]

// but you could also use a key/pair value as the parameters of the closures
def agesOfMales = people.findAll { id, person ->
person.gender == ‘M’
}.collect { id, person ->
person.age
}
assert agesOfMales == [32, 36]

this kind of works to get the data out of the map, but i want to be able to have the 122981 number as a variable, ie be the device.deviceNetworkId, but i cant find the right sintax to replace the fixed id with a variable

def respparid = resppar.data.groupBy{ it.id }

log.debug “by id fixed 122981 -${device.deviceNetworkId} - ${respparid[122981].last_temperature}”