Skip to content

Commit

Permalink
add laisiao bathroom heater
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkaName committed Nov 15, 2024
1 parent ce63e46 commit 47c2da2
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 1 deletion.
5 changes: 5 additions & 0 deletions drivers/SmartThings/zigbee-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2293,6 +2293,11 @@ zigbeeManufacturer:
manufacturer: Insta GmbH
model: NEXENTRO Dimming Actuator
deviceProfileName: on-off-level
- id: "LAISIAO/BATH"
deviceLabel: Laisiao Bathroom Heater
manufacturer: LAISIAO
model: yuba
deviceProfileName: switch-smart-bath-heater-laisiao
zigbeeGeneric:
- id: "genericSwitch"
deviceLabel: Zigbee Switch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: switch-smart-bath-heater-laisiao
components:
- id: main
label: "待机"
capabilities:
- id: switch
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: Switch
- id: switch2
label: "照明"
capabilities:
- id: switch
version: 1
categories:
- name: Switch
- id: switch3
label: "强暖"
capabilities:
- id: switch
version: 1
categories:
- name: Switch
- id: switch4
label: "弱暖"
capabilities:
- id: switch
version: 1
categories:
- name: Switch
- id: switch5
label: "换气"
capabilities:
- id: switch
version: 1
categories:
- name: Switch
- id: switch6
label: "自然风"
capabilities:
- id: switch
version: 1
categories:
- name: Switch
- id: switch7
label: "干燥"
capabilities:
- id: switch
version: 1
categories:
- name: Switch
- id: switch8
label: "摆页"
capabilities:
- id: switch
version: 1
categories:
- name: Switch
3 changes: 2 additions & 1 deletion drivers/SmartThings/zigbee-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ local zigbee_switch_driver_template = {
lazy_load_if_possible("ge-link-bulb"),
lazy_load_if_possible("bad_on_off_data_type"),
lazy_load_if_possible("robb"),
lazy_load_if_possible("wallhero")
lazy_load_if_possible("wallhero"),
lazy_load_if_possible("laisiao")
},
lifecycle_handlers = {
init = device_init,
Expand Down
83 changes: 83 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/laisiao/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
-- Copyright 2024 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 zcl_clusters = require "st.zigbee.zcl.clusters"
local socket = require "cosock.socket"

local FINGERPRINTS = {
{ mfr = "LAISIAO", model = "yuba" },
}

local function can_handle_laisiao(opts, driver, device, ...)
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
local subdriver = require("laisiao")
return true, subdriver
end
end
return false
end

local function component_to_endpoint(device, component_id)
if component_id == "main" then
return device.fingerprinted_endpoint_id
else
local ep_num = component_id:match("switch(%d)")
return ep_num and tonumber(ep_num) or device.fingerprinted_endpoint_id
end
end

local function endpoint_to_component(device, ep)
if ep == device.fingerprinted_endpoint_id then
return "main"
else
return string.format("switch%d", ep)
end
end

local device_init = function(self, device)
device:set_component_to_endpoint_fn(component_to_endpoint)
device:set_endpoint_to_component_fn(endpoint_to_component)
end

local function on_handler(driver, device, command)
local attr = capabilities.switch.switch
if command.component == "main" then
-- The main component is set to on by the device and cannot be set to on itself. It can only trigger off
device:emit_event_for_endpoint(device.fingerprinted_endpoint_id, attr.on())
socket.sleep(1)
device:emit_event_for_endpoint(device.fingerprinted_endpoint_id, attr.off())
else
device:send_to_component(command.component, zcl_clusters.OnOff.server.commands.On(device))
end
end

local laisiao_bath_heater = {
NAME = "Zigbee Laisiao Bathroom Heater",
supported_capabilities = {
capabilities.switch,
},
lifecycle_handlers = {
init = device_init,
},
capability_handlers = {
[capabilities.switch.ID] = {
[capabilities.switch.commands.on.NAME] = on_handler
}
},
can_handle = can_handle_laisiao
}

return laisiao_bath_heater
1 change: 1 addition & 0 deletions tools/localizations/cn.csv
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ Aqara Wireless Mini Switch T1,Aqara 无线开关 T1
"WallHero Switch (8 Way)",八位智能开关/场景面板
"WallHero Outlet",智能墙面五孔插座
"WallHero Remote Control (4-Inch)",语音场景(4寸)面板
"Laisiao Bathroom Heater",Laisiao智能浴霸

0 comments on commit 47c2da2

Please sign in to comment.