Skip to content

Commit

Permalink
Added support for the Philips Hue Smart Plug; Philips Hue Smart Plug …
Browse files Browse the repository at this point in the history
…is exposed as a 'light' service so existing light code was modified to include the case for Philips Hue Smart Plug new device adoption and use
  • Loading branch information
kiera-robinson-st2 authored and dljsjr committed May 3, 2024
1 parent a4fade6 commit 007b231
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
12 changes: 12 additions & 0 deletions drivers/SmartThings/philips-hue/profiles/plug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: plug
components:
- id: main
capabilities:
- id: switch
version: 1
- id: samsungim.hueSyncMode
version: 1
- id: refresh
version: 1
categories:
- name: SmartPlug
4 changes: 3 additions & 1 deletion drivers/SmartThings/philips-hue/src/disco/light.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ function M.handle_discovered_device(
profile_ref = "white-ambiance" -- all color temp products support `white` (dimming)
elseif light.dimming then
profile_ref = "white" -- `white` refers to dimmable and includes filament bulbs
elseif light.on then -- Case for plug which uses same category as 'light'
profile_ref = "plug"
else
log.warn(
string.format(
"Light resource [%s] does not seem to be A White/White-Ambiance/White-Color-Ambiance device, currently unsupported"
"Light resource [%s] does not seem to be A White/White-Ambiance/White-Color-Ambiance/Plug device, currently unsupported"
,
resource_id
)
Expand Down
6 changes: 3 additions & 3 deletions drivers/SmartThings/philips-hue/src/hue/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,21 @@ function PhilipsHueApi:get_rooms() return self:get_all_reprs_for_rtype("room") e
---@return HueResourceResponse<HueLightInfo>?
---@return string? err nil on success
function PhilipsHueApi:get_light_by_id(light_resource_id)
return self:get_rtype_by_rid(HueDeviceTypes.LIGHT, light_resource_id)
return self:get_rtype_by_rid(HueDeviceTypes.LIGHT, light_resource_id) --[[@as HueResourceResponse<HueLightInfo>]]
end

---@param hue_device_id string
---@return HueResourceResponse<HueDeviceInfo>?
---@return string? err nil on success
function PhilipsHueApi:get_device_by_id(hue_device_id)
return self:get_rtype_by_rid("device", hue_device_id)
return self:get_rtype_by_rid("device", hue_device_id) --[[@as HueResourceResponse<HueDeviceInfo>]]
end

---@param zigbee_resource_id string
---@return HueResourceResponse<HueZigbeeInfo>?
---@return string? err nil on success
function PhilipsHueApi:get_zigbee_connectivity_by_id(zigbee_resource_id)
return self:get_rtype_by_rid("zigbee_connectivity", zigbee_resource_id)
return self:get_rtype_by_rid("zigbee_connectivity", zigbee_resource_id) --[[@as HueResourceResponse<HueZigbeeInfo>]]
end

---@param contact_resource_id string
Expand Down
1 change: 1 addition & 0 deletions drivers/SmartThings/philips-hue/src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ end
function utils.kelvin_to_mirek(kelvin) return 1000000 / kelvin end

function utils.mirek_to_kelvin(mirek) return 1000000 / mirek end

function utils.str_starts_with(str, start)
return str:sub(1, #start) == start
end
Expand Down

0 comments on commit 007b231

Please sign in to comment.