-
Notifications
You must be signed in to change notification settings - Fork 511
Use fanSpeedPercent for thermostats #2425
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
Open
nickolas-deboom
wants to merge
1
commit into
main
Choose a base branch
from
use-fan-speed-percentage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -17,16 +17,15 @@ local log = require "log" | |
local clusters = require "st.matter.clusters" | ||
local embedded_cluster_utils = require "embedded-cluster-utils" | ||
local im = require "st.matter.interaction_model" | ||
|
||
local MatterDriver = require "st.matter.driver" | ||
local utils = require "st.utils" | ||
local version = require "version" | ||
|
||
local SUPPORTED_COMPONENT_CAPABILITIES = "__supported_component_capabilities" | ||
-- declare match_profile function for use throughout file | ||
local match_profile | ||
|
||
-- Include driver-side definitions when lua libs api version is < 10 | ||
local version = require "version" | ||
if version.api < 10 then | ||
clusters.HepaFilterMonitoring = require "HepaFilterMonitoring" | ||
clusters.ActivatedCarbonFilterMonitoring = require "ActivatedCarbonFilterMonitoring" | ||
|
@@ -100,8 +99,6 @@ local HEAT_PUMP_DEVICE_TYPE_ID = 0x0309 | |
local THERMOSTAT_DEVICE_TYPE_ID = 0x0301 | ||
local ELECTRICAL_SENSOR_DEVICE_TYPE_ID = 0x0510 | ||
|
||
local MIN_ALLOWED_PERCENT_VALUE = 0 | ||
local MAX_ALLOWED_PERCENT_VALUE = 100 | ||
local DEFAULT_REPORT_TIME_INTERVAL = 15 * 60 -- Report cumulative energy every 15 minutes | ||
local MAX_REPORT_TIMEOUT = 30 * 60 | ||
local POLL_INTERVAL = 60 -- To read CumulativeEnergyImported every 60 seconds. | ||
|
@@ -201,7 +198,8 @@ local subscribed_attributes = { | |
clusters.FanControl.attributes.FanMode | ||
}, | ||
[capabilities.fanSpeedPercent.ID] = { | ||
clusters.FanControl.attributes.PercentCurrent | ||
clusters.FanControl.attributes.PercentCurrent, | ||
clusters.FanControl.attributes.PercentSetting | ||
}, | ||
[capabilities.windMode.ID] = { | ||
clusters.FanControl.attributes.WindSupport, | ||
|
@@ -1012,6 +1010,7 @@ local function match_modular_profile_thermostat(driver, device) | |
|
||
if #fan_eps > 0 then | ||
table.insert(main_component_capabilities, capabilities.fanMode.ID) | ||
table.insert(main_component_capabilities, capabilities.fanSpeedPercent.ID) | ||
end | ||
if #rock_eps > 0 then | ||
table.insert(main_component_capabilities, capabilities.fanOscillationMode.ID) | ||
|
@@ -1613,11 +1612,19 @@ local function fan_mode_sequence_handler(driver, device, ib, response) | |
end | ||
|
||
local function fan_speed_percent_attr_handler(driver, device, ib, response) | ||
local speed = 0 | ||
if ib.data.value ~= nil then | ||
speed = utils.clamp_value(ib.data.value, MIN_ALLOWED_PERCENT_VALUE, MAX_ALLOWED_PERCENT_VALUE) | ||
local thermostat_mode = device:get_latest_state( | ||
device:endpoint_to_component(ib.endpoint_id), | ||
capabilities.thermostatMode.ID, | ||
capabilities.thermostatMode.thermostatMode.NAME | ||
) | ||
if thermostat_mode == capabilities.thermostatMode.thermostatMode.auto() then | ||
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.fanSpeedPercent.percent(ib.data.value)) | ||
end | ||
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.fanSpeedPercent.percent(speed)) | ||
end | ||
|
||
local function fan_speed_setting_attr_handler(driver, device, ib, response) | ||
if ib.data.value == nil then return end | ||
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.fanSpeedPercent.percent(ib.data.value)) | ||
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. we probably want to clamp this as well |
||
end | ||
|
||
local function wind_support_handler(driver, device, ib, response) | ||
|
@@ -2125,6 +2132,7 @@ local matter_driver_template = { | |
[clusters.FanControl.attributes.FanModeSequence.ID] = fan_mode_sequence_handler, | ||
[clusters.FanControl.attributes.FanMode.ID] = fan_mode_handler, | ||
[clusters.FanControl.attributes.PercentCurrent.ID] = fan_speed_percent_attr_handler, | ||
[clusters.FanControl.attributes.PercentSetting.ID] = fan_speed_setting_attr_handler, | ||
[clusters.FanControl.attributes.WindSupport.ID] = wind_support_handler, | ||
[clusters.FanControl.attributes.WindSetting.ID] = wind_setting_handler, | ||
[clusters.FanControl.attributes.RockSupport.ID] = rock_support_handler, | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
probably shouldn't remove the clamp, right?