Skip to content

Commit

Permalink
Update submodule, add media variables, align version
Browse files Browse the repository at this point in the history
  • Loading branch information
bphillips09 committed Mar 4, 2024
1 parent 8b8abbc commit fe9f04f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Control4-HA-Base
Submodule Control4-HA-Base updated 1 files
+23 −0 driver.lua
22 changes: 15 additions & 7 deletions commands.lua
Expand Up @@ -20,6 +20,13 @@ SHUFFLE = false
REPEAT = false
REPEAT_ONE = false

function DRV.OnDriverInit(init)
C4:AddVariable("MEDIA_TITLE", "", "STRING")
C4:AddVariable("MEDIA_ARTIST", "", "STRING")
C4:AddVariable("MEDIA_ALBUM", "", "STRING")
C4:AddVariable("MEDIA_APP_NAME", "", "STRING")
end

function DRV.OnDriverLateInit(init)
math.randomseed(os.time())
math.random(); math.random(); math.random()
Expand Down Expand Up @@ -346,26 +353,27 @@ function Parse(data)
selectedAttribute = attributes["media_title"]
if selectedAttribute ~= nil then
MEDIA_STATUS.TITLE = selectedAttribute
C4:SetVariable("MEDIA_TITLE", selectedAttribute)
end

selectedAttribute = attributes["media_artist"]
if selectedAttribute ~= nil then
MEDIA_STATUS.ARTIST = selectedAttribute
C4:SetVariable("MEDIA_ARTIST", selectedAttribute)
end

selectedAttribute = attributes["media_album_name"]
if selectedAttribute ~= nil then
MEDIA_STATUS.ALBUM = selectedAttribute
end

selectedAttribute = attributes["media_artist"]
if selectedAttribute ~= nil then
MEDIA_STATUS.ARTIST = selectedAttribute
C4:SetVariable("MEDIA_ALBUM", selectedAttribute)
end

selectedAttribute = attributes["app_name"]
if selectedAttribute ~= nil and MEDIA_STATUS.TITLE == "" or MEDIA_STATUS.TITLE == nil then
MEDIA_STATUS.TITLE = selectedAttribute
if selectedAttribute ~= nil then
if MEDIA_STATUS.TITLE == "" or MEDIA_STATUS.TITLE == nil then
MEDIA_STATUS.TITLE = selectedAttribute
end
C4:SetVariable("MEDIA_APP_NAME", selectedAttribute)
end

selectedAttribute = attributes["shuffle"]
Expand Down
4 changes: 2 additions & 2 deletions driver.xml
Expand Up @@ -5,8 +5,8 @@
<name>HA Media Player</name>
<model>HA Media Player</model>
<created>09/10/2023 12:00</created>
<modified>02/09/2024 12:00</modified>
<version>103</version>
<modified>03/04/2024 12:00</modified>
<version>102</version>
<control>lua_gen</control>
<controlmethod>IP</controlmethod>
<driver>DriverWorks</driver>
Expand Down

0 comments on commit fe9f04f

Please sign in to comment.