Setting Up Edge Development Environment

So I’m definitely behind in the times. I am definitely having problems understanding the process on how to setup the everything to start development.

It would be handy to have a detailed dumbed down step by step on how to setup the environment for new people wanting to dabble in this.

Any help would be greatly appreciated.

2 Likes

This tells you how to set up the Command Line Interface (CLI)

This is the starting tutorial for Zigbee edge drivers:

And one for Z wave:

Does that help?

1 Like

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.

2 Likes

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 ’…:wink:)

but who knows, maybe they will this time. One can always hope. :sunglasses:

3 Likes

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.

1 Like

You need to install the CLI and have a way to edit text files. Everything else is fluff.

1 Like

@Jake_Mohl,

I don’t know exactly where you are, but I’ll try to explain how I did it

How to edit the LUA and yml code of the Edge drivers

I’m going to explain the steps I did, that I’m not a developer and I started from scratch, without knowing the CLI or Lua.

  1. First I read the Edge Drivers tutorials and CLI in the community
  1. Download a multilanguage code editor, I opted for Visual Studio since they recommended it in some thread of the tutorials.
    Visual Studio: IDE y Editor de código para desarrolladores de software y Teams
  2. Once installed, the Windows version in my case, this window appears

  1. 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

  1. 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.

  1. 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.
  1. The drivers are organized into folders that contain all the necessary files for each driver. Some useful information about the driver folders

This is the official tutorial.

  1. 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

smartthings-cli/packages/cli at master · SmartThingsCommunity/smartthings-cli - smartthings edge:channels:update [ID]

• 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.

  1. To modify an existing Driver

  2. 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

name:  'Zigbee Switch Mc'
packageKey:  'Zigbee_Switch_v5'
permissions:
zigbee: {}

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

  1. 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
- id:  "LIDL Plug/TS011F"
deviceLabel:  Lidl Plug
manufacturer:  _TZ3000_kdi2o9m6
model:  TS011F
deviceProfileName:  single-switch-plug
  1. 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
  2. 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

.\smartthings edge:drivers:package C:\Users\Mariano\Documents\Mariano\VSC\SampleDrivers\zigbee-switch-power-v2

You can copy the path of the containing folder of the code and paste it into the CLI command

  1. 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           │
  1. 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:drivers:publish

  1. Install the driver on your Hub and follow the cli prompts:
    .\smartthings edge:drivers:install

  2. 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

17 Likes

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.

3 Likes

Good write up.

@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.

1 Like

@Mariano_Colmenarejo
NOW THIS IS EXACTLY WHAT I WAS HOPING FOR!

THANK YOU!

I can only smash the :heart: button once but if I could it would be x1000.

3 Likes

I agree but there should be something better than what was there.

1 Like

With each question and with each answer we all learn something new!!!

2 Likes

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.

Regards
Doug

3 Likes

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 :face_with_spiral_eyes:

3 Likes

Wonderful guide and well explained :+1: :+1:
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…

manufacturer: _TZ3000_vd43bbfq
 model : TS130F

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.
2 Likes

Thank you for this great intro, it is extremely helpful.
Do you have any idea how to get started with window shutter calibration (zigbee)?