Package: Hubitat

Author: HCA Central
Version: 28
Added to Library: 10-Nov-23
HCAVersion needed: 17.0.21
Keywords: Class

Requirements: Before working with this class, you must have a Hubitat hub installed and have used the Hubitat interface to add the devices to it. There are additional steps to follow and they are outlined in the online technical note linked below.
Extra Info Link: Here

Package Description:
With contributions from Bob Armstrong, Kevin Wilcox, and Michael Jasper

What's new in this version?

- New Class for the Zoos Scene Keypad

What's new in this version?

- Addition of Keypad class

- Updates to the thermostat class

- During discovery creates a file called HubitatDevices.csv in the HCA Folder that lists all the Hubitat devices discovered and their ID

What's new in this version?

- Addition of thermostat class

- Better determination of what class a device belongs to

- Events received from devices now log to the HCA log

NOTE: Requires facilities in HCA version 17.0.21 or later. It will not operate correctly in older versions.

Program: #1 Do Discover

Program Description:
Driver program to load Hubitat devices into a HCA design

Global Variable Use:

Name Description
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Check Batteries

Program Description:
Finds any device in the design that is a Hubitat device that has a battery. Then requests its status to get current battery level and sends a message if battery level less than 25%. Schedule the program to run once a day, once a week, or however often you want to do it.

Program: Class Hubitat Lock Device

Program Description:
Class for any Hubitat device that has a load that can be set to either 0% or 100%

Parameters:

Name Type Description Default
DeviceName Value HCA Device Name  
DeviceId Value Hubitat device id  
Code Value Class action code  
Data Value Class action data  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Class Hubitat On Off Device

Program Description:
Class for any Hubitat device that has a load that can be set to either 0% or 100%

Parameters:

Name Type Description Default
DeviceName Value HCA device name  
DeviceId Value Hubitat device id  
Code Value Class action code  
Data Value Class action data  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Class Hubitat Dim Device

Program Description:
Class for any Hubitat device that has a load that can be set to any percent 0% to 100%

Parameters:

Name Type Description Default
DeviceName Value HCA device name  
DeviceId Value Hubitat device id  
Code Value Class action code  
Data Value Class action data  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Class Hubitat Keypad

Program Description:
This is essentially a collection of buttons in a common controller.

A great example is the excellent Nexia NX1000 Z-Wave one touch controller. The Hubitat community driver for that one allows you to program the button names too.

The class itself operates as a sensor and when it receives a button press event, it updates the datetime of a button trigger tag that corresponds to the button being pressed.

This way its simple to add a trigger for "Tag Changed" corresponding to the button press you want to trigger on. So if I want to trigger on button 3 pressed, add a Tag Changed trigger for my keypad using the tag name "HE_Button_3_Trigger"

Parameters:

Name Type Description Default
DeviceName Value HCA device name  
DeviceId Value Hubitat device id  
Code Value Class action code  
Data Value Class action data  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Class Hubitat Keypad Zoos

Program Description:
This class implements the Zoos Scene Controller keypad

After discovering from the Hubitat and it being added to the HCA design, open the properties of the keypad device and on the "Type" tab enable the "allow change of device class" option and then change the type to "Zoos Keypad".

When it receives a button press event, it updates the datetime and action of a button trigger tag that corresponds to the button being pressed. For example, if button 1 is pushed this trigger is created:

HE_Button_1_Trigger

With tag in a CSV format of two parts - a date time of the action and the action. Like this:

8/23/2022 10:57:05 AM, pushed

This way its simple to add a trigger for "Tag Changed" corresponding to the button press you want to trigger on. So if I want to trigger on button 3 pressed, add a Tag Changed trigger for my keypad using the tag name "HE_Button_3_Trigger"

The Zoos keypad also has a load controller so the device can be controlled ON, OFF, and Get-Status

Parameters:

Name Type Description Default
DeviceName Value HCA device name  
DeviceId Value Hubitat device id  
Code Value Class action code  
Data Value Class action data  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Class Hubitat Sensor

Program Description:
Class for any Hubitat device that is a sensor that has a state the can be queried.

Parameters:

Name Type Description Default
DeviceName Value HCA device name  
DeviceId Value Hubitat device id  
Code Value Class action code  
Data Value Class action data  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Class Hubitat Shade

Program Description:
Class for any Hubitat device that operates as a window shade

Parameters:

Name Type Description Default
DeviceName Value HCA device name  
DeviceId Value Hubitat device id  
Code Value Class action code  
Data Value Class action data  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Class Hubitat Thermostat

Program Description:
Example of thermostat class. Doesn't communicate with any actual hardware but shows the handling of the various codes.

To make this a useful example, any change to the thermostat state is saved in tags on the thermostat object. This allows you to do things like right-click on the device and pick "thermostat" from the popup menu to set and change state. By having the log enabled you can see how HCA uses the class to carry out operations on a thermostat.

Example:
This program is not used directly but invoked by HCA to handle operations on a thermostat device of this class.

Parameters:

Name Type Description Default
DeviceName Value HCA Name of the thermostat device  
DeviceId Value What is on the User Class Object tab of the device. This is class specific and is used by the implementation to identify the thermostat.  
Code Value Operation code  
Data Value Operation data  
retryOperation Value Should the operation be retried if fail? No

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Class Hubitat Unsupported

Program Description:
Placeholder class for any Hubitat device type not managed by another other class.

Parameters:

Name Type Description Default
DeviceName Value HCA device name  
DeviceId Value Hubitat device id  
Code Value Class action code  
Data Value Class action data  

Program: Extract Non JSON Error Code

Program Description:
Utility program to extract the error code from a HTML or XML response. Does its best in spite of Hubitat inconsistent error reporting,

Parameters:

Name Type Description Default
text Value response from Hubitat that looks like a network error  

Program: Hubitat Event Handler

Program Description:
Program to handle the event reports from Hubitat. Full details in the Hubitat technical note.

1. Set the "URL to send device events to by POST" in the MakerAPI to "http://<ip address of computer running HCA Server>/Hubitat. For example "http://192/168.0.88/Hubitat"

2. Add an interface of type "Generic Server" and named "Hubitat Event Server". Set port to 80, Data is TEXT, receive delimiter is NONE. All other settings leave as is.

3. Add a trigger of type "port reception" to this program. Select as the interface "Hubitat Event Server" and tick the "trigger on reception not otherwise handled" checkbox. At the bottom of the Triggers tab, in the "If trigger received" section, choose the final option to queue the message.

Parameters:

Name Type Description Default
EventReport Value Text response from the Hubitat cloud or some network error  
FromIPAddress Value IP address of the source of what was received  

Program: Hubitat Get Devices

Program Description:
Auxiliary program to create HCA devices for Hubitat managed devices.

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Hubitat Refresh Device

Program Description:
Use to perform the "refresh" option on a device

Parameters:

Name Type Description Default
id Value Hubitat device id  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31

Program: Hubitat Respond to push

Program Description:
Responses to a button push for the SmartThings/Hubitat button

Parameters:

Name Type Description Default
TriggerDevice Object The device object for the button that got pushed  

Program: Hubitat User Event Handler

Program Description:
This is a "Stub" for a program that gets started whenever a Hubitat event is reported. After processing the message to adjust HCA device state, this program is started passing in as arguments the various pieces of the event message and the name of the HCA device the event comes from.

If the event reports are only needed for updating state, then you can ignore this program. But if you wanted to, for example, trigger one of your programs on a temperature change report then you should use this event processing.

But don't modify this program!

Just copy the program and paste into one of your folders and modify it there. Then modify the Start-Program element in the "Hubitat Event Handler" program to start your program and not this program.

Anytime you update the Hubitat package then you will have to make that modification to the Start-Program element in the "Hubitat Event Handler" program again.

Parameters:

Name Type Description Default
device Value HCA device name that reported the event  
value Value Value from event report  
displayName Value Display name from event report  
descriptionText Value Description text from event report  
unit Value Unit from event report  
data Value Data from event report  
attributeName Value attribute name from event report  

Program: Send Hubitat Command

Program Description:
Sends a command to a Hubitat controlled device

Parameters:

Name Type Description Default
Device Object HCA Device to control  
Command Value Command name  

Global Variable Use:

Name Description
HE_AccessToken Access token for Hubitat hub. See Hubitat technical note on how to obtain this.
HE_APICode Code for use with Hubitat. See Hubitat technical note on how to obtain this.
HE_HubAddress Hubitat hub IP address. Find from your router and configure the router to not change the IP address. Example of how to enter: 192.168.0.31