Other Device state in driver?

I've got a custom garage door opener, the driver just emulates a push button, I'd like to be able to read the status of a contact sensor on the garage door to get a sense of the state, whether I'm opening or closing the door. Is there a preferred way to read a separate device state in a driver?

I thought I could just use maker api, but that seemed inelegant.

Do you mean from another device? ..
If so you will probably need an app for that ..

Yes, separate contact sensor. App seemed like overkill since you could just say do a maker api request and get the state of the contact.. But thought perhaps there was a proper way to do that.

To clarify:

My Driver is for the garage controller, and the garage door has a separate contact sensor for seeing if it's closed.

You cannot access other devices via a driver. You can only access multiple devices from within an app.

Then you will need an app. But there is already an app for that that simulates a garage door from two separate devices.

@Ryan780 don't keep me waiting :slight_smile: , what's it called?!

Phone rang...took me a minute to find it. But I'm sure you could have found it if you looked...

Thanks @Ryan780 , really appreciate it.

1 Like

Try this it's working fine for me in he, app and virtual driver/device.

Support 1 sensor or 2 setup, dew time on closing, flashing lights/alarm/voice on closing

Toggle open close or dedicated open and separate close devices

Dont use gate driver, as only difference was icons and he dont support them like ST I never bothered porting it

Is this absolutely true?
I want a device driver to pass hub values to a child.
Setting up a indoor weather station. Would like to pass any value on da hub I.e. master bedroom temp, living room temp, to the device.
Device will have a TFT display to act as a HMI.
Matt

Passing information from one to another is possible directly between parent and children and vice versa. I meant devices that do not have a relationship with each other, which is clear from the OP that they do not.

Hub values? I don't know what you're referring to.

You don't have to pass the value to the device. The parent can generate the event for the child and the child's attributes are updated automatically. You don't have to wait for the child to parse the data again. This is much more efficient since all the processing can live in the parent. Instead of calling "sendEvent(params)", the parent can call "childDeviceWrapper.sendEvent(params)".

I've heard that the hub is a database. I want to query the hub for values in that database.

"You don't have to pass the value to the device. The parent can generate the event for the child and the child's attributes are updated automatically. You don't have to wait for the child to parse the data again. This is much more efficient since all the processing can live in the parent. Instead of calling "sendEvent(params)", the parent can call "childDeviceWrapper.sendEvent(params)"."

So your saying create a weather station attribute Living Room Temp and have the driver update it.
I thought attributes were one way sending device data to the hub.
Matt

You can't do that. That't not how the system works. Apps can query the value of attributes for devices or execute command on devices they have been told to control. The system does not allow complete and unfettered access to everything everywhere.

You're not talking about sending data to the hub. You're talking about the hub publishing the data for other apps to use.

In a nutshell, this is how the system works:

Sensors send data to the hub which is then parsed by device drivers. These drivers then generate Events, which are subscribed to by apps. When the devices generates an event, the apps is "told" about the event and then process that event to decide if anything should be done. If the app decides that something should be done, then it commands the necessary devices to do what they are supposed to do. Those device's drivers process those commands into messages the devices will understand and send those messages out to the devices.

The hub is not one big database. It is an event driven system that has a discrete architecture. You have to work within that framework.

I would recommend that you do some reading on here on how the system works.

1 Like

To query the only way is to subscribe to attributes
An app can write an event for a device without invoking the device

I was trying to simplify things. Let's crawl before we try to run the Boston Marathon.

Andy @haas and Dan’s @ogiewon MonaLisa driver can send a text string to the Arduino. I’m just trying to move data to the Arduino that it can use.
I can always use RM to send data down to the Arduino
I realize that I’m not using the hub the way it was intended, it’s more fun that way.

“ I would recommend that you do some reading on here on how the system works.”
I can’t believe you just said that. The Hubitat development documentation is some of the poorest I’ve read. They post examples on GitHub that have 0 comments. I’m still having fun because of all the help I’ve received from the forum

Yes...but that is not data from another device. It is data from that device itself. You can either accept what I am telling you or not, that choice is yours. But it's not going to change how the system works. You cannot query another device for a value from a driver. That is not possible. You can pass data from a child to a parent or from a parent to a child but that is a special relationship. Otherwise, you have to do what you are trying to do from an app. That's just how it is.

I meant on the forum. There are a lot of examples of other folks code up here for you to look at. Maybe you didn't understand when I said "here" i meant HERE....as in the forum.

That is the best description of the architecture I've seen.

1 Like

It's vastly simplified and there are some things that could be considered exceptions, like child devices, but my view is, understand the basics before you try to tackle the advanced stuff. We should learn to crawl before we try and run a marathon, right?

WOOT!
Tried RM but it can't send a dynamic sendCommand.
Only a static string or number.

Took the Average Temperatures.groovy app and butchered it.
Added inputs for RH and the MonaLisa board .
input "LisaDev", "capability.configuration", title: "Select configuration to send string to", submitOnChange: true, required: true, multiple: true

(because when I want an output I create an input)

In the body of the App code:
log.info "Sensor temperature = ${n} ${it.currentTemperature}°"
LisaDev.sendCommand "${n} ${it.currentTemperature}."

First line sends to the log. Second to the MonaLisa/Arduino!!!!!!

What do you mean it can't send a dynamic sendCommand? You can set a variable equal to whatever you want and then use that as a parameter in a custom action. Also, sendCommand has to be declared in the metadata as an available command for RM to be able to see it.

I have this using sendData and the local variable "test" which is equal to "This is a test."

image