@riddix/hamh 2.1.0-alpha.420 → 2.1.0-alpha.422

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -170571,6 +170571,70 @@ var MediaPlayerKeypadInputServer = class extends KeypadInputServer {
170571
170571
  }
170572
170572
  };
170573
170573
 
170574
+ // src/matter/behaviors/media-input-server.ts
170575
+ init_home_assistant_entity_behavior();
170576
+ var MediaInputServerBase = class extends MediaInputServer {
170577
+ async initialize() {
170578
+ await super.initialize();
170579
+ const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
170580
+ this.update(homeAssistant.entity);
170581
+ this.reactTo(homeAssistant.onChange, this.update);
170582
+ }
170583
+ update(entity) {
170584
+ if (!entity.state) {
170585
+ return;
170586
+ }
170587
+ const config10 = this.state.config;
170588
+ let source_idx = 0;
170589
+ const sourceList = config10.getSourceList(entity.state, this.agent)?.sort();
170590
+ const inputList = sourceList?.map((source) => ({
170591
+ index: source_idx++,
170592
+ inputType: MediaInput3.InputType.Other,
170593
+ name: source,
170594
+ description: source
170595
+ }));
170596
+ const currentSource = config10.getCurrentSource(entity.state, this.agent);
170597
+ let currentInput = sourceList?.indexOf(currentSource ?? "");
170598
+ if (currentInput === -1 || currentInput == null) {
170599
+ currentInput = 0;
170600
+ }
170601
+ applyPatchState(this.state, {
170602
+ inputList,
170603
+ currentInput
170604
+ });
170605
+ }
170606
+ selectInput(request) {
170607
+ const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
170608
+ const target = this.state.inputList[request.index];
170609
+ homeAssistant.callAction(
170610
+ this.state.config.selectSource(target.name, this.agent)
170611
+ );
170612
+ }
170613
+ showInputStatus() {
170614
+ }
170615
+ hideInputStatus() {
170616
+ }
170617
+ };
170618
+ ((MediaInputServerBase2) => {
170619
+ class State extends MediaInputServer.State {
170620
+ config;
170621
+ }
170622
+ MediaInputServerBase2.State = State;
170623
+ })(MediaInputServerBase || (MediaInputServerBase = {}));
170624
+ function MediaInputServer2(config10) {
170625
+ return MediaInputServerBase.set({ config: config10 });
170626
+ }
170627
+
170628
+ // src/matter/endpoints/legacy/media-player/behaviors/media-player-media-input-server.ts
170629
+ var MediaPlayerMediaInputServer = MediaInputServer2({
170630
+ getCurrentSource: (entity) => entity.attributes.source,
170631
+ getSourceList: (entity) => entity.attributes.source_list,
170632
+ selectSource: (source) => ({
170633
+ action: "media_player.select_source",
170634
+ data: { source }
170635
+ })
170636
+ });
170637
+
170574
170638
  // src/matter/endpoints/legacy/media-player/behaviors/media-player-media-playback-server.ts
170575
170639
  init_home_assistant_entity_behavior();
170576
170640
  var MediaPlayerMediaPlaybackServer = class extends MediaPlaybackServer {
@@ -170688,6 +170752,9 @@ function VideoPlayerDevice(homeAssistantEntity) {
170688
170752
  if (supportsPlay || supportsPause) {
170689
170753
  device = device.with(MediaPlayerMediaPlaybackServer);
170690
170754
  }
170755
+ if (testBit(supportedFeatures, MediaPlayerDeviceFeature.SELECT_SOURCE)) {
170756
+ device = device.with(MediaPlayerMediaInputServer);
170757
+ }
170691
170758
  return device.set({ homeAssistantEntity });
170692
170759
  }
170693
170760
 
@@ -170814,70 +170881,6 @@ var MediaPlayerLevelControlServer = SpeakerLevelControlServer({
170814
170881
  }
170815
170882
  });
170816
170883
 
170817
- // src/matter/behaviors/media-input-server.ts
170818
- init_home_assistant_entity_behavior();
170819
- var MediaInputServerBase = class extends MediaInputServer {
170820
- async initialize() {
170821
- await super.initialize();
170822
- const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
170823
- this.update(homeAssistant.entity);
170824
- this.reactTo(homeAssistant.onChange, this.update);
170825
- }
170826
- update(entity) {
170827
- if (!entity.state) {
170828
- return;
170829
- }
170830
- const config10 = this.state.config;
170831
- let source_idx = 0;
170832
- const sourceList = config10.getSourceList(entity.state, this.agent)?.sort();
170833
- const inputList = sourceList?.map((source) => ({
170834
- index: source_idx++,
170835
- inputType: MediaInput3.InputType.Other,
170836
- name: source,
170837
- description: source
170838
- }));
170839
- const currentSource = config10.getCurrentSource(entity.state, this.agent);
170840
- let currentInput = sourceList?.indexOf(currentSource ?? "");
170841
- if (currentInput === -1 || currentInput == null) {
170842
- currentInput = 0;
170843
- }
170844
- applyPatchState(this.state, {
170845
- inputList,
170846
- currentInput
170847
- });
170848
- }
170849
- selectInput(request) {
170850
- const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
170851
- const target = this.state.inputList[request.index];
170852
- homeAssistant.callAction(
170853
- this.state.config.selectSource(target.name, this.agent)
170854
- );
170855
- }
170856
- showInputStatus() {
170857
- }
170858
- hideInputStatus() {
170859
- }
170860
- };
170861
- ((MediaInputServerBase2) => {
170862
- class State extends MediaInputServer.State {
170863
- config;
170864
- }
170865
- MediaInputServerBase2.State = State;
170866
- })(MediaInputServerBase || (MediaInputServerBase = {}));
170867
- function MediaInputServer2(config10) {
170868
- return MediaInputServerBase.set({ config: config10 });
170869
- }
170870
-
170871
- // src/matter/endpoints/legacy/media-player/behaviors/media-player-media-input-server.ts
170872
- var MediaPlayerMediaInputServer = MediaInputServer2({
170873
- getCurrentSource: (entity) => entity.attributes.source,
170874
- getSourceList: (entity) => entity.attributes.source_list,
170875
- selectSource: (source) => ({
170876
- action: "media_player.select_source",
170877
- data: { source }
170878
- })
170879
- });
170880
-
170881
170884
  // src/matter/endpoints/legacy/media-player/behaviors/media-player-on-off-server.ts
170882
170885
  var MediaPlayerOnOffServer = OnOffServer2({
170883
170886
  isOn: (state) => {