sendEvent from an app?

I may be going down the wrong road here, but what I am trying to do is get app logging from the app event page, just in case I accidentally close the live logging window (I do this ALL the time! :smile:)

I set up a really simple refresh app for my switches and dimmers (to test if a delay between the refreshes helps with my hub locking up) and I tried to do a sendEvent. But it is looking for name, value and descriptionText and I’m not sure what to use for name and value. I tried just a made up name and the switch name for value, but it didn’t work. Didn’t crash the app, that was good!

I have looked through the ST documentation and several ST apps, and not finding the answer. Anybody know how to do this or if it is even possible?

Doubt this will explain it, but I'm finding it in all our code.

if (!state.isConfigured) {
logTrace("Waiting 1 second because this is the first time being configured")
sendEvent(getEventMap("motion", "inactive", false))
sendEvent(getEventMap("illuminance", 0, false, null, "lx"))
cmds << "delay 1000"
}
sendEvent(name: "lastUpdate", value: newtime, descriptionText: "Configured: $newtime")

sendEvent(name: "color", value: "#ffffff")

if(value.hue) sendEvent(name: "hue", value: value.hue)
if(value.hex) sendEvent(name: "color", value: value.hex)
if(value.switch) sendEvent(name: "switch", value: value.switch)
if(value.saturation) sendEvent(name: "saturation", value: value.saturation)

This helps…I think where I am having the disconnect is that I see sendEvent in device handlers and the name is either a built-in attribute or a custom attribute. With apps, there are only preferences and state and I can’t tell if the sendEvent sets one of those or not. On the app information page there is a link to events, but I’ve never seen any data on the events page for any apps.

:exploding_head: I really should learn to READ. It’s right there in the title even: App

Sorry. But I feel more awake now, having smacked my forehead :smiley:

1 Like

We’ve all been there! :laughing: Any answer is better than none IMHO :grinning:.

I finally found something over at ST community from a few years ago where the same question was being asked and was never answered. So maybe I hope in vain!

Hubitat is supposed to be BETTER than ST, right? Maybe that’s via answering questions?

sendEvent from an app works just like it does from a driver.

sendEvent(name:"myApp", value: "some random value") or:
sendEvent(name:"myApp", value: "some random value", descriptionText:"some long winded helpful stuff...")

To see these, click the info icon in the app list, then the events link at the top

2 Likes

Aha! So the missing piece seems to be setting the name to your app name. I will give that a try tonight, and thank you!

ummm... almost:

the string assigned to name is totally arbitrary in this context, as is value, and descriptionText.

1 Like

That is even easier...just tried it and it worked. I tried to make it too hard :slight_smile:

Thanks for the info!

2 Likes