Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions drivers/DeepSmart/deepsmart/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'DEEPSMART KNX GATEWAY'
packageKey: 'DEEPSMART-KNX.GATEWAY'
permissions:
lan: {}
discovery: {}
22 changes: 22 additions & 0 deletions drivers/DeepSmart/deepsmart/profiles/Ac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Ac.v1
components:
- id: main
capabilities:
- id: switch
version: 1
- id: temperatureMeasurement
version: 1
- id: thermostatHeatingSetpoint
version: 1
config:
values:
- key: "heatingSetpoint.value"
range: [ 16, 30 ]
- id: airConditionerMode
version: 1
- id: airConditionerFanMode
version: 1
- id: refresh
version: 1
categories:
- name: AirConditioner
8 changes: 8 additions & 0 deletions drivers/DeepSmart/deepsmart/profiles/Deepsmart-bridge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Deepsmart.bridge
components:
- id: main
capabilities:
- id: refresh
version: 1
categories:
- name: Bridges
20 changes: 20 additions & 0 deletions drivers/DeepSmart/deepsmart/profiles/Heater.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Heater.v1
components:
- id: main
capabilities:
- id: temperatureMeasurement
version: 1
- id: thermostatOperatingState
version: 1
- id: thermostatMode
version: 1
- id: thermostatHeatingSetpoint
version: 1
config:
values:
- key: "heatingSetpoint.value"
range: [ 5, 35 ]
- id: refresh
version: 1
categories:
- name: Thermostat
18 changes: 18 additions & 0 deletions drivers/DeepSmart/deepsmart/profiles/Hue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Hue.v1
components:
- id: main
capabilities:
- id: switch
version: 1
- id: switchLevel
version: 1
- id: colorTemperature
version: 1
- id: refresh
version: 1
categories:
- name: Light
metadata:
deviceType: Light
ocfDeviceType: oic.d.light
deviceTypeId: Light
14 changes: 14 additions & 0 deletions drivers/DeepSmart/deepsmart/profiles/Light.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Light.v1
components:
- id: main
capabilities:
- id: switch
version: 1
- id: refresh
version: 1
categories:
- name: Light
metadata:
deviceType: Light
ocfDeviceType: oic.d.light
deviceTypeId: Light
12 changes: 12 additions & 0 deletions drivers/DeepSmart/deepsmart/profiles/Newfan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Newfan.v1
components:
- id: main
capabilities:
- id: switch
version: 1
- id: airConditionerFanMode
version: 1
- id: refresh
version: 1
categories:
- name: Vent
16 changes: 16 additions & 0 deletions drivers/DeepSmart/deepsmart/profiles/Slider.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Slider.v1
components:
- id: main
capabilities:
- id: switch
version: 1
- id: switchLevel
version: 1
- id: refresh
version: 1
categories:
- name: Light
metadata:
deviceType: Light
ocfDeviceType: oic.d.light
deviceTypeId: Light
2 changes: 2 additions & 0 deletions drivers/DeepSmart/deepsmart/search-parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ssdp:
- searchTerm: "DEEPSMART-ARM"
171 changes: 171 additions & 0 deletions drivers/DeepSmart/deepsmart/src/commands.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
local caps = require('st.capabilities')
local log = require('log')

local config = require('config')
local wisers = require('deepsmart.wisers')

local command_handler = {}

------------------
-- Refresh command
function command_handler.refresh(_, device)
local bridge_id = device.device_network_id
local parent_assigned_child_key = device.parent_assigned_child_key
local success = false
local is_bridge = wisers.is_device_bridge(device)
log.info('refresh bridge '..bridge_id..' device')
if (not is_bridge) then
success = wisers.refresh(device)
log.info('hub refresh device '..parent_assigned_child_key)
else
-- reload wiser devices
wisers.refresh_wiser(bridge_id)
log.info('hub refresh device '..bridge_id)
end
-- Check success
if success then
-- Define online status
device:online()
else
log.error('failed to poll device state')
-- Set device as offline
device:offline()
end
end

----------------
-- Switch command
----------------
function command_handler.set_switch(_, device, command)
local on_off = command.command
log.info('hub control device '..device.parent_assigned_child_key..' onoff '..on_off)
-- gt devtype
local devtype = wisers.get_dev_type(device)
local addrtypes = {}
-- get devtype onoff addrtype
if (devtype == config.ENUM.AC or devtype == config.ENUM.HEATER or devtype == config.ENUM.NEWFAN or devtype == config.ENUM.SWITCH or devtype == config.ENUM.SLIDER or devtype == config.ENUM.HUE) then
addrtypes[1] = config.DEVICE.ONOFF
else
addrtypes[1] = 0
end
-- send command
local success = wisers.control(device, command, addrtypes)
-- Check if success
if success then
if on_off == 'off' then
return device:emit_event(caps.switch.switch.off())
end
return device:emit_event(caps.switch.switch.on())
end
log.error('no response from device')
return 0
end

----------------
-- Switch level command
----------------
function command_handler.set_level(_, device, command)
local lvl = command.args.level
local success = wisers.control(device, command, {config.SLIDER.BRIGHT})
-- Check if success
if success then
if lvl == 0 then
device:emit_event(caps.switch.switch.off())
else
device:emit_event(caps.switch.switch.on())
end
device:emit_event(caps.switchLevel.level(lvl))
return
end
log.error('no response from device')
end

----------------
-- Color control command
----------------
function command_handler.set_color(_, device, command)
local success = wisers.control(device, command, {config.HUE.HUE})

-- Check if success
if success then
device:emit_event(caps.switch.switch.on())
device:emit_event(caps.colorTemperature.colorTemperature(command.args.temperature))
return
end
log.error('no response from device')
end

----------------
-- fan mode command
----------------
function command_handler.set_thermostat_fan_mode(driver, device, command)
local devtype = wisers.get_dev_type(device)
local addrtypes = {}
if (devtype == config.ENUM.AC) then
addrtypes[1] = config.AC.FAN
elseif devtype == config.ENUM.NEWFAN then
addrtypes[1] = config.NEWFAN.FAN
end
local success = wisers.control(device, command, addrtypes)
-- Check if success
if success then
return device:emit_event(caps.airConditionerFanMode.fanMode(command.args.fanMode))
end
log.error('no response from device')
return 0
end

----------------
-- mode command
----------------
function command_handler.set_airconditioner_mode(driver, device, command)
local success = wisers.control(device, command, {config.AC.MODE})
-- Check if success
if success then
return device:emit_event(caps.airConditionerMode.airConditionerMode(command.args.mode))
end
log.error('no response from device')
end

----------------
-- heater mode command
----------------
function command_handler.set_thermostat_mode(driver, device, command)
-- send command
local success = wisers.control(device, command, {config.HEATER.ONOFF})
-- Check if success
if success then
if command.args.mode == 'off' then
device:emit_event(caps.thermostatMode.thermostatMode.off())
device:emit_event(caps.thermostatOperatingState.thermostatOperatingState.idle())
else
device:emit_event(caps.thermostatMode.thermostatMode.heat())
device:emit_event(caps.thermostatOperatingState.thermostatOperatingState.heating())
end
return
end
log.error('no response from device')
return 0
end

----------------
-- set heating point command
----------------
function command_handler.set_setheatingpoint(driver, device, command)
local devtype = wisers.get_dev_type(device)
local addrtypes = {}
if (devtype == config.ENUM.AC) then
addrtypes[1] = config.AC.SETTEMP
elseif devtype == config.ENUM.HEATER then
addrtypes[1] = config.HEATER.SETTEMP
end
local success = wisers.control(device, command, addrtypes)
-- Check if success
if success then
return device:emit_event(caps.thermostatHeatingSetpoint.heatingSetpoint({value=command.args.setpoint,unit='C'}))
end
log.error('no response from device')
end


return command_handler
70 changes: 70 additions & 0 deletions drivers/DeepSmart/deepsmart/src/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
local config = {}
-- device info
-- NOTE: In the future this information
-- may be submitted through the Developer
-- Workspace to avoid hardcoded values.
config.DEVICE_PROFILE={}
config.DEVICE_PROFILE[3]='Ac.v1'
config.DEVICE_PROFILE[4]='Heater.v1'
config.DEVICE_PROFILE[14]='Light.v1'
config.DEVICE_PROFILE[16]='Slider.v1'
config.DEVICE_PROFILE[39]='Slider.v1'
config.DEVICE_PROFILE[25]='Hue.v1'
config.DEVICE_PROFILE[38]='Hue.v1'
config.DEVICE_PROFILE[53]='Newfan.v1'
config.DEVICE_TYPE='LAN'

-- SSDP Config
config.MC_ADDRESS='239.255.255.250'
config.MC_PORT=1900
config.MC_TIMEOUT=6

config.ENUM = {}
config.ENUM.AC = 3
config.ENUM.HEATER = 4
config.ENUM.NEWFAN = 53
config.ENUM.SWITCH = 14
config.ENUM.SLIDER = 39
config.ENUM.HUE = 38

--device addrtype
config.AC = {}
config.AC.ONOFF = 0
config.AC.MODE = 1
config.AC.FAN = 2
config.AC.SETTEMP = 3
config.AC.TEMP = 4

config.HEATER = {}
config.HEATER.ONOFF = 0
config.HEATER.SETTEMP = 2
config.HEATER.TEMP = 3

config.NEWFAN = {}
config.NEWFAN.ONOFF = 0
config.NEWFAN.FAN = 1

config.SWITCH = {}
config.SWITCH.ONOFF = 0

config.SLIDER = {}
config.SLIDER.ONOFF = 0
config.SLIDER.BRIGHT = 1

config.HUE = {}
config.HUE.ONOFF = 0
config.HUE.BRIGHT = 1
config.HUE.HUE = 2

config.DEVICE = {}
config.DEVICE.ONOFF = 0

config.FIELD = {}
config.FIELD.DP2KNX = "dp2knx"
config.FIELD.DPENUM = "dpenum"
config.FIELD.DEVICES = "devices"
config.FIELD.IP = "ip"
config.FIELD.INVALID = "invalid"


return config
Binary file not shown.
Loading