Skip to content
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

[Bar 300] Issues - device don't operate about 'stop' command #1797

Merged
merged 4 commits into from
Jan 9, 2025
Merged
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
2 changes: 0 additions & 2 deletions drivers/SmartThings/jbl/profiles/jbl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ components:
enabledValues:
- 'playing'
- 'paused'
- 'stopped'
- key: "{{enumCommands}}"
enabledValues:
- 'play'
- 'pause'
- 'stop'
- id: mediaTrackControl
version: 1
- id: audioMute
Expand Down
11 changes: 10 additions & 1 deletion drivers/SmartThings/jbl/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -204,7 +214,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,
Expand Down
3 changes: 2 additions & 1 deletion drivers/SmartThings/jbl/src/jbl/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions drivers/SmartThings/jbl/src/jbl/capability_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand Down
1 change: 0 additions & 1 deletion drivers/SmartThings/jbl/src/jbl/device_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading