Skip to content

Feature/matter britzyhub #2189

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
wants to merge 14 commits into
base: main
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# BritzyHub Matter Edge Driver

Edge driver for registering BritzyHub Matter dedicated Matter devices.

---

## Reference
6 changes: 6 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: BritzyHub Matter
packageKey: britzyhub-matter
permissions:
matter: {}
description: SmartThings Edge driver for BritzyHub Matter devices.
vendorSupportInformation: https://sinux.kr
16 changes: 16 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/fingerprints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
matterGeneric:
- id: "elevator"
deviceLabel: "Elevator"
deviceTypes:
- id: 0xFF02
deviceProfileName: elevator
- id: "gas-valve"
deviceLabel: "Gas Valve"
deviceTypes:
- id: 0xFF01
deviceProfileName: gas-valve
- id: "ventilator"
deviceLabel: "Ventilator"
deviceTypes:
- id: 0xFF03
deviceProfileName: ventilator
8 changes: 8 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/profiles/elevator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: elevator
components:
- id: main
capabilities:
- id: elevatorCall
version: 1
categories:
- name: Elevator
8 changes: 8 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/profiles/gas-valve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: gas-valve
components:
- id: main
capabilities:
- id: safetyValve
version: 1
categories:
- name: GasValve
17 changes: 17 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/profiles/ventilator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ventilator
components:
- id: main
capabilities:
- id: airPurifierFanMode
version: 1
config:
values:
- key: "airPurifierFanMode.value"
enabledValues:
- auto
- low
- medium
- high
- off
categories:
- name: Vent
91 changes: 91 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/src/elevator/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
-- SinuxSoft (c) 2025
-- Licensed under the Apache License, Version 2.0

local capabilities = require "st.capabilities"
local clusters = require "st.matter.clusters"
local log = require "log"

local elevator_cap = capabilities.elevatorCall
local onoff_cluster = clusters.OnOff

local ELEVATOR_DEVICE_TYPE_ID = 0xFF02

local function on_off_attr_handler(_, device, ib, _)
if ib.data.value then
device:emit_event_for_endpoint(ib.endpoint_id, elevator_cap.callStatus.called())
else
device:emit_event_for_endpoint(ib.endpoint_id, elevator_cap.callStatus.standby())
end
end

local function handle_elevator_call(driver, device, cmd)
local endpoint_id = device:component_to_endpoint(cmd.component)
local req = onoff_cluster.server.commands.On(device, endpoint_id)
device:send(req)
end

local function find_default_endpoint(device, cluster)
local eps = device:get_endpoints(cluster)
table.sort(eps)
for _, ep in ipairs(eps) do
if ep ~= 0 then return ep end
end
log.warn(string.format("No endpoint found, using default %d", device.MATTER_DEFAULT_ENDPOINT))
return device.MATTER_DEFAULT_ENDPOINT
end

local function component_to_endpoint(device, _)
return find_default_endpoint(device, clusters.OnOff.ID)
end

local function device_init(_, device)
device:set_component_to_endpoint_fn(component_to_endpoint)
device:subscribe()
end

local function info_changed(_, device)
device:add_subscribed_attribute(onoff_cluster.attributes.OnOff)
device:subscribe()
end

local function is_matter_elevator(opts, driver, device)
for _, ep in ipairs(device.endpoints) do
for _, dt in ipairs(ep.device_types) do
if dt.device_type_id == ELEVATOR_DEVICE_TYPE_ID then
return true
end
end
end
return false
end

local elevator_handler = {
NAME = "Elevator Handler",
can_handle = is_matter_elevator,
lifecycle_handlers = {
init = device_init,
infoChanged = info_changed,
},
matter_handlers = {
attr = {
[onoff_cluster.ID] = {
[onoff_cluster.attributes.OnOff.ID] = on_off_attr_handler,
}
}
},
capability_handlers = {
[elevator_cap.ID] = {
[elevator_cap.commands.call.NAME] = handle_elevator_call,
}
},
supported_capabilities = {
elevator_cap,
},
subscribed_attributes = {
[elevator_cap.ID] = {
onoff_cluster.attributes.OnOff
}
},
}

return elevator_handler
93 changes: 93 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/src/gas-valve/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
-- SinuxSoft (c) 2025
-- Licensed under the Apache License, Version 2.0

local capabilities = require "st.capabilities"
local clusters = require "st.matter.clusters"
local log = require "log"

local valve_cap = capabilities.safetyValve
local onoff_cluster = clusters.OnOff

local GAS_VALVE_DEVICE_TYPE_ID = 0xFF01

local function on_off_attr_handler(driver, device, ib, response)
if ib.data.value then
device:emit_event_for_endpoint(ib.endpoint_id, valve_cap.valve.open())
else
device:emit_event_for_endpoint(ib.endpoint_id, valve_cap.valve.closed())
end
end

local function handle_valve_command(driver, device, cmd, cluster_command)
local endpoint_id = device:component_to_endpoint(cmd.component)
local req = cluster_command(device, endpoint_id)
device:send(req)
end

local function find_default_endpoint(device, cluster)
local eps = device:get_endpoints(cluster)
table.sort(eps)
for _, ep in ipairs(eps) do
if ep ~= 0 then return ep end
end
log.warn(string.format("No endpoint found, using default %d", device.MATTER_DEFAULT_ENDPOINT))
return device.MATTER_DEFAULT_ENDPOINT
end

local function component_to_endpoint(device, _)
return find_default_endpoint(device, onoff_cluster.ID)
end

local function device_init(_, device)
device:set_component_to_endpoint_fn(component_to_endpoint)
device:subscribe()
end

local function info_changed(_, device)
device:add_subscribed_attribute(onoff_cluster.attributes.OnOff)
device:subscribe()
end

local function is_matter_gas_valve(opts, driver, device)
for _, ep in ipairs(device.endpoints) do
for _, dt in ipairs(ep.device_types) do
if dt.device_type_id == GAS_VALVE_DEVICE_TYPE_ID then
return true
end
end
end
return false
end

local gas_valve_handler = {
NAME = "Gas Valve Handler",
can_handle = is_matter_gas_valve,
lifecycle_handlers = {
init = device_init,
infoChanged = info_changed,
},
matter_handlers = {
attr = {
[onoff_cluster.ID] = {
[onoff_cluster.attributes.OnOff.ID] = on_off_attr_handler,
}
}
},
capability_handlers = {
[valve_cap.ID] = {
[valve_cap.commands.close.NAME] = function(driver, device, cmd)
handle_valve_command(driver, device, cmd, onoff_cluster.server.commands.Off)
end,
}
},
supported_capabilities = {
valve_cap,
},
subscribed_attributes = {
[valve_cap.ID] = {
onoff_cluster.attributes.OnOff
}
},
}

return gas_valve_handler
16 changes: 16 additions & 0 deletions drivers/SmartThings/sinux-britzyhub/src/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- SinuxSoft (c) 2025
-- Licensed under the Apache License, Version 2.0

local MatterDriver = require "st.matter.driver"
local log = require "log"

local matter_driver = MatterDriver("britzyhub-matter", {
sub_drivers = {
require ("elevator"),
require ("gas-valve"),
require ("ventilator"),
}
})

log.info_with({hub_logs=true}, string.format("Starting %s driver, with dispatcher: %s", matter_driver.NAME, matter_driver.matter_dispatcher))
matter_driver:run()
Loading