From 0d5bcebea86861e3a3a5ee4bb4cca07cde633728 Mon Sep 17 00:00:00 2001 From: cchillerr Date: Fri, 16 Aug 2024 09:45:38 +0800 Subject: [PATCH 1/2] [Bar 300] Issues - device don't operate about 'stop' command --- drivers/SmartThings/jbl/profiles/jbl.yml | 2 -- drivers/SmartThings/jbl/src/init.lua | 1 - drivers/SmartThings/jbl/src/jbl/capability_handler.lua | 5 ----- drivers/SmartThings/jbl/src/jbl/device_manager.lua | 1 - 4 files changed, 9 deletions(-) diff --git a/drivers/SmartThings/jbl/profiles/jbl.yml b/drivers/SmartThings/jbl/profiles/jbl.yml index c60823fed7..143c90634f 100644 --- a/drivers/SmartThings/jbl/profiles/jbl.yml +++ b/drivers/SmartThings/jbl/profiles/jbl.yml @@ -10,12 +10,10 @@ components: enabledValues: - 'playing' - 'paused' - - 'stopped' - key: "{{enumCommands}}" enabledValues: - 'play' - 'pause' - - 'stop' - id: mediaTrackControl version: 1 - id: audioMute diff --git a/drivers/SmartThings/jbl/src/init.lua b/drivers/SmartThings/jbl/src/init.lua index d707c27376..25da82abf3 100644 --- a/drivers/SmartThings/jbl/src/init.lua +++ b/drivers/SmartThings/jbl/src/init.lua @@ -204,7 +204,6 @@ local lan_driver = Driver("jbl", [capabilities.mediaPlayback.ID] = { [capabilities.mediaPlayback.commands.play.NAME] = jbl_capability_handler.playback_play_handler, [capabilities.mediaPlayback.commands.pause.NAME] = jbl_capability_handler.playback_pause_handler, - [capabilities.mediaPlayback.commands.stop.NAME] = jbl_capability_handler.playback_stop_handler, }, [capabilities.audioNotification.ID] = { [capabilities.audioNotification.commands.playTrack.NAME] = jbl_capability_handler.audioNotification_handler, diff --git a/drivers/SmartThings/jbl/src/jbl/capability_handler.lua b/drivers/SmartThings/jbl/src/jbl/capability_handler.lua index 1ad5259c01..75f05266ba 100644 --- a/drivers/SmartThings/jbl/src/jbl/capability_handler.lua +++ b/drivers/SmartThings/jbl/src/jbl/capability_handler.lua @@ -9,7 +9,6 @@ local function smartthings_playback_capability_handler(driver, device, capabilit local st_status_to_jbl_playback_status_table = { paused = "pause", playing = "play", - stopped = "stop", } local conn_info = device:get_field(fields.CONN_INFO) @@ -34,10 +33,6 @@ function capability_handler.playback_pause_handler(driver, device, args) smartthings_playback_capability_handler(driver, device, "paused") end -function capability_handler.playback_stop_handler(driver, device, args) - smartthings_playback_capability_handler(driver, device, "stopped") -end - function capability_handler.next_track_handler(driver, device, args) local conn_info = device:get_field(fields.CONN_INFO) log.info(string.format("media_track_control.next_track_handler : dni = %s", device.device_network_id)) diff --git a/drivers/SmartThings/jbl/src/jbl/device_manager.lua b/drivers/SmartThings/jbl/src/jbl/device_manager.lua index 436b16266e..c7ca9c6092 100644 --- a/drivers/SmartThings/jbl/src/jbl/device_manager.lua +++ b/drivers/SmartThings/jbl/src/jbl/device_manager.lua @@ -28,7 +28,6 @@ end local jbl_playback_state_to_smartthings_playback_status_table = { paused = "paused", playing = "playing", - stopped = "stopped", } function device_manager.handle_status(driver, device, status) From 4bd5e3276370ab671059ed7348841c3bd7ace8f2 Mon Sep 17 00:00:00 2001 From: cchillerr Date: Fri, 13 Dec 2024 14:20:07 +0800 Subject: [PATCH 2/2] emit the default set of supported commands enhance connection quality --- drivers/SmartThings/jbl/src/init.lua | 10 ++++++++++ drivers/SmartThings/jbl/src/jbl/api.lua | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/SmartThings/jbl/src/init.lua b/drivers/SmartThings/jbl/src/init.lua index 25da82abf3..f422ecf84c 100644 --- a/drivers/SmartThings/jbl/src/init.lua +++ b/drivers/SmartThings/jbl/src/init.lua @@ -179,6 +179,16 @@ local function device_init(driver, device) refresh(driver, device, nil) device:set_field(fields._INIT, true, { persist = false }) + + device:emit_event(capabilities.mediaPlayback.supportedPlaybackCommands({ + capabilities.mediaPlayback.commands.play.NAME, + capabilities.mediaPlayback.commands.pause.NAME, + })) + + device:emit_event(capabilities.mediaTrackControl.supportedTrackControlCommands({ + capabilities.mediaTrackControl.commands.nextTrack.NAME, + capabilities.mediaTrackControl.commands.previousTrack.NAME, + })) end local lan_driver = Driver("jbl", diff --git a/drivers/SmartThings/jbl/src/jbl/api.lua b/drivers/SmartThings/jbl/src/jbl/api.lua index 3cebabce55..95e25d14c3 100644 --- a/drivers/SmartThings/jbl/src/jbl/api.lua +++ b/drivers/SmartThings/jbl/src/jbl/api.lua @@ -2,6 +2,7 @@ local log = require "log" local json = require "st.json" local RestClient = require "lunchbox.rest" local utils = require "utils" +local st_utils = require "st.utils" local cosock = require "cosock" local jbl_api = {} @@ -68,7 +69,7 @@ function jbl_api.new_device_manager(bridge_ip, bridge_info, socket_builder) return setmetatable( { - headers = ADDITIONAL_HEADERS, + headers = st_utils.deep_copy(ADDITIONAL_HEADERS), client = RestClient.new(base_url, socket_builder), base_url = base_url, }, jbl_api