Getting started with development

Hey all,

I was wondering what the best resources are for getting started developing for HE. I've found the development page to be a little thin. Both high level overview, like the relationship between templates and drivers, and many of the low level details.

As an example, I installed IKEA shades, and successfully installed device code I found for them to get them working. But when I look at the code, one of the first sections is 'tiles', which I don't see in the developer documentation, and I can't even figure out how to display all of the tile components listed in the code from the dashboard. I did find documentation similar to the code for SmartThings, which is where I believe this device code started. Does HE only use a subset, and that is why I don't see the extra tile components? This is the type of documentation I am looking for.

On a more specific note, I have used a pair of power monitors on my washer/dryer, and sent that through MQTT to NodeRED to decide if the washer is off/idle/filling/washing, and the dryer is off/open/drying/igniting, and then send these values back into MQTT. Also working on a garage door sensor that can report position like a shade (closed/opening/open/closing/partially open). I could probably just use the shade template with the garage door, but I don't understand the parts I would need for the washer/dryer. I have found in the forum I can not create a capability for them, but can use custom attributes. And from the developer doc I see how I can connect to MQTT, but it is not clear what template would represent a washer or dryer, or how the device code maps to them.

Any pointers on a more encompassing source of developer information? Do I start with the ST documentation for the device code?

Thanks.

-Michael

This question has come up several times recently. Here's an answer I gave that is still applicable:

Thank you. The ST docs and porting info will likely be very useful.

I've started writing device code based on the examples on Github, but selecting a proper template, and how to display values in it, is still a mystery.

FYI the tiles section in not used at all on Hubitat. That is a Smartthings feature for their classic mobile app. You can safely remove the tiles section custom drivers.

I should answer more specifically about this: Hubitat doesn't use tiles. That is an artifact from a sloppy SmartThings port if you see one in a "Hubitat" driver. :slight_smile: (In ST, it is used to create part of the mobile app UI for the device. Hubitat creates a page for the device automatically based on commands and attributes it implements, but day-to-day user-oriented control is intended to be done via automation or a Dashboard, not the device admin page. In ST, these are confounded.)

I'm not sure what you mean with "templates" here. This is a Dashboard term for sure, but that just means how the Dashboard tile displays. Different templates show different attributes of the device (e.g., a Temperature template will show you a temperature for any device that supports it, whether it's a motion sensor or a thermostat, etc.; a thermostat with the Thermostat template will display differently than one with a Temperature template applied). Many also allow you to send commands--e.g., a Switch template will let you send on/off (and view the switch state). This applies only to Hubitat Dashboard. Perhaps you mean something else, since I'm not sure why you're asking about templates here--you can't create custom Dashboard templates (they're just part of the app). Some devices trick custom attributes into working in very specific ways on Dashboard tiles (e.g., SuperTile, TileMaster), but that's probably not what you're going for.

EDIT: After re-reading both of these replies next to each other, I think the confusion might stem from "SmartThings tiles" (not a thing in Hubitat) and Hubitat Dashboard tiles (definitely a thing but one you have little control over as a driver author--stick with standard capabilities, and Hubitat Dashboard does most of the work). They are unrelated.

ogiewon Was just figuring that out, didn't see it in the example drivers. Explains some of my confusion.

I just did a too-quick-readthrough of that porting post, and didn't see anything about how the templates work. I suspect the templates are related to capabilities, and if I match the capability protocol, the template would be able to display those values?

For now I started using an attribute template, boring but is showing my state. Haven't figured out what the generic template does, other than just say 'generic'.

bertabcd1234 - Thanks. I meant template as in the selection when you create a tile on the dashboard. I had seen that you can not create custom ones somewhere in a forum post, but it was not clear to me how you get custom device data into an existing template. Am I correct that the templates are built to mostly display values/controls from capabilities, so if I follow those, even if they don't make sense in my washer/dryer case, I could use one to display my data?

I honestly did not know there was a "Generic" Dashboard tile template, and after playing with it for a bit myself, I am unable to figure out what, if anything, it is supposed to do. (Placeholder or artifact from development are my guesses, probably both wrong.) An "Attribute" template lets you pick an arbitrary attribute, including a custom attribute, to show on the tile. As you note, these are not always useful because they are dispaly-only. If you want something interactive, you'll have to stick to commands and attributes that are part of standard capabilities made useful by regular templates (switch, dimmer, thermostat, etc.).

For your washer/dryer example, if you aren't trying to make something interactive, you could definitely use an attribute template with a custom attribute. There are Energy Meter and Power Meter templates that could tap into standard attributes, but it depends on exactly what your device/driver reports.

This may or may not suit your use case, but I have my washing machine plugged into a TP-Link energy monitoring plug, which I have setup in the TP-Link integration app/driver. I then have the "Better Laundry Monitor" app, which, detects when the washing machine has finished a cycle and sends a notifcation to my phone and to what was once the What Did I Say driver, now known as Follow Me. The follow me "device" has an attribute that lists recent messages, so you can show on a dashboard if one or more events were detected.

Even if this particular setup doesn't suit your needs, hopefully it might give you some other ideas to think about in how you might code your own.

sburke781 - Thanks, I'll look into those components. I have my washer/dryer monitored by a Shelly EM, and that is posting watts to MQTT, where NodeRED is converting the power number into a state name, plus a finished flag at the proper state change on each.

I have device code working to display a status value using the attribute template, and got it to connect to test.mosquitto.org and parse a test message. I just need to create a user on my MQTT server for HE, and create a rule to push a notification when the finished flag is set.

Turns out this was easier than I expected. I was thrown off by cruft in the IKEA shade driver I was using as an example. The tiles are not as fancy as I was expecting, but meh. The states are shown, and the main goal of notifying on completion will work. Not bad for an evenings work.

Thanks to everyone for the pointers!

1 Like