Hubitat's Average Temp error after platform update

Hi @bravenel

Seeing some errors after the second to last hotfix. 2.4.147 didnt fix it.

The only thing I've changed with this app recently it take out some HubConnect temp sensors and add in some Hub Mesh sensors. I'm unsure if it's related, but I'd guess so.

Are you using exactly the code from the public repo? Because it wouldn't throw an error from line 44. Perhaps you should post the code you are using, since it evidently is not what is in public repo.

definition(
name: "Average Temperatures",
namespace: "hubitat",
author: "Bruce Ravenel",
description: "Average some temperature sensors",
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 temperature averager", submitOnChange: true
if(thisName) app.updateLabel("$thisName")
input "tempSensors", "capability.temperatureMeasurement", title: "Select Temperature Sensors", submitOnChange: true, required: true, multiple: true
if(tempSensors) paragraph "Current average is ${averageTemp()}°"
}
}
}

def installed() {
initialize()
}

def updated() {
unsubscribe()
initialize()
}

def initialize() {
def averageDev = getChildDevice("AverageTemp_${app.id}")
if(!averageDev) averageDev = addChildDevice("hubitat", "Virtual Temperature Sensor", "AverageTemp_${app.id}", null, [label: thisName, name: thisName])
averageDev.setTemperature(averageTemp())
subscribe(tempSensors, "temperature", handler)
}

def averageTemp() {
def total = 0
def n = tempSensors.size()
tempSensors.each {total += it.currentTemperature}
return ( total / n ).toDouble().round(1)
}

def handler(evt) {
def averageDev = getChildDevice("AverageTemp_${app.id}")
def avg = averageTemp()
averageDev.setTemperature(avg)
// log.info "Average temperature = $avg°"
}

One of your sensors is reporting null for temperature.

Change line 44 to this to find out which one:

	tempSensors.each { log.debug "temp=$it.currentTemperature, $it.displayName"
		total += it.currentTemperature}

I did as you suggested, and the number of errors dropped to 1 in a 2 hour period.

It seems that the error is coming from the Hub-mesh device.

What's weird, is that on the real device, there was nothing at that time. The same temp is there 26.88 but it's an 93 minutes later. It's the same on the linked hub (where the app resides).

Sorry @bravenel , any more thoughts on this? I've checked all my temp devices, and none are reporting null.

The only thing that changed was hub-mesh. And in fact, the only Average Temp's that are erroring are the ones with the hub-mesh devices included. I have multiple Average Temp's (inside, outside, upstairs, downstairs etc). And the only ones that error are the ones with the newly added hub-mesh. The error didnt occur when using Hub-connect. I've only transitioned 2 devices across to hub-mesh.

I’ll try to reproduce this in hub mesh.

1 Like

I just deleted the app, and recreated it for the problematic/erroring one, to see if it had some weirdness.

Newly created app is also getting errors. The errors are only occassional. I have two identical apps that average the temperature with the same input devices. One errors on certain triggers, the other on different, or sometimes the same triggers.

I removed the hub-mesh devices, and the errors ceased.

Have you been able to reproduce? It would seem pretty easy.......share devices via hub-connect to ensure data is valid. Then stop sharing via hub-connect, and share via hub-mesh. Errors!

Yes, and there will be another update coming.

2 Likes

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