Capture Information From 3 Devices

Hello! I'm wondering if there is already something out there that will do what I would like to do. If not, any ideas on how to capture and record the following?

I would like to be able to track when my Ecobee changes to "COOLING". With that, I'd like to also know the time it changed to "COOLING", The date it changed to "COOLING", The Temperature of "DEVICE 1", The temperature of "DEVICE 2", The time it changed back to "IDLE".

Any thoughts on something like this?

I would expect you can capture that using a Rule Machine rule. Recording of the results... I'll leave that to others, but I expect is is possible, if not using a pre-defined driver, then something else that can record what you need.

I guess that is where I'm hung up. Getting the information can come from the devices themselves. Storing it for later is the challenge. I did see today that the Ecobee reports are nicer than previously, but that won't include my other devices...

haven't played with it much myself, but you could likely use a hub variable or something similar... appending the values as you need to... Ata pinch you could use my generic attribute driver, but that is essentially superseded by the hub variable or the more recent equivalent.

Create local variables in rule machine, then append to a local file (the action) when state changes (the trigger).
edit: Oh, other devices too. I guess hub variable would be involved then.

If you have a home assistant instance available I find it’s ideal for logging and visualizing historical data and passing data back and forth with Hubitat.

Nope, I don't...

Yeah... I did something similar in SharpTools. It gives me the current and last 4 temperature values in a chicken coop. I stopped at four because it was a bit time consuming.

Could have sworn @thebearmay created something/some capability along these lines at some point.

Maybe not, but the man's done so much here that I have a hard time remembering that he hasn't done everything there is to do. :slightly_smiling_face:

Don't think I've covered this exact scenario, but the ask isn't too difficult and, as noted above, could be done with RM or one of the other automation tools. You may want to consider using a File Manager file to store the log so that you can use it to do historical analysis at a later date if desired.

Logic flow for an app or automation:

  • Select Thermostat and all external sensors
  • Subscribe to Thermostat Operating Mode
  • When Operating Mode changes
    • capture Operating Mode, and temperatures from all sensors (including the thermostat)
    • Write captured data to text file including date/time stamp (if you use a CSV format you could open the file in Excel or Google Sheets and do the analysis/graphing/reporting there)

I read it as two additional devices, as in z-sensors, hence the need for a hub-wide variable.

2, 10, 50... same logic flow loop to read sensor values just runs longer. Could use a variable, but variables have a limited number of characters which is why I prefer a text file if I'm storing more than a couple entries.

I'm already in over my head, lol. Have a nice evening. :slight_smile:

Capture is key, I guess. I'll have to look at that, one day. :slight_smile:

LOL. You already have the basics down, I'm just adding some additional nice to haves and complicating it.

Fed the requirements into Gemini and it spit out the following app (it's almost as quick as I am :rofl:):

/**
 *  Thermostat Mode Logger
 *  
 *  Logs thermostat operating mode changes and sensor temperatures to a CSV file.
 *
 */

definition(
    name: "Thermostat Mode Logger",
    namespace: "custom",
    author: "AI Collaborator",
    description: "Logs thermostat operating mode changes and temperature sensors to a CSV file.",
    category: "Convenience",
    iconUrl: "",
    iconX2Url: ""
)

preferences {
    page(name: "mainPage")
}

def mainPage() {
    dynamicPage(name: "mainPage", title: "Thermostat Logger Configuration", install: true, uninstall: true) {
        section("Devices to Monitor") {
            input "theThermostat", "capability.thermostat", title: "Select Thermostat", multiple: false, required: true
            input "tempSensors", "capability.temperatureMeasurement", title: "Select Temperature Sensors", multiple: true, required: false
        }
        section("File Settings") {
            input "fileName", "string", title: "CSV File Name", defaultValue: "thermostat_log.csv", required: true
        }
    }
}

def installed() {
    initialize()
}

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

def initialize() {
    // Subscribe to the operating mode attribute of the thermostat
    subscribe(theThermostat, "thermostatOperatingState", modeHandler)
}

def modeHandler(evt) {
    // Generate date and time stamps
    def now = new Date()
    def dateStr = now.format("yyyyMMdd")
    def timeStr = now.format("HH:mm:ss")
    
    // Get the new operating mode (e.g., heating, cooling, idle)
    def currentMode = evt.value
    
    // Start building the CSV row
    def csvRow = "${dateStr},${timeStr},${currentMode}"
    
    // Append the temperature from each selected sensor
    tempSensors.each { sensor ->
        def temp = sensor.currentValue("temperature")
        csvRow += ",${sensor.displayName}:${temp}"
    }
    
    // Add a newline character to the end of the row
    csvRow += "\n"
    
    // Log data to Hubitat File Manager
    writeToCsvFile(csvRow)
}

def writeToCsvFile(rowText) {
    try {
        // Check if file already exists in File Manager
        if (hubitat.helper.FilesUtils.exists(fileName)) {
            // Append row to existing file
            hubitat.helper.FilesUtils.appendFile(fileName, rowText)
            log.info "Thermostat Logger: Appended data to ${fileName}"
        } else {
            // Create headers first if the file does not exist
            def headers = "Date,Time,OperatingMode"
            tempSensors.each { sensor ->
                headers += ",${sensor.displayName}"
            }
            headers += "\n"
            
            // Create file and write headers followed by the first row
            hubitat.helper.FilesUtils.writeFile(fileName, headers + rowText)
            log.info "Thermostat Logger: Created ${fileName} and wrote headers."
        }
    } catch (Exception e) {
        log.error "Thermostat Logger: Failed to write to file. Error: ${e.message}"
    }
}

That looks VERY impressive. I wish I knew what I was looking at. LOL. @velvetfoot is correct, One device is temperature Outside, the other is temperature in another room. I'll study what @thebearmay posted and maybe I can figure out how to use it. The historical values are really nice to have. I appreciate the help!!

@thebearmay Since I use ChatGPT, your idea was awesome! I asked it to create the app and show me step by step how to install and use it. I now have a report being sent to my Pushover once a day, and a button press will generate that report on demand,

Cooling Cycle Report

Cooling started at 9:00 PM
Cooling stopped at 9:12 PM

Inside temperature was 74°
Outside temperature was 82°

Cooling cycle ran for 12 minutes

AI can be very useful, and for situations where you want a custom result may fill the gap perfectly. Still haven't figured out which one(s) I like the best, used Gemini this time simply because it was a button click in the browser interface (Chrome).

Glad to see you were able to get the result you needed.

[RELEASE] Advanced Climate Controller - A Commercial-Grade BMS for Hubitat - :construction: Developers / Vibe-Code - Hubitat

You might want to check out Advanced Climate Controller. It will log your cooling cycles, prolong them if your short cycling, and only notify you if you have an issue.