-
Notifications
You must be signed in to change notification settings - Fork 468
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
ronie-z-wave
wants to merge
7
commits into
SmartThingsCommunity:main
from
iot-holding:add/aeotec_heavy_duty_switch
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fc4e12b
aeotec heavy duty switch added
ronie-z-wave debb5e9
update aeotec heavy duty
mh-zwave fd76fdd
Merge branch 'main' into add/aeotec_heavy_duty_switch
lelandblue 02d55c5
remove unused imports
mh-zwave 909750c
Merge branch 'add/aeotec_heavy_duty_switch' of https://github.com/zwa…
mh-zwave a9f2fb2
add credit of dev back
mh-zwave d1750a9
proposed changes made
mh-zwave File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
126 changes: 126 additions & 0 deletions
126
drivers/SmartThings/zwave-switch/profiles/aeotec-heavy-duty.yml
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,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
135
drivers/SmartThings/zwave-switch/src/aeotec-heavy-duty/init.lua
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,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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.