Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aeotec heavy duty switch added #1109

Closed
Show file tree
Hide file tree
Changes from 3 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
19 changes: 19 additions & 0 deletions drivers/SmartThings/zwave-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,25 @@ zwaveManufacturer:
manufacturerId: 0x010F
productType: 0x0102
deviceProfileName: fibaro-dimmer-2
# Aeotec Heavy Duty Switch
- id: "Aeotec/Heavy Duty/EU"
deviceLabel: Aeotec Heavy Duty
manufacturerId: 0x0086
productType: 0x0003
productId: 0x004E
deviceProfileName: aeotec-heavy-duty
- id: "Aeotec/Heavy Duty/US"
deviceLabel: Aeotec Heavy Duty
manufacturerId: 0x0086
productType: 0x0103
productId: 0x004E
deviceProfileName: aeotec-heavy-duty
- id: "Aeotec/Heavy Duty/AU"
deviceLabel: Aeotec Heavy Duty
manufacturerId: 0x0086
productType: 0x0203
productId: 0x004E
deviceProfileName: aeotec-heavy-duty
zwaveGeneric:
- id: "GenericSwitch/1"
deviceLabel: Switch
Expand Down
126 changes: 126 additions & 0 deletions drivers/SmartThings/zwave-switch/profiles/aeotec-heavy-duty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: aeotec-heavy-duty
components:
- id: main
label: "Switch"
capabilities:
- id: switch
version: 1
- id: powerMeter
version: 1
- id: energyMeter
version: 1
- id: powerConsumptionReport
version: 1
- id: refresh
version: 1
categories:
- name: Switch
metadata:
deviceType: Switch
ocfDeviceType: oic.d.switch
deviceTypeId: Switch
preferences:
- title: "3. Overload Protection"
name: overloadProtection
description: "Determines if Load is turned off if more then 39.5A current is used for more than 5 seconds."
required: true
preferenceType: enumeration
definition:
options:
0: "Disable"
1: "Enable"
default: 0
- title: "20. Output power after power restore"
name: ledAfterPower
description: "Determines what happens to the output state after a power restoration"
required: true
preferenceType: enumeration
definition:
options:
0: "Last Status"
1: "Always On"
2: "Always Off"
default: 0
- title: "80. Automatic Report Type"
name: autoReportType
description: "Determines what type of report is sent by HDSS when status changes by hub or button press"
required: true
preferenceType: enumeration
definition:
options:
0: "Nothing"
1: "hail CC"
2: "basic CC Report"
default: 2
- title: "90. Enable/Disable Threshold Report"
name: powerThreshold
description: "Disable or Enable Threshold reporting"
required: true
preferenceType: enumeration
definition:
options:
0: "Disable"
1: "Enable"
default: 0
- title: "101. Group 1 Sensors"
name: group1Sensors
description: "Group 1 sensor reports."
required: true
preferenceType: integer
definition:
minimum: 0
maximum: 15
default: 12
- title: "102. Group 2 Sensors"
name: group2Sensors
description: "Group 2 sensor reports."
required: true
preferenceType: integer
definition:
minimum: 0
maximum: 15
default: 0
- title: "103. Group 3 Sensors"
name: group3Sensors
description: "Group 3 sensor reports."
required: true
preferenceType: integer
definition:
minimum: 0
maximum: 15
default: 0
- title: "111. Group 1 sensor report time"
name: group1Time
description: "set timed report of Group 1 sensor in seconds"
required: true
preferenceType: integer
definition:
minimum: 0
maximum: 86400
default: 300
- title: "112. Group 2 sensor report time"
name: group2Time
description: "set timed report of Group 2 sensor in second"
required: true
preferenceType: integer
definition:
minimum: 0
maximum: 86400
default: 3600
- title: "113. Group 3 sensor report time"
name: group3Time
description: "set timed report of Group 3 sensor in second"
required: true
preferenceType: integer
definition:
minimum: 0
maximum: 86400
default: 3600
- title: "Association Group 1: Lifeline"
name: assocGroup1
description: "Enter a comma delimited list of hex IDs to be sent general notifications (5 node max)"
required: true
preferenceType: string
definition:
stringType: text
default: ""
135 changes: 135 additions & 0 deletions drivers/SmartThings/zwave-switch/src/aeotec-heavy-duty/init.lua
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either change the copyright date or add back in the credit to the dev.

Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
-- Author: CommanderQ
--
-- Copyright 2021 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

local capabilities = require "st.capabilities"
local ZwaveDriver = require "st.zwave.driver"
local defaults = require "st.zwave.defaults"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    drivers/SmartThings/zwave-switch/src/aeotec-heavy-duty/init.lua:18:7: (W211) unused variable ZwaveDriver
    drivers/SmartThings/zwave-switch/src/aeotec-heavy-duty/init.lua:19:7: (W211) unused variable defaults

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry. I will remove them.

--- @type st.zwave.CommandClass.Meter
local Meter = (require "st.zwave.CommandClass.Meter")({ version = 3 })
--- @type st.zwave.CommandClass
local cc = require "st.zwave.CommandClass"
--- @type st.st.zwave.CommandClass.Configuration
local Configuration = (require "st.zwave.CommandClass.Configuration")({ version = 4 })

local preferencesMap = require "preferences"


local LAST_REPORT_TIME = "LAST_REPORT_TIME"
local POWER_UNIT_WATT = "W"
local ENERGY_UNIT_KWH = "kWh"

local FINGERPRINTS = {
{ mfr = 0x0086, prod = 0x0103, model = 0x004E }, -- US
{ mfr = 0x0086, prod = 0x0203, model = 0x004E }, -- AU
{ mfr = 0x0086, prod = 0x0003, model = 0x004E } -- EU
}

local function can_handle(opts, driver, device, ...)
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:id_match(fingerprint.mfr, fingerprint.prod, fingerprint.model) then return true end
end
return false
end

local function emit_power_consumption_report_event(device, value, channel)
-- powerConsumptionReport report interval
local current_time = os.time()
local last_time = device:get_field(LAST_REPORT_TIME) or 0
local next_time = last_time + 60 * 15 -- 15 mins, the minimum interval allowed between reports
if current_time < next_time then
return
end
device:set_field(LAST_REPORT_TIME, current_time, { persist = true })
local raw_value = value.value * 1000 -- 'Wh'

local delta_energy = 0.0
local current_power_consumption = device:get_latest_state('main', capabilities.powerConsumptionReport.ID,
capabilities.powerConsumptionReport.powerConsumption.NAME)
if current_power_consumption ~= nil then
delta_energy = math.max(raw_value - current_power_consumption.energy, 0.0)
end
device:emit_event_for_endpoint(channel, capabilities.powerConsumptionReport.powerConsumption({
energy = raw_value,
deltaEnergy = delta_energy
}))
end

local function meter_report_handler(driver, device, cmd, zb_rx)
if cmd.args.scale == Meter.scale.electric_meter.KILOWATT_HOURS then
local event_arguments = {
value = cmd.args.meter_value,
unit = ENERGY_UNIT_KWH
}
-- energyMeter
device:emit_event_for_endpoint(
cmd.src_channel,
capabilities.energyMeter.energy(event_arguments)
)

emit_power_consumption_report_event(device, { value = event_arguments.value }, cmd.src_channel)
elseif cmd.args.scale == Meter.scale.electric_meter.WATTS then
local event_arguments = {
value = cmd.args.meter_value,
unit = POWER_UNIT_WATT
}
-- powerMeter
device:emit_event_for_endpoint(
cmd.src_channel,
capabilities.powerMeter.power(event_arguments)
)
end
end

--- Handle preference changes
---
--- @param driver st.zwave.Driver
--- @param device st.zwave.Device
--- @param event table
--- @param args
local function info_changed(driver, device, event, args)
local preferences = preferencesMap.get_device_parameters(device)
for id, value in pairs(device.preferences) do
if args.old_st_store.preferences[id] ~= value and preferences and preferences[id] then
local new_parameter_value = preferencesMap.to_numeric_value(device.preferences[id])
device:send(Configuration:Set({
parameter_number = preferences[id].parameter_number,
size = preferences[id].size,
configuration_value = new_parameter_value
}))
end
end
end

local driver_template = {
supported_capabilities = {
capabilities.switch,
capabilities.energyMeter,
capabilities.powerMeter,
capabilities.powerConsumptionReport
},
zwave_handlers = {
[cc.METER] = {
[Meter.REPORT] = meter_report_handler
}
},
NAME = "Aeotec Heavy Duty",
lifecycle_handlers = {
infoChanged = info_changed
},
can_handle = can_handle
}

return driver_template;
3 changes: 2 additions & 1 deletion drivers/SmartThings/zwave-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ local driver_template = {
require("multi-metering-switch"),
require("zooz-zen-30-dimmer-relay"),
require("multichannel-device"),
require("aeotec-smart-switch")
require("aeotec-smart-switch"),
require("aeotec-heavy-duty")
},
lifecycle_handlers = {
init = device_init,
Expand Down
40 changes: 40 additions & 0 deletions drivers/SmartThings/zwave-switch/src/preferences.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.

local AEOTEC_HEAVY_DUTY_SWITCH = {
PARAMETERS = {
overloadProtection = { type = 'config', parameter_number = 3, size = 1 },
ledAfterPower = { type = 'config', parameter_number = 20, size = 1 },
autoReportType = { type = 'config', parameter_number = 80, size = 1 },
powerThreshold = { type = 'config', parameter_number = 90, size = 1 },
group1Sensors = { type = 'config', parameter_number = 101, size = 4 },
group2Sensors = { type = 'config', parameter_number = 102, size = 4 },
group3Sensors = { type = 'config', parameter_number = 103, size = 4 },
group1Time = { type = 'config', parameter_number = 111, size = 4 },
group2Time = { type = 'config', parameter_number = 112, size = 4 },
group3Time = { type = 'config', parameter_number = 113, size = 4 },
assocGroup1 = { type = 'assoc', group = 1, maxnodes = 5, addhub = true }
}
}

local devices = {
INOVELLI = {
MATCHING_MATRIX = {
Expand Down Expand Up @@ -301,6 +317,30 @@ local devices = {
dimmerPaddleControl = {parameter_number = 27, size = 1}
}
},
AEOTEC_HEAVY_DUTY_EU = {
MATCHING_MATRIX = {
mfrs = 0x0086,
product_types = 0x0003,
product_ids = 0x004E
},
PARAMETERS = AEOTEC_HEAVY_DUTY_SWITCH.PARAMETERS
},
AEOTEC_HEAVY_DUTY_US = {
MATCHING_MATRIX = {
mfrs = 0x0086,
product_types = 0x0103,
product_ids = 0x004E
},
PARAMETERS = AEOTEC_HEAVY_DUTY_SWITCH.PARAMETERS
},
AEOTEC_HEAVY_DUTY_AU = {
MATCHING_MATRIX = {
mfrs = 0x0086,
product_types = 0x0203,
product_ids = 0x004E
},
PARAMETERS = AEOTEC_HEAVY_DUTY_SWITCH.PARAMETERS
},
SWITCH_LEVEL_INDICATOR = {
MATCHING_MATRIX = {
mfrs = 0x0063,
Expand Down
Loading
Loading