forked from SmartThingsCommunity/SmartThingsEdgeDrivers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DeepSmart (SmartThingsCommunity#1283)
Signed-off-by: “liuzhonghua” <[email protected]>
- Loading branch information
Showing
23 changed files
with
3,386 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ssdp: | ||
- searchTerm: "DEEPSMART-ARM" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
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) 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 | ||
|
||
---------------- | ||
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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[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 | ||
|
||
|
||
--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.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 |
Oops, something went wrong.