Hello, I would like to create my very first driver on HE. Basically I need a Virtual device with a few custom fields that I wish to use later on Rule machine.
- Is there a way to copy the virtual driver code so I can use as a starting point? I could only access custom drivers I installed from other users.
- Is there any "Hello World" guide somewhere?
Check out the public Hubitat GitHub. It has examples to get you started.
Tks for the quick reply and for the directions!
@bobbyD has pointed you to Hubitat's GirHub respository. I just want to add that there's a standard list of capabilities recognized by the platform. They are described in this document:
Drivers can have custom attributes for data categories outside of the standard capabilities.
Question: Let's say I create a "Virtual Switch Plus", containing additional attributes.
Do you think I will be able to use those custom attributes on RM via Custom command action?
I think so but better check before I go this road...
Yes. As long as you also have a standard capability in that driver.
Let me sort of expand on that. I have custom virtual drivers with the standard capabilities of TemperatureMeasurement and RelativeHumidityMeasurement that also calculate a Dew[oint, which is a custom attribute in my driver (DewpointMeasurement). As shown in the screenshot below, I can use Dewpoint as a trigger in my automations.
@aaiyar answered your question on using custom attributes as event triggers in RM.
You also mentioned custom commands, and you can definitely use those in RM by invoking custom actions in rules. You need to declare those methods as commands in the custom driver definition, as described here: https://docs.hubitat.com/index.php?title=Device_Definition#Commands
Tks a lot, guys. I will have fun trying out these things by the weekend!
Hello, @aaiyar , Bobby and Tomw! it is me again!
I managed to create a simple virtual switch driver but I am confused on how to achieve my main goal:
-I need a virtual Switch that will set itself off after X days
The original virtual switch has feature limited to 5 sec.
-Is there any issue performance-wise to have such implementation? I am doing this for avoiding having lots of RM resetting the switches.
-I actually could not figure out how the original Virtual Switch driver implements that. What needs to be done so that HE will interpret this parameter as sort of countdown and take action after the time set?
Thanks a lot for your help, guys.