Help Needed: SmartThings Edge Driver Fails to Reflect Cooling Setpoint & Temperature

I created an Edge driver for a Samsung mini-split AC with the latest capabilities. While AC mode, fan operation, and switch control work correctly, I’m facing an issue with simulating the cooling setpoint and temperature. The JSON payload is being accepted by SmartThings but the updates are not reflected on the device.

Since I couldn’t make my Edge driver discoverable, I used Tasutin’s Edge Driver V2 devices to create a virtual AC (as it’s hosted on the cloud). My plan is to later switch it over to my driver. However, when switching, the provisioning state remains stuck at Driver_Switch instead of changing to TYPED.

As mentioned, everything else works fine except for temperature simulation and cooling setpoint. Although the values are accepted, they are not being applied to the device. I’ve also observed the same behavior through the SmartThings CLI.

Could you please help me resolve this issue?

So… You can control the actual device with your driver?

I might be wrong, but the Samsung ACs are directly connected devices…

I used Tasutin’s Edge Driver V2 devices to create a virtual AC (as it’s hosted on the cloud)

No, it’s not.

Can you please post the init.lua of your driver? Add ``` before and after the code.

Edit: skip the next comment - formatted code below.

this is my int.lua

– Samsung Mini Split AC Edge Driver

-- Author: Ashwin

-- Date: August 12, 2025

local capabilities = require “st.capabilities”

local Driver = require “st.driver”

local log = require “log”

-- Driver constants

local DEVICE_PROFILE = “samsung-mini-split”

-- Initialize device with default attribute values

local function initialize_device(device)

log.info("Initializing Samsung Mini Split AC device: " .. device.device_network_id)

– airConditionerFanMode - Set default values as specified

device:emit_event(capabilities.airConditionerFanMode.fanMode(“medium”))

device:emit_event(capabilities.airConditionerFanMode.supportedAcFanModes({“auto”,“low”,“medium”,“high”,“turbo”}))

device:emit_event(capabilities.airConditionerFanMode.availableAcFanModes({“auto”,“low”,“medium”,“high”,“turbo”}))

– airConditionerMode - Set default values as specified for Lennox powered Samsung mini split

device:emit_event(capabilities.airConditionerMode.airConditionerMode(“cool”))

device:emit_event(capabilities.airConditionerMode.supportedAcModes({“auto”,“cool”,“dry”,“fan”,“heat”}))

device:emit_event(capabilities.airConditionerMode.availableAcModes({“auto”,“cool”,“dry”,“fan”,“heat”}))

– fanOscillationMode - Set default values as specified

device:emit_event(capabilities.fanOscillationMode.fanOscillationMode(“fixed”))

device:emit_event(capabilities.fanOscillationMode.supportedFanOscillationModes({“fixed”,“vertical”,“horizontal”,“all”}))

device:emit_event(capabilities.fanOscillationMode.availableFanOscillationModes({“fixed”,“vertical”,“horizontal”,“all”}))

– temperatureMeasurement - Set default temperature to 77°F

device:emit_event(capabilities.temperatureMeasurement.temperature({value = 77, unit = “F”}))

– thermostatCoolingSetpoint - Set default cooling setpoint and range

device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint({value = 69, unit = “F”}))

device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpointRange({minimum = 61, maximum = 86, step = 1, unit = “F”}))

– switch capability - default to off

device:emit_event(capabilities.switch.switch(“off”))

log.info(“Samsung Mini Split AC device initialized successfully”)

end

-- Handle device added

local function device_added(driver, device)

log.info("Device added: " .. device.device_network_id)

initialize_device(device)

end

-- Handle device initialization

local function device_init(driver, device)

log.info("Device init: " .. device.device_network_id)

initialize_device(device)

end

-- Handle driver initialization

local function driver_init(driver)

log.info(“Samsung Mini Split AC Driver initialized”)

log.info(“Driver capability handlers registered:”)

log.info("- Switch capability: " .. tostring(capabilities.switch.ID))

log.info("- AC Mode capability: " .. tostring(capabilities.airConditionerMode.ID))

log.info("- Cooling Setpoint capability: " .. tostring(capabilities.thermostatCoolingSetpoint.ID))

– Run discovery immediately when driver starts

discovery_handler(driver, {}, function() return false end)

end

-- Handle switch on command

local function handle_switch_on(driver, device, command)

log.info(“Handling switch on command”)

device:emit_event(capabilities.switch.switch(“on”))

– When turning on, ensure we have the proper AC mode and fan mode

device:emit_event(capabilities.airConditionerMode.airConditionerMode(“cool”))

device:emit_event(capabilities.airConditionerFanMode.fanMode(“medium”))

end

-- Handle switch off command

local function handle_switch_off(driver, device, command)

log.info(“Handling switch off command”)

device:emit_event(capabilities.switch.switch(“off”))

end

-- Handle air conditioner mode change for Lennox powered Samsung mini split

local function handle_ac_mode_change(driver, device, command)

local mode = command.args.mode

log.info("Changing AC mode to: " .. mode)

local supported_modes = {“auto”, “cool”, “dry”, “fan”, “heat”}

– Validate the mode

for _, supported_mode in ipairs(supported_modes) do

if supported_mode == mode then

  device:emit_event(capabilities.airConditionerMode.airConditionerMode(mode))

  

  -- If switching to a mode, ensure the unit is on

  device:emit_event(capabilities.switch.switch("on"))

  return

end

end

log.warn("Unsupported AC mode: " .. mode)

end

-- Handle fan mode change

local function handle_fan_mode_change(driver, device, command)

local fan_mode = command.args.fanMode

log.info("Changing fan mode to: " .. fan_mode)

local supported_fan_modes = {“auto”, “low”, “medium”, “high”, “turbo”}

– Validate the fan mode

for _, supported_mode in ipairs(supported_fan_modes) do

if supported_mode == fan_mode then

  device:emit_event(capabilities.airConditionerFanMode.fanMode(fan_mode))

  

  -- If changing fan mode, ensure the unit is on

  device:emit_event(capabilities.switch.switch("on"))

  return

end

end

log.warn("Unsupported fan mode: " .. fan_mode)

end

-- Handle fan oscillation mode change

local function handle_oscillation_mode_change(driver, device, command)

local oscillation_mode = command.args.fanOscillationMode

log.info("Changing oscillation mode to: " .. oscillation_mode)

local supported_oscillation_modes = {“fixed”, “vertical”, “horizontal”, “all”}

– Validate the oscillation mode

for _, supported_mode in ipairs(supported_oscillation_modes) do

if supported_mode == oscillation_mode then

  device:emit_event(capabilities.fanOscillationMode.fanOscillationMode(oscillation_mode))

  return

end

end

log.warn("Unsupported oscillation mode: " .. oscillation_mode)

end

-- Handle cooling setpoint change

local function handle_cooling_setpoint_change(driver, device, command)

log.info(“=== COOLING SETPOINT HANDLER CALLED ===”)

log.info("Command received: " .. (command and “YES” or “NO”))

log.info("Command args: " .. (command.args and “YES” or “NO”))

local setpoint = command.args.setpoint or command.args.value

log.info("Raw setpoint value: " .. tostring(setpoint))

log.info("Setpoint type: " .. type(setpoint))

log.info("Changing cooling setpoint to: " .. setpoint .. “°F”)

– Validate setpoint is within range (61-86°F)

if setpoint and setpoint >= 61 and setpoint <= 86 then

log.info("Setpoint is within valid range, emitting event...")



-- Try different emission formats

local temp_event = capabilities.thermostatCoolingSetpoint.coolingSetpoint({value = setpoint, unit = "F"})

log.info("Event object created: " .. tostring(temp_event))

device:emit_event(temp_event)

log.info("Cooling setpoint event emitted successfully")



-- Also try emitting without unit

device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint(setpoint))

log.info("Alternative cooling setpoint event emitted")



-- If changing setpoint, ensure the unit is on and in cool mode

device:emit_event(capabilities.switch.switch("on"))

device:emit_event(capabilities.airConditionerMode.airConditionerMode("cool"))

log.info("Switch and AC mode events emitted")

else

log.warn("Setpoint out of range or missing: " .. tostring(setpoint) .. " (valid range: 61-86°F)")

end

log.info(“=== COOLING SETPOINT HANDLER COMPLETED ===”)

end

-- Handle refresh command

local function handle_refresh(driver, device, command)

log.info(“Refreshing device state”)

initialize_device(device)

end

-- Device discovery function

local function discovery_handler(driver, opts, should_continue)

log.info(“Starting Samsung Mini Split AC discovery”)

– Create a mock device for demonstration

– In a real implementation, this would scan for actual devices

local device_metadata = {

type = "LAN",

device_network_id = "samsung-mini-split-001",

label = "Samsung Mini Split AC",

profile = DEVICE_PROFILE,

manufacturer = "Samsung",

model = "Mini Split AC",

vendor_provided_label = "Samsung Mini Split Air Conditioner"

}

log.info("Creating Samsung Mini Split AC device with metadata: " .. device_metadata.device_network_id)

local device = driver:try_create_device(device_metadata)

if device then

log.info("Successfully created Samsung Mini Split AC device")

else

log.error("Failed to create Samsung Mini Split AC device")

end

end

-- Create the driver

local samsung_mini_split_driver = Driver(“SamsungMiniSplitDriver”, {

discovery = discovery_handler,

lifecycle_handlers = {

init = driver_init,

added = device_added,

driverSwitched = device_init

},

capability_handlers = {

\[capabilities.switch.ID\] = {

  \[capabilities.switch.commands.on.NAME\] = handle_switch_on,

  \[capabilities.switch.commands.off.NAME\] = handle_switch_off

},

\[capabilities.airConditionerMode.ID\] = {

  \[capabilities.airConditionerMode.commands.setAirConditionerMode.NAME\] = handle_ac_mode_change

},

\[capabilities.airConditionerFanMode.ID\] = {

  \[capabilities.airConditionerFanMode.commands.setFanMode.NAME\] = handle_fan_mode_change

},

\[capabilities.fanOscillationMode.ID\] = {

  \[capabilities.fanOscillationMode.commands.setFanOscillationMode.NAME\] = handle_oscillation_mode_change

},

\[capabilities.thermostatCoolingSetpoint.ID\] = {

  \[capabilities.thermostatCoolingSetpoint.commands.setCoolingSetpoint.NAME\] = handle_cooling_setpoint_change

},

\[capabilities.refresh.ID\] = {

  \[capabilities.refresh.commands.refresh.NAME\] = handle_refresh

}

}

})

-- Run the driver

samsung_mini_split_driver:run()

I don’t have project access for Taustin’s workspace , i have access only for the driver channel
got it from Youtube Youtube

Channel Invitation for Edge Driver: https://api.smartthings.com/invitatio…

Readable:

– Samsung Mini Split AC Edge Driver

-- Author: Ashwin

-- Date: August 12, 2025

local capabilities = require “st.capabilities”

local Driver = require “st.driver”

local log = require “log”

-- Driver constants

local DEVICE_PROFILE = “samsung-mini-split”

-- Initialize device with default attribute values

local function initialize_device(device)

  log.info("Initializing Samsung Mini Split AC device: " .. device.device_network_id)

  – airConditionerFanMode - Set default values as specified

  device:emit_event(capabilities.airConditionerFanMode.fanMode(“medium”))

  device:emit_event(capabilities.airConditionerFanMode.supportedAcFanModes({“auto”,“low”,“medium”,“high”,“turbo”}))

  device:emit_event(capabilities.airConditionerFanMode.availableAcFanModes({“auto”,“low”,“medium”,“high”,“turbo”}))

  – airConditionerMode - Set default values as specified for Lennox powered Samsung mini split

  device:emit_event(capabilities.airConditionerMode.airConditionerMode(“cool”))

  device:emit_event(capabilities.airConditionerMode.supportedAcModes({“auto”,“cool”,“dry”,“fan”,“heat”}))

  device:emit_event(capabilities.airConditionerMode.availableAcModes({“auto”,“cool”,“dry”,“fan”,“heat”}))

  – fanOscillationMode - Set default values as specified

  device:emit_event(capabilities.fanOscillationMode.fanOscillationMode(“fixed”))

  device:emit_event(capabilities.fanOscillationMode.supportedFanOscillationModes({“fixed”,“vertical”,“horizontal”,“all”}))

  device:emit_event(capabilities.fanOscillationMode.availableFanOscillationModes({“fixed”,“vertical”,“horizontal”,“all”}))

  – temperatureMeasurement - Set default temperature to 77°F

  device:emit_event(capabilities.temperatureMeasurement.temperature({value = 77, unit = “F”}))

  – thermostatCoolingSetpoint - Set default cooling setpoint and range

  device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint({value = 69, unit = “F”}))

  device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpointRange({minimum = 61, maximum = 86, step = 1, unit = “F”}))

  – switch capability - default to off

  device:emit_event(capabilities.switch.switch(“off”))

  log.info(“Samsung Mini Split AC device initialized successfully”))

end

-- Handle device added

local function device_added(driver, device)

  log.info("Device added: " .. device.device_network_id)

  initialize_device(device)

end

-- Handle device initialization

local function device_init(driver, device)

  log.info("Device init: " .. device.device_network_id)

  initialize_device(device)

end

-- Handle driver initialization

local function driver_init(driver)

  log.info(“Samsung Mini Split AC Driver initialized”)

  log.info(“Driver capability handlers registered:”)

  log.info("- Switch capability: " .. tostring(capabilities.switch.ID))

  log.info("- AC Mode capability: " .. tostring(capabilities.airConditionerMode.ID))

  log.info("- Cooling Setpoint capability: " .. tostring(capabilities.thermostatCoolingSetpoint.ID))

  – Run discovery immediately when driver starts

  discovery_handler(driver, {}, function() return false end)

end

-- Handle switch on command

local function handle_switch_on(driver, device, command)

  log.info(“Handling switch on command”)

  device:emit_event(capabilities.switch.switch(“on”))

  – When turning on, ensure we have the proper AC mode and fan mode

  device:emit_event(capabilities.airConditionerMode.airConditionerMode(“cool”))

  device:emit_event(capabilities.airConditionerFanMode.fanMode(“medium”))

end

-- Handle switch off command

local function handle_switch_off(driver, device, command)

  log.info(“Handling switch off command”)

  device:emit_event(capabilities.switch.switch(“off”))

end

-- Handle air conditioner mode change for Lennox powered Samsung mini split

local function handle_ac_mode_change(driver, device, command)

  local mode = command.args.mode

  log.info("Changing AC mode to: " .. mode)

  local supported_modes = {“auto”, “cool”, “dry”, “fan”, “heat”}

  – Validate the mode

  for _, supported_mode in ipairs(supported_modes) do

    if supported_mode == mode then

      device:emit_event(capabilities.airConditionerMode.airConditionerMode(mode))

      -- If switching to a mode, ensure the unit is on

      device:emit_event(capabilities.switch.switch("on"))

      return

    end

  end

  log.warn("Unsupported AC mode: " .. mode)

end

-- Handle fan mode change

local function handle_fan_mode_change(driver, device, command)

  local fan_mode = command.args.fanMode

  log.info("Changing fan mode to: " .. fan_mode)

  local supported_fan_modes = {“auto”, “low”, “medium”, “high”, “turbo”}

  – Validate the fan mode

  for _, supported_mode in ipairs(supported_fan_modes) do

    if supported_mode == fan_mode then

      device:emit_event(capabilities.airConditionerFanMode.fanMode(fan_mode))

      -- If changing fan mode, ensure the unit is on

      device:emit_event(capabilities.switch.switch("on"))

      return

    end

  end

  log.warn("Unsupported fan mode: " .. fan_mode)

end

-- Handle fan oscillation mode change

local function handle_oscillation_mode_change(driver, device, command)

  local oscillation_mode = command.args.fanOscillationMode

  log.info("Changing oscillation mode to: " .. oscillation_mode)

  local supported_oscillation_modes = {“fixed”, “vertical”, “horizontal”, “all”}

  – Validate the oscillation mode

  for _, supported_mode in ipairs(supported_oscillation_modes) do

    if supported_mode == oscillation_mode then

      device:emit_event(capabilities.fanOscillationMode.fanOscillationMode(oscillation_mode))

      return

    end

  end

  log.warn("Unsupported oscillation mode: " .. oscillation_mode)

end

-- Handle cooling setpoint change

local function handle_cooling_setpoint_change(driver, device, command)

  log.info(“=== COOLING SETPOINT HANDLER CALLED ===”)

  log.info("Command received: " .. (command and “YES” or “NO”))

  log.info("Command args: " .. (command.args and “YES” or “NO”))

  local setpoint = command.args.setpoint or command.args.value

  log.info("Raw setpoint value: " .. tostring(setpoint))

  log.info("Setpoint type: " .. type(setpoint))

  log.info("Changing cooling setpoint to: " .. setpoint .. “°F”)

  – Validate setpoint is within range (61-86°F)

  if setpoint and setpoint >= 61 and setpoint <= 86 then

    log.info("Setpoint is within valid range, emitting event...")

    -- Try different emission formats

    local temp_event = capabilities.thermostatCoolingSetpoint.coolingSetpoint({value = setpoint, unit = "F"})

    log.info("Event object created: " .. tostring(temp_event))

    device:emit_event(temp_event)

    log.info("Cooling setpoint event emitted successfully")

    -- Also try emitting without unit

    device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint(setpoint))

    log.info("Alternative cooling setpoint event emitted")

    -- If changing setpoint, ensure the unit is on and in cool mode

    device:emit_event(capabilities.switch.switch("on"))

    device:emit_event(capabilities.airConditionerMode.airConditionerMode("cool"))

    log.info("Switch and AC mode events emitted")

  else

    log.warn("Setpoint out of range or missing: " .. tostring(setpoint) .. " (valid range: 61-86°F)")

  end

  log.info(“=== COOLING SETPOINT HANDLER COMPLETED ===”)

end

-- Handle refresh command

local function handle_refresh(driver, device, command)

  log.info(“Refreshing device state”)

  initialize_device(device)

end

-- Device discovery function

local function discovery_handler(driver, opts, should_continue)

  log.info(“Starting Samsung Mini Split AC discovery”)

  – Create a mock device for demonstration

  – In a real implementation, this would scan for actual devices

  local device_metadata = {

    type = "LAN",

    device_network_id = "samsung-mini-split-001",

    label = "Samsung Mini Split AC",

    profile = DEVICE_PROFILE,

    manufacturer = "Samsung",

    model = "Mini Split AC",

    vendor_provided_label = "Samsung Mini Split Air Conditioner"

  }

  log.info("Creating Samsung Mini Split AC device with metadata: " .. device_metadata.device_network_id)

  local device = driver:try_create_device(device_metadata)

  if device then

    log.info("Successfully created Samsung Mini Split AC device")

  else

    log.error("Failed to create Samsung Mini Split AC device")

  end

end

-- Create the driver

local samsung_mini_split_driver = Driver(“SamsungMiniSplitDriver”, {

  discovery = discovery_handler,

  lifecycle_handlers = {

    init = driver_init,

    added = device_added,

    driverSwitched = device_init

  },

  capability_handlers = {

    [capabilities.switch.ID] = {

      [capabilities.switch.commands.on.NAME] = handle_switch_on,

      [capabilities.switch.commands.off.NAME] = handle_switch_off

    },

    [capabilities.airConditionerMode.ID] = {

      [capabilities.airConditionerMode.commands.setAirConditionerMode.NAME] = handle_ac_mode_change

    },

    [capabilities.airConditionerFanMode.ID] = {

      [capabilities.airConditionerFanMode.commands.setFanMode.NAME] = handle_fan_mode_change

    },

    [capabilities.fanOscillationMode.ID] = {

      [capabilities.fanOscillationMode.commands.setFanOscillationMode.NAME] = handle_oscillation_mode_change

    },

    [capabilities.thermostatCoolingSetpoint.ID] = {

      [capabilities.thermostatCoolingSetpoint.commands.setCoolingSetpoint.NAME] = handle_cooling_setpoint_change

    },

    [capabilities.refresh.ID] = {

      [capabilities.refresh.commands.refresh.NAME] = handle_refresh

    }

  }

})

-- Run the driver

samsung_mini_split_driver:run()

There’s an entire part missing where you actually talk to the device.

Correct me if I’m wrong, but these are directly connected devices—they communicate with the cloud, if I recall correctly.

If it were that simple, someone would have already written a driver.

I’m trying to create a virtual device of a Samsung mini split AC for testing a multi-device scenario.

You should have mentioned that from the start…

Kindly support me to fix it

There’s so much wrong with your code…

Why do you call the discovery function in the init lifecycle?

Why an extra function to initialize the device?

There’s a log.info(“…”))- double ))

This is how you usually, correctly set a cooling setpoint:

device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = setpoint, unit = "F" }))

Why a lifecycle driverSwitched?

The driver log must be a mess…

How to fix this, I’m new to SmartThings Edge driver creation

check this out
– Samsung Mini Split AC Edge Driver
– Author: Ashwin (fixed)
– Date: August 12, 2025

local capabilities = require “st.capabilities”
local Driver = require “st.driver”
local log = require “log”

– Driver constants
local DEVICE_PROFILE = “samsung-mini-split” – must match your profile name in resources

– --------- helpers ---------
local function dev_tag(device)
– Safe tag for logs; Edge devices may not expose device_network_id
return string.format(“[%s | %s]”, device.label or “Device”, device.id or “no-id”)
end

local function temp_unit(device)
– Keep a single unit consistently; adjust if you add a preference later
return “F”
end

– Initialize device with default attribute values
local function initialize_device(device)
log.info(string.format(“Initializing device %s”, dev_tag(device)))

– airConditionerFanMode
device:emit_event(capabilities.airConditionerFanMode.fanMode(“medium”))
device:emit_event(capabilities.airConditionerFanMode.supportedAcFanModes({“auto”,“low”,“medium”,“high”,“turbo”}))

– airConditionerMode
device:emit_event(capabilities.airConditionerMode.airConditionerMode(“cool”))
device:emit_event(capabilities.airConditionerMode.supportedAcModes({“auto”,“cool”,“dry”,“fan”,“heat”}))

– fanOscillationMode
device:emit_event(capabilities.fanOscillationMode.fanOscillationMode(“fixed”))
device:emit_event(capabilities.fanOscillationMode.supportedFanOscillationModes({“fixed”,“vertical”,“horizontal”,“all”}))

– temperatureMeasurement
device:emit_event(capabilities.temperatureMeasurement.temperature({ value = 77, unit = temp_unit(device) }))

– thermostatCoolingSetpoint (emit once, with unit)
device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = 69, unit = temp_unit(device) }))

– switch
device:emit_event(capabilities.switch.switch(“off”))

log.info(string.format(“Device initialized %s”, dev_tag(device)))
end

– Handle device added
local function device_added(driver, device)
log.info("Device added " .. dev_tag(device))
initialize_device(device)
end

– Handle device initialization (also used after driver switch)
local function device_init(driver, device)
log.info("Device init " .. dev_tag(device))
initialize_device(device)
end

– Handle switch on/off
local function handle_switch_on(driver, device, command)
log.info("Switch ON " .. dev_tag(device))
device:emit_event(capabilities.switch.switch(“on”))
device:emit_event(capabilities.airConditionerMode.airConditionerMode(“cool”))
device:emit_event(capabilities.airConditionerFanMode.fanMode(“medium”))
end

local function handle_switch_off(driver, device, command)
log.info("Switch OFF " .. dev_tag(device))
device:emit_event(capabilities.switch.switch(“off”))
end

– AC mode change
local function handle_ac_mode_change(driver, device, command)
local mode = command and command.args and command.args.mode
log.info(string.format(“Set AC mode → %s %s”, tostring(mode), dev_tag(device)))

local allowed = { auto=true, cool=true, dry=true, fan=true, heat=true }
if allowed[mode] then
device:emit_event(capabilities.airConditionerMode.airConditionerMode(mode))
device:emit_event(capabilities.switch.switch(“on”))
else
log.warn("Unsupported AC mode: " .. tostring(mode))
end
end

– Fan mode change
local function handle_fan_mode_change(driver, device, command)
local fm = command and command.args and command.args.fanMode
log.info(string.format(“Set Fan mode → %s %s”, tostring(fm), dev_tag(device)))

local allowed = { auto=true, low=true, medium=true, high=true, turbo=true }
if allowed[fm] then
device:emit_event(capabilities.airConditionerFanMode.fanMode(fm))
device:emit_event(capabilities.switch.switch(“on”))
else
log.warn("Unsupported fan mode: " .. tostring(fm))
end
end

– Oscillation mode change
local function handle_oscillation_mode_change(driver, device, command)
local om = command and command.args and command.args.fanOscillationMode
log.info(string.format(“Set Oscillation → %s %s”, tostring(om), dev_tag(device)))

local allowed = { fixed=true, vertical=true, horizontal=true, all=true }
if allowed[om] then
device:emit_event(capabilities.fanOscillationMode.fanOscillationMode(om))
else
log.warn("Unsupported oscillation mode: " .. tostring(om))
end
end

– Cooling setpoint change
local function handle_cooling_setpoint_change(driver, device, command)
log.info("=== COOLING SETPOINT HANDLER === " .. dev_tag(device))
local sp = nil

– Capability schema uses ‘setpoint’; some UIs send ‘value’
if command and command.args then
sp = command.args.setpoint or command.args.value
end

log.info("Requested setpoint: " .. tostring(sp))

– Validate range (61–86F). Adjust if you later add a preference.
if type(sp) == “number” and sp >= 61 and sp <= 86 then
device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = sp, unit = temp_unit(device) }))

-- Optional: keep temperatureMeasurement loosely in sync to reflect changes
-- (remove this if your physical device reports actual room temp)
-- device:emit_event(capabilities.temperatureMeasurement.temperature({ value = sp, unit = temp_unit(device) }))

device:emit_event(capabilities.switch.switch("on"))
device:emit_event(capabilities.airConditionerMode.airConditionerMode("cool"))
log.info("Cooling setpoint updated")

else
log.warn(“Setpoint out of range or invalid: " .. tostring(sp) .. " (valid 61–86°F)”)
end
end

– Refresh
local function handle_refresh(driver, device, command)
log.info("Refresh requested " .. dev_tag(device))
initialize_device(device)
end

– Discovery
local function discovery_handler(driver, opts, should_continue)
log.info(“Starting discovery…”)

– If you already have a device, skip creating duplicates
local existing = false
for _, d in ipairs(driver:get_devices()) do
if d.device_network_id == “samsung-mini-split-001” or d.label == “Samsung Mini Split AC” then
existing = true
break
end
end
if existing then
log.info(“Device already exists; skipping creation”)
return
end

local metadata = {
type = “LAN”,
device_network_id = “samsung-mini-split-001”,
label = “Samsung Mini Split AC”,
profile = DEVICE_PROFILE,
manufacturer = “Samsung”,
model = “Mini Split AC”,
vendor_provided_label = “Samsung Mini Split Air Conditioner”,
}

local ok, err = pcall(function() driver:try_create_device(metadata) end)
if ok then
log.info(“Device created”)
else
log.error("Device creation failed: " .. tostring(err))
end
end

– Driver init (do NOT force discovery here; the framework will call discovery)
local function driver_init(driver)
log.info(“Samsung Mini Split AC Driver initialized”)
log.info(“- Switch capability: " .. tostring(capabilities.switch.ID))
log.info(”- AC Mode capability: " .. tostring(capabilities.airConditionerMode.ID))
log.info("- Cooling Setpoint capability: " .. tostring(capabilities.thermostatCoolingSetpoint.ID))
end

– Build the driver
local samsung_mini_split_driver = Driver(“SamsungMiniSplitDriver”, {
discovery = discovery_handler,
lifecycle_handlers = {
init = driver_init,
added = device_added,
driverSwitched = device_init, – re-init after migration
},
capability_handlers = {
[capabilities.switch.ID] = {
[capabilities.switch.commands.on.NAME] = handle_switch_on,
[capabilities.switch.commands.off.NAME] = handle_switch_off,
},
[capabilities.airConditionerMode.ID] = {
[capabilities.airConditionerMode.commands.setAirConditionerMode.NAME] = handle_ac_mode_change,
},
[capabilities.airConditionerFanMode.ID] = {
[capabilities.airConditionerFanMode.commands.setFanMode.NAME] = handle_fan_mode_change,
},
[capabilities.fanOscillationMode.ID] = {
[capabilities.fanOscillationMode.commands.setFanOscillationMode.NAME] = handle_oscillation_mode_change,
},
[capabilities.thermostatCoolingSetpoint.ID] = {
[capabilities.thermostatCoolingSetpoint.commands.setCoolingSetpoint.NAME] = handle_cooling_setpoint_change,
},
[capabilities.refresh.ID] = {
[capabilities.refresh.commands.refresh.NAME] = handle_refresh,
},
}
})

– Run the driver
samsung_mini_split_driver:run()

Nope, I’m not doing a code review until it runs properly. Your turn to work on it again for a few hours.

Your whole code looks like it’s AI generated…

Hi, @Ashwin

You should start with a basic structure that works. This is a sample of a switch, it’s a LAN driver but in the end, it’s an instance simulating a switch.

There, you would need to add the corresponding capabilities to the profile and then, initialize them accordingly.

If you don’t see changes in the app after you modified something in the profile, we suggest you change the network ID and device label to force an update.

Generally, adding new capabilities will force an update for the device presentation, but just in case.
Remember the networkID must be unique, so, if the device isn’t discovered, check first that the networkID doesn’t exist yet for another device.

Thank you, it will be very useful

@Andreas_Roedl @nayelyz Created virtual AC
with my driver alone the provision state is also changes to TYPED

but same issue Unable to set temperature and cooling setpoint , commands are getting accepted through CLI , but for temperature it shows no command

local capabilities = require “st.capabilities”

local Driver = require “st.driver”

local log = require “log”

local cosock = require “cosock”

local socket = require “cosock.socket” – sleep + time

local DEVICE_PROFILE = “samsung-mini-split”

-- RNG seed for unique DNIs (time-based + random)

do

local seed = math.floor((socket.gettime() or os.time()) * 1e6) % 0x7fffffff

math.randomseed(seed)

end

-- ---------- helpers ----------

local dni_counter = 0 – static counter to ensure uniqueness

local function new_dni()

dni_counter = dni_counter + 1

local timestamp = socket.gettime() or os.time() – microsecond precision if available

local ms = math.floor((timestamp * 1000) % 1000) – extract milliseconds

return string.format(“mini-split-%d-%03d-%04d”,

math.floor(timestamp), ms, dni_counter % 10000)

end

-- ---------- default attributes ----------

local function initialize_device(device)

device:emit_event(capabilities.switch.switch(“off”))

device:emit_event(capabilities.airConditionerMode.airConditionerMode(“cool”))

device:emit_event(capabilities.airConditionerMode.supportedAcModes({“auto”,“cool”,“dry”,“fan”,“heat”}))

device:emit_event(capabilities.airConditionerFanMode.fanMode(“medium”))

device:emit_event(capabilities.airConditionerFanMode.supportedAcFanModes({“auto”,“low”,“medium”,“high”,“turbo”}))

device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = 69, unit = “F” }))

device:emit_event(capabilities.temperatureMeasurement.temperature({ value = 77, unit = “F” }))

end

-- ---------- lifecycle (per-device) ----------

local function device_added(driver, device)

log.info(“[” .. device.id .. “] Adding new Samsung Mini Split device”)

initialize_device(device)

end

local function device_init(driver, device)

log.info(“[” .. device.id .. “] Initializing Samsung Mini Split device”)

device:online() – mark device as online like the official example

initialize_device(device)

end

-- ---------- commands ----------

local function handle_switch_on (driver, device, cmd) device:emit_event(capabilities.switch.switch(“on”)) end

local function handle_switch_off(driver, device, cmd) device:emit_event(capabilities.switch.switch(“off”)) end

local function handle_set_cooling(driver, device, cmd)

local sp = tonumber(cmd.args.setpoint or cmd.args.value)

if sp and sp >= 61 and sp <= 86 then

device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = sp, unit = "F" }))

else

log.warn("Cooling setpoint out of range: " .. tostring(sp))

end

end

-- ---------- discovery (for Scan Nearby) ----------

-- handle discovery events, normally you’d try to discover devices on your

-- network in a loop until calling `should_continue()` returns false.

local function discovery_handler(driver, _should_continue)

log.info(“Starting Samsung Mini Split Discovery”)

– Check if we already have a Samsung Mini Split device

for _, device in ipairs(driver:get_devices()) do

if device.profile and device.profile.name == "samsung-mini-split" then

  log.info("Samsung Mini Split device already exists: " .. device.device_network_id)

  return  -- Don't create duplicate

end

end

local dni = new_dni()

log.info("Creating device with unique DNI: " .. dni)

local metadata = {

type = "LAN",

-- the DNI must be unique across your hub, using dynamic ID here

device_network_id = dni,

label = "Samsung Mini Split AC",

profile = "samsung-mini-split",

manufacturer = "Samsung",

model = "Mini Split",

vendor_provided_label = nil

}

– tell the cloud to create a new device record, will get synced back down

– and `device_added` and `device_init` callbacks will be called

driver:try_create_device(metadata)

log.info("Device creation requested with DNI: " .. dni)

end

-- ---------- driver object ----------

local driver = Driver(“SamsungMiniSplitDriver”, {

discovery = discovery_handler,

lifecycle_handlers = {

added = device_added,

init = device_init,

driverSwitched = device_init,

},

capability_handlers = {

\[capabilities.switch.ID\] = {

  \[capabilities.switch.commands.on.NAME\]  = handle_switch_on,

  \[capabilities.switch.commands.off.NAME\] = handle_switch_off

},

\[capabilities.thermostatCoolingSetpoint.ID\] = {

  \[capabilities.thermostatCoolingSetpoint.commands.setCoolingSetpoint.NAME\] = handle_set_cooling

}

}

})

-- run the driver

log.info(“DRIVER: Starting Samsung Mini Split driver”)

driver:run()

Hi, @Ashwin

Is it possible for you to upload your code to a Github repository and share it with me? If it has sensitive information, you can share it only with my user nayelyzarazua-bluetrail

I want to use your exact configuration to check on my side what might be incorrect.

Also, something important is checking the driver logs to see if there’s an error message shown.

Are you listening for the driver logs with the command below?

smartthings edge:drivers:logcat

will share shortly, I’m not seeing it because I’m accessing the from remote.
HUB is on different network , so i can’t see smartthings edge:drivers:logcat

@nayelyz

shared repo

What do you mean?

HUB is on different network , so i can’t see smartthings edge:drivers:logcat

I see…

It’s absolutely impossible to develop a driver without access to the driver logs.

Everything I mentioned above would show up in the logs. Your driver wouldn’t even run in this state.

Is it a remote job, a personal project or what?