Thanks @JDRoberts yes it helps some, unfortunately for me I’m a learn by watching and doing kind of person.
I was hoping for a step by step from a blank slate.
There’s a lot of before you do this you need this setup, go to this link. Then you need this and by the way you need to configure this go to this link.
There needs to be a very clear step by step not got to this link do this, go to this link then this link do this now, then go back 1 step do this now, go to this link do this and now you can go back to where you started.
SmartThings has rarely provided beginner’s guides throughout their history. (Try figuring out how to use only specific selected sensors for STHM, for example. Or what repeaters do. Or how geopresence works. Or what a precondition does. Or using light groups. Just sayin ’…)
but who knows, maybe they will this time. One can always hope.
Deleted my posts. You asked about edge and my posts were not about edge. Sorry. Should have read it closer.
The videos inside of @JDRoberts 's links are pretty good overall. They walk you through it in the fashion you are looking for, including setup. Just choose your flavor zigbee/zwave/lan and go from there. For completeness, here is the LAN setup.
Click on extensions to install the extensions to work with the LUA language, with syntax fixes and programming errors. With these that you see are enough for me
This editor has integrated the Terminal, where we can use the CLI, to package, publish, view logs… create custom capabilities…
If you install the CLI in the same VSC editor directory, you don’t have to configure the terminal execution home directory in Visual Studio Code (VSC). In my case I configured it in editor settings.
Once the extensions are installed, you have to download the code of the official beta drivers from the smartthings Edg drivers repository. You can synchronize with the github repository, I haven’t done it in this editor.
The drivers are organized into folders that contain all the necessary files for each driver. Some useful information about the driver folders
Install CLI on your computer:
• You have to download from this link release 34 of the compressed file smartthings-win.zip, if you use windows or the one necessary for your operating system
• In that link you also have installation help, use and all the commands you can use
• Unzip it and move the smartthings.exe file to a folder on your computer from where it will be used. for example to a new folder in documents/CLI
• You have to open the windows powerShell terminal window and you have to go to the directory (folder) where the smarttings.exe file is.
• Use the DOS commands “cd…” to move down directory and “cd directory name” to move to that directory. This is an example of my folder for CLI or VSC folder
• the first time you type a CLI command it will take you to the smartthing page to authorize your account.
• type .\smartthings edge:drivers:logcat
• enter the IP of your HUB, you can see it in IDE
• It will show you the list of drivers installed on your HUB
• type the number corresponding to the driver you want to see
• It will show you the activity of the device connected to that driver.
To modify an existing Driver
VERY IMPORTANT to create different versions of the driver. The Driver ID is unique:
10.1. Youcan create different versions of the driver with different IDs, which will look like different drivers
10.2. You can create driver versions with the same ID, which will look like a new version with a different date of the same driver and overwrite the previous version.
10.3. this is controlled with the config.yml file and the name and packagekey fields
10.4. Name: It is the name with which the driver is created. Changes in this field does not change the driver ID, it only modifies the name and overwrites the previous driver
10.5. packageKey: This name is used to create the Driver ID. If you modify this field, versions of the driver with different ID are created, which will be seen as different drivers. You can use -v1… vx to create different versions without modifying the previous ones that already work well
To only add new Fingerprints to the driver:
11.1. You have to open and edit the fingerprints.yml file
11.2. You will see that each device id is assigned a deviceProfileName
You have to check all the profile files, in the profiles folder, to verify which capabilities each profile has defined and see which profile fits your device.
12.1. Copy and paste a device group and modify it with your device’s data:
12.2. The id : Must be unique, there can be no duplicates
12.3. The manufacturer and model must be exact to the one shown in IDE
12.4. Assign the profile that best fits the capabilities of your device
12.5. This does not guarantee that your device will work, since it may need the execution of some subdriver, to show the battery voltage for example
Once the file is modified you save it and you have to create the new driver with the CLI, for example the driver with the code that is in the zigbee-switch-power-v2 folder
You can copy the path of the containing folder of the code and paste it into the CLI command
This generate the driver like this:
┌─────────────┬──────────────────────────────────────┐
│ Driver Id │ f72a817f-7181-4538-8ef3-e932343a03de │
│ Name │ Zigbee Switch Power Mc │
│ Package Key │ Zigbee_Switch_Power-v2 │
│ Version │ 2022-01-25T11:40:11.202738 │
Publish it in the channel you want to use to distribute or install. Follow the CLI instructions
You must have created a channel to install your drivers, see tutorials
.\smartthings edge:channels:assign
Install the driver on your Hub and follow the cli prompts: .\smartthings edge:drivers:install
To capture the pairing log:
• Uninstall the device with the app
• Open the terminal window with the CLI ready to see the log of the driver to which the device is going to be paired
• In the app, add new device and search nearby
• When paired in the app you will see information appear in the CLI window
• When it finishes pairing, select the data in the window, copy and paste it in the post
Kudos to @Mariano_Colmenarejo. Not only do you provide drivers for a lot of devices you took the time to document the process that you used. Very much appreciated.
@Jake_Mohl the tutorials don’t cover things like setting up node or your development environment because these processes are being updated frequently and there are many tutorials for this. Once you have your workstation configured the actual driver development process is quite straight forward.
With each question and with each answer we all learn something new!!!
3 Likes
Novicetwo
(Doug. When will mobile presence work?)
15
Hello Mariano
I’m not a developer or coder, just follow along these discussions with interest. Not that I understand anything about edge but have a curiosity. After ready your write up I feel better prepared to take the plunge and dabble in edge. Thank you for the clear explanation of how to approach this. In my book your a valuable asset to this community.
Sort off, I generally forget the answer… and then ask again months later when I remember to ask the same question, probably why I feel I don’t have the aptitude for dev work
Wonderful guide and well explained
Can you please write some more regarding regarding init.lua files , Preferences buttons, other buttons. Give some good hints for non developer…
I just want to create setting that initialize calibration and % reversal for ZigBee shutter module. I know the cluster and attribute and values but how to send and debug. Any help is appreciate.
Moving and pausing is working with generic ST driver…
This is not something that is explained in a few words, it is several different tasks and the best is see examples and try do it.
if it is about writing a value in a cluster attribute, you can see how the writing of the attribute is done to restore the state after a power outage in my Zigbee Switch Mc driver:
Search in the .yml file of a profile how to write the preference, copy, paste and modify it to your liking in your profile:
- name: "restoreState"
title: "Restore State After Power Lost"
description: "After the power supply is back on, the State can be restored to previous state or remain switched off"
required: false
preferenceType: enumeration
definition:
options:
"0": "device remains switched Off"
"1": "device remains switched On"
"255": "device restores previous state"
default: "255"
Search in the do_Preferences function in random.lua file how to detect when the value of that preference is changed.
There is the code to write the new value in the attribute:
--- Update preferences after infoChanged recived---
function driver_handler.do_Preferences (self, device)
for id, value in pairs(device.preferences) do
print("device.preferences[infoChanged]=", device.preferences[id])
oldPreferenceValue = device:get_field(id)
newParameterValue = device.preferences[id]
if oldPreferenceValue ~= newParameterValue then
device:set_field(id, newParameterValue, {persist = true})
print("<< Preference changed: name, old, new >>", id, oldPreferenceValue, newParameterValue)
--- Configure on-off cluster, attributte 0x8002 and 4003 to value restore state in preferences
if id == "restoreState" then
print("<<< Write restore state >>>")
local value_send = tonumber(newParameterValue)
local data_value = {value = value_send, ID = 0x30}
local cluster_id = {value = 0x0006}
--write atribute for Tuya devices
local attr_id = 0x4003
write_attribute_function(device, cluster_id, attr_id, data_value)
--write atribute for Tuya devices (Restore previous state = 0x02)
if newParameterValue == "255" then data_value = {value = 0x02, ID = 0x30} end
attr_id = 0x8002
write_attribute_function(device, cluster_id, attr_id, data_value)
end
The function write_attribute_function(device, cluster_id, attr_id, data_value) is a custom code modified from default libraries, is in the top of random.lua. You can copy and paste in your file.
Only have to send the values of the variables (device, cluster_id, attr_id, data_value)
The data_value = {value = 0x02, ID = 0x30} : value is new value to send and ID is the datatype, you have to use the correct data Type for the atributte (see the developers document or lua libraries to see all types). data type 0x30 = “Enum8”
In the log with the CLI you can see how the write attribute command is sent with the new value and response of the device.
thanks for very detailed guide.
I did your steps carefully, step by step.
in the end of the toturial i got error when type “.\smartthings edge:drivers:package ”
i very want to learn how to add and customized new devices to help the community grows
Be careful with .yaml and .yml files. With YAML the amount of indentation at the start of a line carries different meanings depending on whether it is the same, more than, or less than, that on the previous line. It also has to be all spaces, tab stops will not be accepted. If you are editing an existing file try and make things line up with the existing code and then you should be OK.