Skip to content

Commit

Permalink
Changed dp type
Browse files Browse the repository at this point in the history
  • Loading branch information
w35l3y authored Jun 20, 2024
1 parent 86f5040 commit bca38c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions personal-tuya-devices/models/TS0601/_TZE200_rjxqso4a.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ datapoints:
group: 1
capability: carbonMonoxideDetector
attribute: carbonMonoxide
type: enum
on: tested
off: clear
- id: 15
Expand Down
8 changes: 8 additions & 0 deletions personal-tuya-devices/src/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,13 @@ local defaults = {
end,
},
testCapability = {
type = "bool",
create_event = function (self, value, device, force_child) -- from_zigbee
return self.capability and self.attribute and capabilities[self.capability][self.attribute](to_number(value) == 1 and self.on or self.off) or nil
end,
},
momentaryAudioMuteTestCapability = {
type = "bool",
capability = "momentary",
create_event = function (self, value, device, force_child, datapoints) -- from_zigbee
return nil
Expand All @@ -486,9 +488,15 @@ local defaults = {
local cmd = datapoints[self.testCapability]
local state = device:get_latest_state(command.component, cmd.capability, cmd.attribute, "clear", "clear")
if state == "detected" then
if self.type == "enum" then
return { math.abs(self:get_dp(dpid, device)), data_types.Enum8(1) } -- mute
end
return { math.abs(self:get_dp(dpid, device)), data_types.Boolean(true) } -- mute
else
device:set_field("tested", state ~= "tested")
if cmd.type == "enum" then
return { math.abs(self:get_dp(self.testCapability, device)), data_types.Enum8(state ~= "tested" and 1 or 0) } -- tested
end
return { math.abs(self:get_dp(self.testCapability, device)), data_types.Boolean(state ~= "tested") } -- tested
end
end,
Expand Down

0 comments on commit bca38c2

Please sign in to comment.