Trying to create an event in an APP and have it output to Node-Red via eventsocket

I've written a simple app to monitor my A/C on time, It works fine and logs (in the live logs) the calculated data.
However I would like to capture this data in Node-Red. To date I can collect all the "device" events but not this "APP" event.

is there a step I'm missing?

Thanks
John

def handlerAC(evt) {
    //log.debug  "event Value=$evt.value"
    if(evt.value == "cooling") state.coolStart = now()
    else if(evt.value == "idle") {			// if idle we must be stopped.
        state.prev_coolStop = state.coolStop
        state.coolStop = now()
 		int onTIME = (state.coolStop - state.coolStart)/1000
		int onPeriod = (state.coolStop - state.prev_coolStop)/1000
        int percentON = (onTIME/onPeriod) * 100
        log.info "onTIME=$onTIME, onPeriod=$onPeriod, percentON=$percentON, OutsideTemp=${state.Temperature},  MasterBRTemp= ${state.MasterBRTemp}" //, ThermostatTemperature= $state.ThermostatTemperature"
        sendEvent(name: "ACDutyCycle", value: percentON)
	}  //if idle
}  // handlerAC

Instead of a app why not just create a device driver that is updated with all of the info you want.

Live logging isn't designed to provide data in a format that can be analysed easily. A device driver on the otherhand can capture the data easily. It can alao break the metrics up so the can be easily analysed.

If you want to capture the live logging though you can have node red connect to the live logging websocket and then it would get anything that gets logged.

What are you putting this data in to look at later? A spreadsheet, influxdb and grafana, something else.

1 Like

I already have node-red capturing the websocket data. My issue seems to be the app is logging but not going out to the websocket connection.

Hubitat offers two websocket choices:

  1. An eventsocket, which is a websocket stream of all device events
  2. A logsocket, which is a websocket stream of all logging

If your app is writing to the logs, it’ll never show up in the eventsocket. For that it has to write to a (virtual) device.

Personally, I would go the route @mavrrick58 suggested. Write to a virtual device and those events will be in the eventsocket stream.

2 Likes

Honestly I haven't seen this situation. I was capturing all the live log data via Node-Red and putting it into InfluxDB to review like a syslog. So i don't see how it would not be getting collected if it being put in the Live Logging and is being parsed fine in Node-Red. I can share my syslog setup with you if you need it.

My suspicion is that you are using logsocket (ws://hubitat-ip/logsocket), while @JohnRob is using eventsocket (ws://hubitat-ip/eventsocket).

1 Like

Correct, I'm using the eventsocket which (now that I know the difference) I prefer over the logsocket.

I still find it weird that an app can generate an event see this post with input from Mike Maxwell.
and eventsocket will not receive it.

@mike.maxwell can you tell us why the eventsocket seems to not "transmit" events created in an app?

Thanks
John

Obviously, I’m not Mike. But I would guess it’s because devices create events that match built-in capabilities or driver-defined attributes, while apps create an output with no capability or attribute defined?

2 Likes

To me this kind of screams wrong tool for the job. Do you have a smart thermostat that you are trying to get this information from. I would suggest you use that device and output it's states to a external database or Webcore Hubigraphs so you can visualize it.

Here is my example of what i have to monitor my HVAC Activity. It is from data collected by my Ecobee thermostat.

What would be the generally intended purpose of sendEvent() in an app? I guess if it were a child of another app, its parent could possibly subscribe to events on that attribute name from the child app?

Although, i'm not sure if non-declared attributes in drivers can have app subscriptions, let alone from child apps where attributes can't be declared at all to the best of my knowledge.

@JohnRob , if you are really invested in this event socket approach, you could create a lightweight child driver with a custom attribute declared and then send events from your app to that.

My goal/project;

Our central air has only one thermostat. Our home is on 3 levels (similar to a split level layout).
The current thermostat location is located where the air flow doesn't provide proper temperature sensing.

We had some issues with the A/C last year. At that time I created an app to calculate the A/C % ON time and period. I would like to collect this data along with the 5 other temperature readings and Lux (although I'm not sure how useful Lux will be).

Status:

Currently I have Node-Red reading all the other data and putting it in a csv file.

With the help here I'm now trying to write a device driver to get the % On time data to Node-Red. I've done this before with DewPoint but forgot the concept (aka the data path).

I see the "sendEvent" command (suggested by Mike Maxwell to just create an event in an app) does not work for devices. However in my naivete I wonder why this is the case. Perhaps it is a "lost feature". Hence I thought Mike might clue me in, and maybe make it function from an app.

I get it. I feel like so often the thermostat in the house is positioned in worst places. That is also why i like Ecobee. The bottom of those two graphs shows the temps of my thermostat and its three additional sensors it uses to determine when to run.

The top graph shows when the HVAC is running and what state it is running in. I suspect you could create a widget that gives you the percentage it is running based on that data collected pretty easily.

How do you know what state your hvac is in. Do you have a smart thermostat?

Our AC has a Honeywell T6 pro. Our ecobee works the heat (where the remote helps control the heat better in the winter). Although it seems to work OK I'm not a fan of the ecobee.
I have temperature sensors on every level of the house and I have a Sonoff on a command strip in the upstairs hallway. My goal is to understand how to best balance the AC at different times of the day. I have considered motorized dampers but currently not sure they would help.