Skip to content

Commit

Permalink
lms: minor command improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Jan 24, 2025
1 parent 39d147a commit ea38eb0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def _transform_send_data(self, data=None, **kwargs):

def _transform_received_data(self, data):
# fix weird representation of MAC address (%3A = :), etc.
data_temp = data.replace("%20", "PPLACEHOLDERR")
data_temp = data.replace("%20", "PPLACcCEHOLDERR")
data = urllib.parse.unquote(data_temp)
data = data.replace("PPLACEHOLDERR", "%20")
data = data.replace("PPLACcCEHOLDERR", "%20")
return data

def _process_additional_data(self, command: str, data: Any, value: Any, custom: int, by: str | None = None):
Expand Down
8 changes: 4 additions & 4 deletions lms/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
'playpause': {'read': True, 'write': True, 'item_type': 'bool', 'write_cmd': '{CUSTOM_ATTR1} {VALUE}', 'dev_datatype': 'LMSPlay', 'reply_pattern': [r'^{CUSTOM_PATTERN1} (?:playlist\s)?(play|pause)(?:\s3)?$', r'^{CUSTOM_PATTERN1} pause (0|1)'], 'item_attrs': {'enforce': True}},
'stop': {'read': True, 'write': True, 'item_type': 'bool', 'write_cmd': '{CUSTOM_ATTR1} {VALUE}', 'dev_datatype': 'LMSStop', 'reply_pattern': [r'^{CUSTOM_PATTERN1} (?:playlist\s)?(stop)$', r'^{CUSTOM_PATTERN1} (?:playlist\s)?(play|pause)(?:\s3)?$'], 'item_attrs': {'enforce': True}},
'mute': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} mixer muting ?', 'item_type': 'bool', 'write_cmd': '{CUSTOM_ATTR1} mixer muting {RAW_VALUE:01}', 'dev_datatype': 'LMSonoff', 'reply_pattern': [r'^{CUSTOM_PATTERN1} mixer muting$', r'^{CUSTOM_PATTERN1} (?:mixer muting|prefset server mute) (\d)'], 'item_attrs': {'initial': True, 'enforce': True}},
'volume': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} mixer volume ?', 'item_type': 'num', 'write_cmd': '{CUSTOM_ATTR1} mixer volume {VALUE}', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} (?:mixer volume |prefset server volume )(\-?\d{1,3})', r'^{CUSTOM_PATTERN1} status(?:.*)mixer volume:([^\s]+)']},
'volume': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} mixer volume ?', 'item_type': 'num', 'write_cmd': '{CUSTOM_ATTR1} mixer volume {VALUE}', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} (?:mixer volume |prefset server volume )(\-?\d{1,3})', r'^{CUSTOM_PATTERN1} status(?:.*)mixer volume:([^\s]+)'], 'item_attrs': {'initial': True}},
'volume_fading': {'read': False, 'write': True, 'item_type': 'num', 'write_cmd': '{CUSTOM_ATTR1} mixer volume {VALUE}', 'dev_datatype': 'str', 'item_attrs': {'item_template': 'volume_fading'}},
'volume_low': {'read': False, 'write': True, 'item_type': 'num', 'write_cmd': '{CUSTOM_ATTR1} mixer volume {VALUE}', 'dev_datatype': 'str', 'send_retries': 0, 'item_attrs': {'attributes': {'cache': True, 'enforce_updates': True, 'initial_value': 60}}},
'volume_high': {'read': False, 'write': True, 'item_type': 'num', 'write_cmd': '{CUSTOM_ATTR1} mixer volume {VALUE}', 'dev_datatype': 'str', 'send_retries': 0, 'item_attrs': {'attributes': {'cache': True, 'enforce_updates': True, 'initial_value': 80}}},
Expand All @@ -83,8 +83,8 @@
'playlist': {
'rename_current': {'read': False, 'write': True, 'item_type': 'str', 'write_cmd': '{CUSTOM_ATTR1} playlists rename playlist_id:{CUSTOM_PARAM1:CURRENT_LIST_ID} newname:{VALUE}', 'dev_datatype': 'str', 'reply_pattern': r'^{CUSTOM_PATTERN1} playlists rename playlist_id:\d+\s+newname:([^\s]+)(?:\s+overwritten_playlist_id:\d+)?$', 'item_attrs': {'enforce': True}},
'delete_current': {'read': False, 'write': True, 'write_cmd': '{CUSTOM_ATTR1} playlists delete playlist_id:{CUSTOM_PARAM1:CURRENT_LIST_ID}', 'item_type': 'bool', 'dev_datatype': 'LMSDeletePlaylist', 'reply_pattern': r'^{CUSTOM_PATTERN1} playlists delete playlist_id:(\d+)', 'send_retries': 0, 'item_attrs': {'enforce': True, 'attributes': {'remark': 'Be careful, instantly deletes the current playlist!'}}},
'repeat': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} playlist repeat ?', 'item_type': 'str', 'write_cmd': '{CUSTOM_ATTR1} playlist repeat {VALUE}', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} prefset server repeat {LOOKUP}$', r'^{CUSTOM_PATTERN1} playlist repeat {LOOKUP}$', r'^{CUSTOM_PATTERN1} status(?:.*)playlist repeat:{LOOKUP}$'], 'lookup': 'REPEAT', 'item_attrs': {'initial': True, 'attributes': {'remark': '0 = Off, 1 = Song, 2 = Playlist'}, 'lookup_item': True}},
'shuffle': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} playlist shuffle ?', 'item_type': 'str', 'write_cmd': '{CUSTOM_ATTR1} playlist shuffle {VALUE}', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} prefset server shuffle {LOOKUP}$', r'^{CUSTOM_PATTERN1} playlist shuffle {LOOKUP}$', r'^{CUSTOM_PATTERN1} status(?:.*)playlist shuffle:{LOOKUP}$'], 'lookup': 'SHUFFLE', 'item_attrs': {'initial': True, 'attributes': {'remark': '0 = Off, 1 = Song, 2 = Album'}, 'lookup_item': True}},
'repeat': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} playlist repeat ?', 'item_type': 'str', 'write_cmd': '{CUSTOM_ATTR1} playlist repeat {VALUE}', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} prefset server repeat {LOOKUP}$', r'^{CUSTOM_PATTERN1} playlist repeat {LOOKUP}$', r'^{CUSTOM_PATTERN1} status(?:.*)playlist repeat:{LOOKUP}$'], 'lookup': 'REPEAT', 'item_attrs': {'initial': True, 'attributes': {'initial_value': 'OFF', 'remark': '0 = Off, 1 = Song, 2 = Playlist'}, 'lookup_item': True}},
'shuffle': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} playlist shuffle ?', 'item_type': 'str', 'write_cmd': '{CUSTOM_ATTR1} playlist shuffle {VALUE}', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} prefset server shuffle {LOOKUP}$', r'^{CUSTOM_PATTERN1} playlist shuffle {LOOKUP}$', r'^{CUSTOM_PATTERN1} status(?:.*)playlist shuffle:{LOOKUP}$'], 'lookup': 'SHUFFLE', 'item_attrs': {'initial': True, 'attributes': {'initial_value': 'OFF', 'remark': '0 = Off, 1 = Song, 2 = Album'}, 'lookup_item': True}},
'index': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} playlist index ?', 'write_cmd': '{CUSTOM_ATTR1} playlist index {VALUE}', 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} playlist (?:index|newsong .*) (\d+)$', r'^{CUSTOM_PATTERN1} status(?:.*)playlist_cur_index:(\d*[^\s]+)', r'^{CUSTOM_PATTERN1} prefset server currentSong (\d+)$', r'^{CUSTOM_PATTERN1} playlist jump (\d+)']},
'current_name': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} playlist name ?', 'write_cmd': '{CUSTOM_ATTR1} playlist name {VALUE}', 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} playlistcontrol cmd:load playlist_name:(.*) count:(?:\d+)$', r'^{CUSTOM_PATTERN1} playlist name (.*[^?])', r'^{CUSTOM_PATTERN1} playlist playlistsinfo id:(?:\d+) name:(.*) modified:']},
'current_url': {'read': True, 'write': False, 'read_cmd': '{CUSTOM_ATTR1} playlist playlistsinfo url', 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': r'^{CUSTOM_PATTERN1} playlist playlistsinfo (?:url\s)?id:(?:\d+) name:(?:.*) modified:(?:0|1) url:(.*)'},
Expand Down Expand Up @@ -116,7 +116,7 @@
'ip': {'read': True, 'write': False, 'read_cmd': '{CUSTOM_ATTR1} ip ?', 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} ip (.*)', r'^{CUSTOM_PATTERN1} status(?:.*)player_ip:([^:\s]+)']},
'modelname': {'read': False, 'write': False, 'item_type': 'str', 'dev_datatype': 'str'},
'firmware': {'read': False, 'write': False, 'item_type': 'str', 'dev_datatype': 'str'},
'name': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} name ?', 'write_cmd': '{CUSTOM_ATTR1} name {VALUE}', 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} name (.*)', r'^{CUSTOM_PATTERN1} status(?:.*)player_name:([^\s]+)']},
'name': {'read': True, 'write': True, 'read_cmd': '{CUSTOM_ATTR1} name ?', 'write_cmd': '{CUSTOM_ATTR1} name {VALUE}', 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} prefset server playername (.*)', r'^{CUSTOM_PATTERN1} name (.*)', r'^{CUSTOM_PATTERN1} status(?:.*)player_name:([^\s]+)']},
'signalstrength': {'read': True, 'write': False, 'read_cmd': '{CUSTOM_ATTR1} signalstrength ?', 'item_type': 'num', 'dev_datatype': 'str', 'reply_pattern': [r'^{CUSTOM_PATTERN1} signalstrength (\d+)', r'^{CUSTOM_PATTERN1} status(?:.*)signalstrength:([^\s]+)']},
'albumarturl': {'read': True, 'write': False, 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': '^(https?://.*)', 'item_attrs': {'attributes': {'remark': 'This item gets automatically defined and overwritten based on (web_)host and web_port'}}}
},
Expand Down
6 changes: 6 additions & 0 deletions lms/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ item_structs:
sqb_read_group@instance:
- player
- player.control
sqb_read_initial@instance: true

volume_fading:
type: num
Expand Down Expand Up @@ -924,6 +925,7 @@ item_structs:
- player
- player.playlist
sqb_read_initial@instance: true
initial_value: OFF
remark: 0 = Off, 1 = Song, 2 = Playlist

lookup:
Expand All @@ -939,6 +941,7 @@ item_structs:
- player
- player.playlist
sqb_read_initial@instance: true
initial_value: OFF
remark: 0 = Off, 1 = Song, 2 = Album

lookup:
Expand Down Expand Up @@ -1752,6 +1755,7 @@ item_structs:
- ALL
- ALL.player
- ALL.player.control
sqb_read_initial@instance: true

volume_fading:
type: num
Expand Down Expand Up @@ -1960,6 +1964,7 @@ item_structs:
- ALL.player
- ALL.player.playlist
sqb_read_initial@instance: true
initial_value: OFF
remark: 0 = Off, 1 = Song, 2 = Playlist

lookup:
Expand All @@ -1976,6 +1981,7 @@ item_structs:
- ALL.player
- ALL.player.playlist
sqb_read_initial@instance: true
initial_value: OFF
remark: 0 = Off, 1 = Song, 2 = Album

lookup:
Expand Down
3 changes: 2 additions & 1 deletion lms/user_doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Das struct `lms.player` (sowie das optionale `lms.player_plugins`) wird dann
pro Abspielgerät genutzt, wobei hier wichtig ist, mittels `lms.sqb_custom1` die MAC Adresse
des Players mit anzugeben.

In Version 2.0.0 wurde die interne Struktur der Structs etwas abgeändert.
In Version 2.0.0 wurde die interne Struktur der Structs etwas abgeändert, weshalb Zugriffe auf die Items in
der Visu, in Logiken, etc. angepasst werden müssen.

.. code-block:: yaml
Expand Down

0 comments on commit ea38eb0

Please sign in to comment.