feat(hass): add PlayPlaylist voice command
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-10-09 00:34:58 -04:00
parent 0a5eb4ffe5
commit a4d2b936d9
14 changed files with 433 additions and 71 deletions

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Generated using NetDaemon CodeGenerator nd-codegen v24.37.1.0 // Generated using NetDaemon CodeGenerator nd-codegen v24.37.1.0
// At: 2024-10-05T16:11:38.2552699-04:00 // At: 2024-10-08T21:14:58.2735702-04:00
// //
// *** Make sure the version of the codegen tool and your nugets Joysoftware.NetDaemon.* have the same version.*** // *** Make sure the version of the codegen tool and your nugets Joysoftware.NetDaemon.* have the same version.***
// You can use following command to keep it up to date with the latest version: // You can use following command to keep it up to date with the latest version:
@ -82,6 +82,7 @@ public static class GeneratedExtensions
serviceCollection.AddTransient<InputNumberServices>(); serviceCollection.AddTransient<InputNumberServices>();
serviceCollection.AddTransient<InputSelectServices>(); serviceCollection.AddTransient<InputSelectServices>();
serviceCollection.AddTransient<InputTextServices>(); serviceCollection.AddTransient<InputTextServices>();
serviceCollection.AddTransient<IntentScriptServices>();
serviceCollection.AddTransient<LightServices>(); serviceCollection.AddTransient<LightServices>();
serviceCollection.AddTransient<LockServices>(); serviceCollection.AddTransient<LockServices>();
serviceCollection.AddTransient<LogbookServices>(); serviceCollection.AddTransient<LogbookServices>();
@ -105,6 +106,7 @@ public static class GeneratedExtensions
serviceCollection.AddTransient<SpotifyplusServices>(); serviceCollection.AddTransient<SpotifyplusServices>();
serviceCollection.AddTransient<SwitchServices>(); serviceCollection.AddTransient<SwitchServices>();
serviceCollection.AddTransient<SystemLogServices>(); serviceCollection.AddTransient<SystemLogServices>();
serviceCollection.AddTransient<TemplateServices>();
serviceCollection.AddTransient<TimerServices>(); serviceCollection.AddTransient<TimerServices>();
serviceCollection.AddTransient<TodoServices>(); serviceCollection.AddTransient<TodoServices>();
serviceCollection.AddTransient<TtsServices>(); serviceCollection.AddTransient<TtsServices>();
@ -271,8 +273,6 @@ public partial class BinarySensorEntities
public IEnumerable<BinarySensorEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("binary_sensor.")).Select(e => new BinarySensorEntity(e)); public IEnumerable<BinarySensorEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("binary_sensor.")).Select(e => new BinarySensorEntity(e));
///<summary>CODA-4680-FIZ WAN status</summary> ///<summary>CODA-4680-FIZ WAN status</summary>
public BinarySensorEntity Coda4680FizWanStatus => new(_haContext, "binary_sensor.coda_4680_fiz_wan_status"); public BinarySensorEntity Coda4680FizWanStatus => new(_haContext, "binary_sensor.coda_4680_fiz_wan_status");
///<summary>M5Stack Atom Echo 31196c Assist in progress</summary>
public BinarySensorEntity M5stackAtomEcho131196cAssistInProgress => new(_haContext, "binary_sensor.m5stack_atom_echo_1_31196c_assist_in_progress");
///<summary>M5Stack Atom Echo 31196c Button</summary> ///<summary>M5Stack Atom Echo 31196c Button</summary>
public BinarySensorEntity M5stackAtomEcho131196cButton => new(_haContext, "binary_sensor.m5stack_atom_echo_1_31196c_button"); public BinarySensorEntity M5stackAtomEcho131196cButton => new(_haContext, "binary_sensor.m5stack_atom_echo_1_31196c_button");
///<summary>Pixel 8 Bluetooth state</summary> ///<summary>Pixel 8 Bluetooth state</summary>
@ -343,6 +343,8 @@ public partial class ConversationEntities
/// <summary>Enumerates all conversation entities currently registered (at runtime) in Home Assistant as ConversationEntity</summary> /// <summary>Enumerates all conversation entities currently registered (at runtime) in Home Assistant as ConversationEntity</summary>
public IEnumerable<ConversationEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("conversation.")).Select(e => new ConversationEntity(e)); public IEnumerable<ConversationEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("conversation.")).Select(e => new ConversationEntity(e));
///<summary>Fallback Conversation Agent</summary>
public ConversationEntity FallbackConversationAgent => new(_haContext, "conversation.fallback_conversation_agent");
///<summary>Home Assistant</summary> ///<summary>Home Assistant</summary>
public ConversationEntity HomeAssistant => new(_haContext, "conversation.home_assistant"); public ConversationEntity HomeAssistant => new(_haContext, "conversation.home_assistant");
} }
@ -359,6 +361,8 @@ public partial class DeviceTrackerEntities
public IEnumerable<DeviceTrackerEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("device_tracker.")).Select(e => new DeviceTrackerEntity(e)); public IEnumerable<DeviceTrackerEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("device_tracker.")).Select(e => new DeviceTrackerEntity(e));
///<summary>Pixel 8</summary> ///<summary>Pixel 8</summary>
public DeviceTrackerEntity Pixel8 => new(_haContext, "device_tracker.pixel_8"); public DeviceTrackerEntity Pixel8 => new(_haContext, "device_tracker.pixel_8");
///<summary>Z Flip 6</summary>
public DeviceTrackerEntity SmF741w => new(_haContext, "device_tracker.sm_f741w");
} }
public partial class InputBooleanEntities public partial class InputBooleanEntities
@ -371,8 +375,10 @@ public partial class InputBooleanEntities
/// <summary>Enumerates all input_boolean entities currently registered (at runtime) in Home Assistant as InputBooleanEntity</summary> /// <summary>Enumerates all input_boolean entities currently registered (at runtime) in Home Assistant as InputBooleanEntity</summary>
public IEnumerable<InputBooleanEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("input_boolean.")).Select(e => new InputBooleanEntity(e)); public IEnumerable<InputBooleanEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("input_boolean.")).Select(e => new InputBooleanEntity(e));
///<summary>netdaemon_app_model_test_script</summary> ///<summary>netdaemon_spotify_play_album</summary>
public InputBooleanEntity NetdaemonAppModelTestScript => new(_haContext, "input_boolean.netdaemon_app_model_test_script"); public InputBooleanEntity NetdaemonSpotifyPlayAlbum => new(_haContext, "input_boolean.netdaemon_spotify_play_album");
///<summary>netdaemon_spotify_play_artist</summary>
public InputBooleanEntity NetdaemonSpotifyPlayArtist => new(_haContext, "input_boolean.netdaemon_spotify_play_artist");
} }
public partial class InputTextEntities public partial class InputTextEntities
@ -403,7 +409,7 @@ public partial class LockEntities
/// <summary>Enumerates all lock entities currently registered (at runtime) in Home Assistant as LockEntity</summary> /// <summary>Enumerates all lock entities currently registered (at runtime) in Home Assistant as LockEntity</summary>
public IEnumerable<LockEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("lock.")).Select(e => new LockEntity(e)); public IEnumerable<LockEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("lock.")).Select(e => new LockEntity(e));
///<summary>Smartplug 1 Child lock</summary> ///<summary>Smartplug1 Child lock</summary>
public LockEntity Smartplug1ChildLock => new(_haContext, "lock.smartplug_1_child_lock"); public LockEntity Smartplug1ChildLock => new(_haContext, "lock.smartplug_1_child_lock");
///<summary>Smartplug2 Child lock</summary> ///<summary>Smartplug2 Child lock</summary>
public LockEntity Smartplug2ChildLock => new(_haContext, "lock.smartplug2_child_lock"); public LockEntity Smartplug2ChildLock => new(_haContext, "lock.smartplug2_child_lock");
@ -421,7 +427,7 @@ public partial class NumberEntities
/// <summary>Enumerates all number entities currently registered (at runtime) in Home Assistant as NumberEntity</summary> /// <summary>Enumerates all number entities currently registered (at runtime) in Home Assistant as NumberEntity</summary>
public IEnumerable<NumberEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("number.")).Select(e => new NumberEntity(e)); public IEnumerable<NumberEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("number.")).Select(e => new NumberEntity(e));
///<summary>Smartplug 1 Timer</summary> ///<summary>Smartplug1 Timer</summary>
public NumberEntity Smartplug1Timer => new(_haContext, "number.smartplug_1_timer"); public NumberEntity Smartplug1Timer => new(_haContext, "number.smartplug_1_timer");
///<summary>Smartplug2 Timer</summary> ///<summary>Smartplug2 Timer</summary>
public NumberEntity Smartplug2Timer => new(_haContext, "number.smartplug2_timer"); public NumberEntity Smartplug2Timer => new(_haContext, "number.smartplug2_timer");
@ -439,8 +445,10 @@ public partial class PersonEntities
/// <summary>Enumerates all person entities currently registered (at runtime) in Home Assistant as PersonEntity</summary> /// <summary>Enumerates all person entities currently registered (at runtime) in Home Assistant as PersonEntity</summary>
public IEnumerable<PersonEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("person.")).Select(e => new PersonEntity(e)); public IEnumerable<PersonEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("person.")).Select(e => new PersonEntity(e));
///<summary>Mathis Hurtubise</summary> ///<summary>Matt</summary>
public PersonEntity MathisHurtubise => new(_haContext, "person.mathis_hurtubise"); public PersonEntity Matt => new(_haContext, "person.matt");
///<summary>Wifey &lt;3</summary>
public PersonEntity Wifey => new(_haContext, "person.wifey");
} }
public partial class RemoteEntities public partial class RemoteEntities
@ -473,8 +481,6 @@ public partial class ScriptEntities
public ScriptEntity AssistTimerstart => new(_haContext, "script.assist_timerstart"); public ScriptEntity AssistTimerstart => new(_haContext, "script.assist_timerstart");
///<summary>Assist - TimerStop</summary> ///<summary>Assist - TimerStop</summary>
public ScriptEntity AssistTimerstop => new(_haContext, "script.assist_timerstop"); public ScriptEntity AssistTimerstop => new(_haContext, "script.assist_timerstop");
///<summary>Spotify - Play Artist</summary>
public ScriptEntity PlayArtist => new(_haContext, "script.play_artist");
///<summary>Music - TurnOnUE</summary> ///<summary>Music - TurnOnUE</summary>
public ScriptEntity TurnOnUe => new(_haContext, "script.turn_on_ue"); public ScriptEntity TurnOnUe => new(_haContext, "script.turn_on_ue");
} }
@ -489,15 +495,15 @@ public partial class SelectEntities
/// <summary>Enumerates all select entities currently registered (at runtime) in Home Assistant as SelectEntity</summary> /// <summary>Enumerates all select entities currently registered (at runtime) in Home Assistant as SelectEntity</summary>
public IEnumerable<SelectEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("select.")).Select(e => new SelectEntity(e)); public IEnumerable<SelectEntity> EnumerateAll() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("select.")).Select(e => new SelectEntity(e));
///<summary>M5Stack Atom Echo 31196c Assist pipeline</summary> ///<summary>M5Stack Atom Echo 31196c Assistant</summary>
public SelectEntity M5stackAtomEcho131196cAssistPipeline => new(_haContext, "select.m5stack_atom_echo_1_31196c_assist_pipeline"); public SelectEntity M5stackAtomEcho131196cAssistPipeline => new(_haContext, "select.m5stack_atom_echo_1_31196c_assist_pipeline");
///<summary>M5Stack Atom Echo 31196c Finished speaking detection</summary> ///<summary>M5Stack Atom Echo 31196c Finished speaking detection</summary>
public SelectEntity M5stackAtomEcho131196cFinishedSpeakingDetection => new(_haContext, "select.m5stack_atom_echo_1_31196c_finished_speaking_detection"); public SelectEntity M5stackAtomEcho131196cFinishedSpeakingDetection => new(_haContext, "select.m5stack_atom_echo_1_31196c_finished_speaking_detection");
///<summary>M5Stack Atom Echo 31196c Wake word engine location</summary> ///<summary>M5Stack Atom Echo 31196c Wake word engine location</summary>
public SelectEntity M5stackAtomEcho131196cWakeWordEngineLocation => new(_haContext, "select.m5stack_atom_echo_1_31196c_wake_word_engine_location"); public SelectEntity M5stackAtomEcho131196cWakeWordEngineLocation => new(_haContext, "select.m5stack_atom_echo_1_31196c_wake_word_engine_location");
///<summary>Smartplug 1 Initial state</summary> ///<summary>Smartplug1 Initial state</summary>
public SelectEntity Smartplug1InitialState => new(_haContext, "select.smartplug_1_initial_state"); public SelectEntity Smartplug1InitialState => new(_haContext, "select.smartplug_1_initial_state");
///<summary>Smartplug 1 Light mode</summary> ///<summary>Smartplug1 Light mode</summary>
public SelectEntity Smartplug1LightMode => new(_haContext, "select.smartplug_1_light_mode"); public SelectEntity Smartplug1LightMode => new(_haContext, "select.smartplug_1_light_mode");
///<summary>Smartplug2 Initial state</summary> ///<summary>Smartplug2 Initial state</summary>
public SelectEntity Smartplug2InitialState => new(_haContext, "select.smartplug2_initial_state"); public SelectEntity Smartplug2InitialState => new(_haContext, "select.smartplug2_initial_state");
@ -525,6 +531,10 @@ public partial class SensorEntities
public IEnumerable<NumericSensorEntity> EnumerateAllNumeric() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("sensor.") && (e.EntityState?.AttributesJson?.TryGetProperty("unit_of_measurement", out _) ?? false)).Select(e => new NumericSensorEntity(e)); public IEnumerable<NumericSensorEntity> EnumerateAllNumeric() => _haContext.GetAllEntities().Where(e => e.EntityId.StartsWith("sensor.") && (e.EntityState?.AttributesJson?.TryGetProperty("unit_of_measurement", out _) ?? false)).Select(e => new NumericSensorEntity(e));
///<summary>CODA-4680-FIZ External IP</summary> ///<summary>CODA-4680-FIZ External IP</summary>
public SensorEntity Coda4680FizExternalIp => new(_haContext, "sensor.coda_4680_fiz_external_ip"); public SensorEntity Coda4680FizExternalIp => new(_haContext, "sensor.coda_4680_fiz_external_ip");
///<summary>Material Rounded Base Color Matt</summary>
public SensorEntity MaterialRoundedBaseColorMatt => new(_haContext, "sensor.material_rounded_base_color_matt");
///<summary>Pixel 8 Accent color</summary>
public SensorEntity Pixel8AccentColor => new(_haContext, "sensor.pixel_8_accent_color");
///<summary>Pixel 8 Audio mode</summary> ///<summary>Pixel 8 Audio mode</summary>
public SensorEntity Pixel8AudioMode => new(_haContext, "sensor.pixel_8_audio_mode"); public SensorEntity Pixel8AudioMode => new(_haContext, "sensor.pixel_8_audio_mode");
///<summary>Pixel 8 Battery health</summary> ///<summary>Pixel 8 Battery health</summary>
@ -587,6 +597,10 @@ public partial class SensorEntities
public SensorEntity Pixel8WifiConnection => new(_haContext, "sensor.pixel_8_wifi_connection"); public SensorEntity Pixel8WifiConnection => new(_haContext, "sensor.pixel_8_wifi_connection");
///<summary>Pixel 8 WiFi IP address</summary> ///<summary>Pixel 8 WiFi IP address</summary>
public SensorEntity Pixel8WifiIpAddress => new(_haContext, "sensor.pixel_8_wifi_ip_address"); public SensorEntity Pixel8WifiIpAddress => new(_haContext, "sensor.pixel_8_wifi_ip_address");
///<summary>SM-F741W Battery state</summary>
public SensorEntity SmF741wBatteryState => new(_haContext, "sensor.sm_f741w_battery_state");
///<summary>SM-F741W Charger type</summary>
public SensorEntity SmF741wChargerType => new(_haContext, "sensor.sm_f741w_charger_type");
///<summary>Sun Next dawn</summary> ///<summary>Sun Next dawn</summary>
public SensorEntity SunNextDawn => new(_haContext, "sensor.sun_next_dawn"); public SensorEntity SunNextDawn => new(_haContext, "sensor.sun_next_dawn");
///<summary>Sun Next dusk</summary> ///<summary>Sun Next dusk</summary>
@ -599,6 +613,10 @@ public partial class SensorEntities
public SensorEntity SunNextRising => new(_haContext, "sensor.sun_next_rising"); public SensorEntity SunNextRising => new(_haContext, "sensor.sun_next_rising");
///<summary>Sun Next setting</summary> ///<summary>Sun Next setting</summary>
public SensorEntity SunNextSetting => new(_haContext, "sensor.sun_next_setting"); public SensorEntity SunNextSetting => new(_haContext, "sensor.sun_next_setting");
///<summary>CODA-4680-FIZ Data received</summary>
public NumericSensorEntity Coda4680FizDataReceived => new(_haContext, "sensor.coda_4680_fiz_data_received");
///<summary>CODA-4680-FIZ Data sent</summary>
public NumericSensorEntity Coda4680FizDataSent => new(_haContext, "sensor.coda_4680_fiz_data_sent");
///<summary>CODA-4680-FIZ Download speed</summary> ///<summary>CODA-4680-FIZ Download speed</summary>
public NumericSensorEntity Coda4680FizDownloadSpeed => new(_haContext, "sensor.coda_4680_fiz_download_speed"); public NumericSensorEntity Coda4680FizDownloadSpeed => new(_haContext, "sensor.coda_4680_fiz_download_speed");
///<summary>CODA-4680-FIZ Upload speed</summary> ///<summary>CODA-4680-FIZ Upload speed</summary>
@ -623,6 +641,8 @@ public partial class SensorEntities
public NumericSensorEntity Pixel8WifiLinkSpeed => new(_haContext, "sensor.pixel_8_wifi_link_speed"); public NumericSensorEntity Pixel8WifiLinkSpeed => new(_haContext, "sensor.pixel_8_wifi_link_speed");
///<summary>Pixel 8 WiFi signal strength</summary> ///<summary>Pixel 8 WiFi signal strength</summary>
public NumericSensorEntity Pixel8WifiSignalStrength => new(_haContext, "sensor.pixel_8_wifi_signal_strength"); public NumericSensorEntity Pixel8WifiSignalStrength => new(_haContext, "sensor.pixel_8_wifi_signal_strength");
///<summary>SM-F741W Battery level</summary>
public NumericSensorEntity SmF741wBatteryLevel => new(_haContext, "sensor.sm_f741w_battery_level");
} }
public partial class SttEntities public partial class SttEntities
@ -670,7 +690,7 @@ public partial class SwitchEntities
///<summary>Salon Lamp</summary> ///<summary>Salon Lamp</summary>
public SwitchEntity Smartplug1 => new(_haContext, "switch.smartplug1"); public SwitchEntity Smartplug1 => new(_haContext, "switch.smartplug1");
///<summary>Smartplug2 None</summary> ///<summary>Smartplug2 None</summary>
public SwitchEntity Smartplug2None => new(_haContext, "switch.smartplug2_none"); public SwitchEntity Smartplug2 => new(_haContext, "switch.smartplug2");
///<summary>Office Lamp</summary> ///<summary>Office Lamp</summary>
public SwitchEntity Smartplug3 => new(_haContext, "switch.smartplug3"); public SwitchEntity Smartplug3 => new(_haContext, "switch.smartplug3");
} }
@ -1113,6 +1133,27 @@ public partial record DeviceTrackerAttributes
[JsonPropertyName("friendly_name")] [JsonPropertyName("friendly_name")]
public string? FriendlyName { get; init; } public string? FriendlyName { get; init; }
[JsonPropertyName("latitude")]
public double? Latitude { get; init; }
[JsonPropertyName("longitude")]
public double? Longitude { get; init; }
[JsonPropertyName("gps_accuracy")]
public double? GpsAccuracy { get; init; }
[JsonPropertyName("altitude")]
public double? Altitude { get; init; }
[JsonPropertyName("course")]
public double? Course { get; init; }
[JsonPropertyName("speed")]
public double? Speed { get; init; }
[JsonPropertyName("vertical_accuracy")]
public double? VerticalAccuracy { get; init; }
} }
public partial record InputBooleanEntity : Entity<InputBooleanEntity, EntityState<InputBooleanAttributes>, InputBooleanAttributes>, IInputBooleanEntityCore public partial record InputBooleanEntity : Entity<InputBooleanEntity, EntityState<InputBooleanAttributes>, InputBooleanAttributes>, IInputBooleanEntityCore
@ -1252,6 +1293,18 @@ public partial record PersonAttributes
[JsonPropertyName("friendly_name")] [JsonPropertyName("friendly_name")]
public string? FriendlyName { get; init; } public string? FriendlyName { get; init; }
[JsonPropertyName("latitude")]
public double? Latitude { get; init; }
[JsonPropertyName("longitude")]
public double? Longitude { get; init; }
[JsonPropertyName("gps_accuracy")]
public double? GpsAccuracy { get; init; }
[JsonPropertyName("source")]
public string? Source { get; init; }
} }
public partial record RemoteEntity : Entity<RemoteEntity, EntityState<RemoteAttributes>, RemoteAttributes>, IRemoteEntityCore public partial record RemoteEntity : Entity<RemoteEntity, EntityState<RemoteAttributes>, RemoteAttributes>, IRemoteEntityCore
@ -1392,6 +1445,33 @@ public partial record SensorAttributes
[JsonPropertyName("metered")] [JsonPropertyName("metered")]
public bool? Metered { get; init; } public bool? Metered { get; init; }
[JsonPropertyName("rgb_color")]
public IReadOnlyList<double>? RgbColor { get; init; }
[JsonPropertyName("album_com.spotify.music")]
public string? AlbumCom_spotify_music { get; init; }
[JsonPropertyName("artist_com.spotify.music")]
public string? ArtistCom_spotify_music { get; init; }
[JsonPropertyName("duration_com.spotify.music")]
public double? DurationCom_spotify_music { get; init; }
[JsonPropertyName("media_id_com.spotify.music")]
public string? MediaIdCom_spotify_music { get; init; }
[JsonPropertyName("playback_position_com.spotify.music")]
public double? PlaybackPositionCom_spotify_music { get; init; }
[JsonPropertyName("playback_state_com.spotify.music")]
public string? PlaybackStateCom_spotify_music { get; init; }
[JsonPropertyName("title_com.spotify.music")]
public string? TitleCom_spotify_music { get; init; }
[JsonPropertyName("total_media_session_count")]
public double? TotalMediaSessionCount { get; init; }
} }
public partial record NumericSensorEntity : NumericEntity<NumericSensorEntity, NumericEntityState<NumericSensorAttributes>, NumericSensorAttributes>, ISensorEntityCore public partial record NumericSensorEntity : NumericEntity<NumericSensorEntity, NumericEntityState<NumericSensorAttributes>, NumericSensorAttributes>, ISensorEntityCore
@ -1671,6 +1751,9 @@ public partial record WeatherAttributes
[JsonPropertyName("supported_features")] [JsonPropertyName("supported_features")]
public double? SupportedFeatures { get; init; } public double? SupportedFeatures { get; init; }
[JsonPropertyName("uv_index")]
public double? UvIndex { get; init; }
} }
public partial record ZoneEntity : Entity<ZoneEntity, EntityState<ZoneAttributes>, ZoneAttributes>, IZoneEntityCore public partial record ZoneEntity : Entity<ZoneEntity, EntityState<ZoneAttributes>, ZoneAttributes>, IZoneEntityCore
@ -1699,7 +1782,7 @@ public partial record ZoneAttributes
public bool? Passive { get; init; } public bool? Passive { get; init; }
[JsonPropertyName("persons")] [JsonPropertyName("persons")]
public IReadOnlyList<object>? Persons { get; init; } public object? Persons { get; init; }
[JsonPropertyName("editable")] [JsonPropertyName("editable")]
public bool? Editable { get; init; } public bool? Editable { get; init; }
@ -1751,6 +1834,8 @@ public interface IServices
InputTextServices InputText { get; } InputTextServices InputText { get; }
IntentScriptServices IntentScript { get; }
LightServices Light { get; } LightServices Light { get; }
LockServices Lock { get; } LockServices Lock { get; }
@ -1797,6 +1882,8 @@ public interface IServices
SystemLogServices SystemLog { get; } SystemLogServices SystemLog { get; }
TemplateServices Template { get; }
TimerServices Timer { get; } TimerServices Timer { get; }
TodoServices Todo { get; } TodoServices Todo { get; }
@ -1835,6 +1922,7 @@ public partial class Services : IServices
public InputNumberServices InputNumber => new(_haContext); public InputNumberServices InputNumber => new(_haContext);
public InputSelectServices InputSelect => new(_haContext); public InputSelectServices InputSelect => new(_haContext);
public InputTextServices InputText => new(_haContext); public InputTextServices InputText => new(_haContext);
public IntentScriptServices IntentScript => new(_haContext);
public LightServices Light => new(_haContext); public LightServices Light => new(_haContext);
public LockServices Lock => new(_haContext); public LockServices Lock => new(_haContext);
public LogbookServices Logbook => new(_haContext); public LogbookServices Logbook => new(_haContext);
@ -1858,6 +1946,7 @@ public partial class Services : IServices
public SpotifyplusServices Spotifyplus => new(_haContext); public SpotifyplusServices Spotifyplus => new(_haContext);
public SwitchServices Switch => new(_haContext); public SwitchServices Switch => new(_haContext);
public SystemLogServices SystemLog => new(_haContext); public SystemLogServices SystemLog => new(_haContext);
public TemplateServices Template => new(_haContext);
public TimerServices Timer => new(_haContext); public TimerServices Timer => new(_haContext);
public TodoServices Todo => new(_haContext); public TodoServices Todo => new(_haContext);
public TtsServices Tts => new(_haContext); public TtsServices Tts => new(_haContext);
@ -3132,6 +3221,21 @@ public partial record InputTextSetValueParameters
public string? Value { get; init; } public string? Value { get; init; }
} }
public partial class IntentScriptServices
{
private readonly IHaContext _haContext;
public IntentScriptServices(IHaContext haContext)
{
_haContext = haContext;
}
///<summary>Reloads the intent script from the YAML-configuration.</summary>
public void Reload(object? data = null)
{
_haContext.CallService("intent_script", "reload", null, data);
}
}
public partial class LightServices public partial class LightServices
{ {
private readonly IHaContext _haContext; private readonly IHaContext _haContext;
@ -3825,11 +3929,6 @@ public partial class NetdaemonServices
_haContext = haContext; _haContext = haContext;
} }
public void CallbackDemo(object? data = null)
{
_haContext.CallService("netdaemon", "callback_demo", null, data);
}
///<summary>Create an entity</summary> ///<summary>Create an entity</summary>
public void EntityCreate(NetdaemonEntityCreateParameters data) public void EntityCreate(NetdaemonEntityCreateParameters data)
{ {
@ -3898,6 +3997,16 @@ public partial class NetdaemonServices
{ {
_haContext.CallService("netdaemon", "reload_apps", null, data); _haContext.CallService("netdaemon", "reload_apps", null, data);
} }
public void SpotifyPlayAlbum(object? data = null)
{
_haContext.CallService("netdaemon", "spotify_play_album", null, data);
}
public void SpotifyPlayArtist(object? data = null)
{
_haContext.CallService("netdaemon", "spotify_play_artist", null, data);
}
} }
public partial record NetdaemonEntityCreateParameters public partial record NetdaemonEntityCreateParameters
@ -4000,6 +4109,22 @@ public partial class NotifyServices
_haContext.CallService("notify", "mobile_app_pixel_8", null, new NotifyMobileAppPixel8Parameters { Message = message, Title = title, Target = target, Data = data }); _haContext.CallService("notify", "mobile_app_pixel_8", null, new NotifyMobileAppPixel8Parameters { Message = message, Title = title, Target = target, Data = data });
} }
///<summary>Sends a notification message using the mobile_app_z_flip_6 integration.</summary>
public void MobileAppZFlip6(NotifyMobileAppZFlip6Parameters data)
{
_haContext.CallService("notify", "mobile_app_z_flip_6", null, data);
}
///<summary>Sends a notification message using the mobile_app_z_flip_6 integration.</summary>
///<param name="message"> eg: The garage door has been open for 10 minutes.</param>
///<param name="title"> eg: Your Garage Door Friend</param>
///<param name="target"> eg: platform specific</param>
///<param name="data"> eg: platform specific</param>
public void MobileAppZFlip6(string message, string? title = null, object? target = null, object? data = null)
{
_haContext.CallService("notify", "mobile_app_z_flip_6", null, new NotifyMobileAppZFlip6Parameters { Message = message, Title = title, Target = target, Data = data });
}
///<summary>Sends a notification message using the notify service.</summary> ///<summary>Sends a notification message using the notify service.</summary>
public void Notify(NotifyNotifyParameters data) public void Notify(NotifyNotifyParameters data)
{ {
@ -4066,6 +4191,25 @@ public partial record NotifyMobileAppPixel8Parameters
public object? Data { get; init; } public object? Data { get; init; }
} }
public partial record NotifyMobileAppZFlip6Parameters
{
///<summary> eg: The garage door has been open for 10 minutes.</summary>
[JsonPropertyName("message")]
public string? Message { get; init; }
///<summary> eg: Your Garage Door Friend</summary>
[JsonPropertyName("title")]
public string? Title { get; init; }
///<summary> eg: platform specific</summary>
[JsonPropertyName("target")]
public object? Target { get; init; }
///<summary> eg: platform specific</summary>
[JsonPropertyName("data")]
public object? Data { get; init; }
}
public partial record NotifyNotifyParameters public partial record NotifyNotifyParameters
{ {
///<summary> eg: The garage door has been open for 10 minutes.</summary> ///<summary> eg: The garage door has been open for 10 minutes.</summary>
@ -4631,16 +4775,6 @@ public partial class ScriptServices
return _haContext.CallServiceWithResponseAsync("script", "assist_timerstop", null, data); return _haContext.CallServiceWithResponseAsync("script", "assist_timerstop", null, data);
} }
public void PlayArtist(object? data = null)
{
_haContext.CallService("script", "play_artist", null, data);
}
public Task<JsonElement?> PlayArtistAsync(object? data = null)
{
return _haContext.CallServiceWithResponseAsync("script", "play_artist", null, data);
}
///<summary>Reloads all the available scripts.</summary> ///<summary>Reloads all the available scripts.</summary>
public void Reload(object? data = null) public void Reload(object? data = null)
{ {
@ -5840,9 +5974,10 @@ public partial class SpotifyplusServices
///<param name="offset">The page index offset of the first item to return. Use with limit to get the next set of items. Default is 0 (the first item). eg: 0</param> ///<param name="offset">The page index offset of the first item to return. Use with limit to get the next set of items. Default is 0 (the first item). eg: 0</param>
///<param name="limitTotal">The maximum number of items to return for the request. If specified, this argument overrides the limit and offset argument values and paging is automatically used to retrieve all available items up to the specified limit total. eg: 20</param> ///<param name="limitTotal">The maximum number of items to return for the request. If specified, this argument overrides the limit and offset argument values and paging is automatically used to retrieve all available items up to the specified limit total. eg: 20</param>
///<param name="sortResult">True to sort result items by name prior to returning to the caller; otherwise, False to return results in the order that the Spotify Web API returned them. eg: True</param> ///<param name="sortResult">True to sort result items by name prior to returning to the caller; otherwise, False to return results in the order that the Spotify Web API returned them. eg: True</param>
public void GetShowFavorites(string entityId, double? limit = null, double? offset = null, double? limitTotal = null, bool? sortResult = null) ///<param name="excludeAudiobooks">True (default) to exclude audiobook shows from the returned list, leaving only podcast shows; otherwise, False to include all results returned by the Spotify Web API. eg: True</param>
public void GetShowFavorites(string entityId, double? limit = null, double? offset = null, double? limitTotal = null, bool? sortResult = null, bool? excludeAudiobooks = null)
{ {
_haContext.CallService("spotifyplus", "get_show_favorites", null, new SpotifyplusGetShowFavoritesParameters { EntityId = entityId, Limit = limit, Offset = offset, LimitTotal = limitTotal, SortResult = sortResult }); _haContext.CallService("spotifyplus", "get_show_favorites", null, new SpotifyplusGetShowFavoritesParameters { EntityId = entityId, Limit = limit, Offset = offset, LimitTotal = limitTotal, SortResult = sortResult, ExcludeAudiobooks = excludeAudiobooks });
} }
///<summary>Get a list of the shows saved in the current Spotify user&apos;s &apos;Your Library&apos;.</summary> ///<summary>Get a list of the shows saved in the current Spotify user&apos;s &apos;Your Library&apos;.</summary>
@ -5857,9 +5992,10 @@ public partial class SpotifyplusServices
///<param name="offset">The page index offset of the first item to return. Use with limit to get the next set of items. Default is 0 (the first item). eg: 0</param> ///<param name="offset">The page index offset of the first item to return. Use with limit to get the next set of items. Default is 0 (the first item). eg: 0</param>
///<param name="limitTotal">The maximum number of items to return for the request. If specified, this argument overrides the limit and offset argument values and paging is automatically used to retrieve all available items up to the specified limit total. eg: 20</param> ///<param name="limitTotal">The maximum number of items to return for the request. If specified, this argument overrides the limit and offset argument values and paging is automatically used to retrieve all available items up to the specified limit total. eg: 20</param>
///<param name="sortResult">True to sort result items by name prior to returning to the caller; otherwise, False to return results in the order that the Spotify Web API returned them. eg: True</param> ///<param name="sortResult">True to sort result items by name prior to returning to the caller; otherwise, False to return results in the order that the Spotify Web API returned them. eg: True</param>
public Task<JsonElement?> GetShowFavoritesAsync(string entityId, double? limit = null, double? offset = null, double? limitTotal = null, bool? sortResult = null) ///<param name="excludeAudiobooks">True (default) to exclude audiobook shows from the returned list, leaving only podcast shows; otherwise, False to include all results returned by the Spotify Web API. eg: True</param>
public Task<JsonElement?> GetShowFavoritesAsync(string entityId, double? limit = null, double? offset = null, double? limitTotal = null, bool? sortResult = null, bool? excludeAudiobooks = null)
{ {
return _haContext.CallServiceWithResponseAsync("spotifyplus", "get_show_favorites", null, new SpotifyplusGetShowFavoritesParameters { EntityId = entityId, Limit = limit, Offset = offset, LimitTotal = limitTotal, SortResult = sortResult }); return _haContext.CallServiceWithResponseAsync("spotifyplus", "get_show_favorites", null, new SpotifyplusGetShowFavoritesParameters { EntityId = entityId, Limit = limit, Offset = offset, LimitTotal = limitTotal, SortResult = sortResult, ExcludeAudiobooks = excludeAudiobooks });
} }
///<summary>Get information about a specific Spotify Connect player device, and (optionally) activate the device if it requires it.</summary> ///<summary>Get information about a specific Spotify Connect player device, and (optionally) activate the device if it requires it.</summary>
@ -6178,13 +6314,30 @@ public partial class SpotifyplusServices
_haContext.CallService("spotifyplus", "player_media_play_tracks", null, new SpotifyplusPlayerMediaPlayTracksParameters { EntityId = entityId, Uris = uris, PositionMs = positionMs, DeviceId = deviceId, Delay = delay }); _haContext.CallService("spotifyplus", "player_media_play_tracks", null, new SpotifyplusPlayerMediaPlayTracksParameters { EntityId = entityId, Uris = uris, PositionMs = positionMs, DeviceId = deviceId, Delay = delay });
} }
///<summary>Resolves a Spotify Connect device identifier from a specified device id, name, alias id, or alias name. This will ensure that the device id can be found on the network, as well as connect to the device if necessary with the current user context. </summary> ///<summary>Seeks to the given absolute or relative position in the user&apos;s currently playing track for the specified Spotify Connect device.</summary>
public void PlayerMediaSeek(SpotifyplusPlayerMediaSeekParameters data)
{
_haContext.CallService("spotifyplus", "player_media_seek", null, data);
}
///<summary>Seeks to the given absolute or relative position in the user&apos;s currently playing track for the specified Spotify Connect device.</summary>
///<param name="entityId">Entity ID of the SpotifyPlus device that will make the request to the Spotify Web API. eg: media_player.spotifyplus_username</param>
///<param name="positionMs">The absolute position in milliseconds to seek to; must be a positive number or zero if the `relativePositionMS` argument is specified. Passing in a position that is greater than the length of the track will cause the player to start playing the next song. Example = `25000` to start playing at the 25 second mark. eg: 25000</param>
///<param name="deviceId">The id or name of the Spotify Connect Player device this command is targeting. If not supplied, the user&apos;s currently active device is the target. If no device is active (or an &apos;*&apos; is specified), then the SpotifyPlus default device is activated. eg: 0d1841b0976bae2a3a310dd74c0f337465899bc8</param>
///<param name="delay">Time delay (in seconds) to wait AFTER issuing the final Connect command (if necessary). This delay will give the spotify web api time to process the device list change before another command is issued. Default is 0.50; value range is 0 - 10. eg: 0.50</param>
///<param name="relativePositionMs">The relative position in milliseconds to seek to; can be a positive or negative number, or zero if the `positionMS` argument is specified. Example = `-10000` to seek behind by 10 seconds; `10000` to seek ahead by 10 seconds. eg: 10000</param>
public void PlayerMediaSeek(string entityId, double? positionMs = null, string? deviceId = null, double? delay = null, double? relativePositionMs = null)
{
_haContext.CallService("spotifyplus", "player_media_seek", null, new SpotifyplusPlayerMediaSeekParameters { EntityId = entityId, PositionMs = positionMs, DeviceId = deviceId, Delay = delay, RelativePositionMs = relativePositionMs });
}
///<summary>Resolves a Spotify Connect device identifier from a specified device id, name, alias id, or alias name. This will ensure that the device id can be found on the network, as well as connect to the device if necessary with the current user context.</summary>
public void PlayerResolveDeviceId(SpotifyplusPlayerResolveDeviceIdParameters data) public void PlayerResolveDeviceId(SpotifyplusPlayerResolveDeviceIdParameters data)
{ {
_haContext.CallService("spotifyplus", "player_resolve_device_id", null, data); _haContext.CallService("spotifyplus", "player_resolve_device_id", null, data);
} }
///<summary>Resolves a Spotify Connect device identifier from a specified device id, name, alias id, or alias name. This will ensure that the device id can be found on the network, as well as connect to the device if necessary with the current user context. </summary> ///<summary>Resolves a Spotify Connect device identifier from a specified device id, name, alias id, or alias name. This will ensure that the device id can be found on the network, as well as connect to the device if necessary with the current user context.</summary>
///<param name="entityId">Entity ID of the SpotifyPlus device that will make the request to the Spotify Web API. eg: media_player.spotifyplus_username</param> ///<param name="entityId">Entity ID of the SpotifyPlus device that will make the request to the Spotify Web API. eg: media_player.spotifyplus_username</param>
///<param name="deviceValue">The device id (e.g. &apos;0d1841b0976bae2a3a310dd74c0f337465899bc8&apos;) or name (e.g. &apos;Bose-ST10-1&apos;) value to resolve. eg: Bose-ST10-1</param> ///<param name="deviceValue">The device id (e.g. &apos;0d1841b0976bae2a3a310dd74c0f337465899bc8&apos;) or name (e.g. &apos;Bose-ST10-1&apos;) value to resolve. eg: Bose-ST10-1</param>
///<param name="verifyUserContext">If True, the active user context of the resolved device is checked to ensure it matches the user context specified on the class constructor. If False, the user context will not be checked. Default is True. eg: True</param> ///<param name="verifyUserContext">If True, the active user context of the resolved device is checked to ensure it matches the user context specified on the class constructor. If False, the user context will not be checked. Default is True. eg: True</param>
@ -6194,13 +6347,13 @@ public partial class SpotifyplusServices
_haContext.CallService("spotifyplus", "player_resolve_device_id", null, new SpotifyplusPlayerResolveDeviceIdParameters { EntityId = entityId, DeviceValue = deviceValue, VerifyUserContext = verifyUserContext, VerifyTimeout = verifyTimeout }); _haContext.CallService("spotifyplus", "player_resolve_device_id", null, new SpotifyplusPlayerResolveDeviceIdParameters { EntityId = entityId, DeviceValue = deviceValue, VerifyUserContext = verifyUserContext, VerifyTimeout = verifyTimeout });
} }
///<summary>Resolves a Spotify Connect device identifier from a specified device id, name, alias id, or alias name. This will ensure that the device id can be found on the network, as well as connect to the device if necessary with the current user context. </summary> ///<summary>Resolves a Spotify Connect device identifier from a specified device id, name, alias id, or alias name. This will ensure that the device id can be found on the network, as well as connect to the device if necessary with the current user context.</summary>
public Task<JsonElement?> PlayerResolveDeviceIdAsync(SpotifyplusPlayerResolveDeviceIdParameters data) public Task<JsonElement?> PlayerResolveDeviceIdAsync(SpotifyplusPlayerResolveDeviceIdParameters data)
{ {
return _haContext.CallServiceWithResponseAsync("spotifyplus", "player_resolve_device_id", null, data); return _haContext.CallServiceWithResponseAsync("spotifyplus", "player_resolve_device_id", null, data);
} }
///<summary>Resolves a Spotify Connect device identifier from a specified device id, name, alias id, or alias name. This will ensure that the device id can be found on the network, as well as connect to the device if necessary with the current user context. </summary> ///<summary>Resolves a Spotify Connect device identifier from a specified device id, name, alias id, or alias name. This will ensure that the device id can be found on the network, as well as connect to the device if necessary with the current user context.</summary>
///<param name="entityId">Entity ID of the SpotifyPlus device that will make the request to the Spotify Web API. eg: media_player.spotifyplus_username</param> ///<param name="entityId">Entity ID of the SpotifyPlus device that will make the request to the Spotify Web API. eg: media_player.spotifyplus_username</param>
///<param name="deviceValue">The device id (e.g. &apos;0d1841b0976bae2a3a310dd74c0f337465899bc8&apos;) or name (e.g. &apos;Bose-ST10-1&apos;) value to resolve. eg: Bose-ST10-1</param> ///<param name="deviceValue">The device id (e.g. &apos;0d1841b0976bae2a3a310dd74c0f337465899bc8&apos;) or name (e.g. &apos;Bose-ST10-1&apos;) value to resolve. eg: Bose-ST10-1</param>
///<param name="verifyUserContext">If True, the active user context of the resolved device is checked to ensure it matches the user context specified on the class constructor. If False, the user context will not be checked. Default is True. eg: True</param> ///<param name="verifyUserContext">If True, the active user context of the resolved device is checked to ensure it matches the user context specified on the class constructor. If False, the user context will not be checked. Default is True. eg: True</param>
@ -7560,6 +7713,10 @@ public partial record SpotifyplusGetShowFavoritesParameters
///<summary>True to sort result items by name prior to returning to the caller; otherwise, False to return results in the order that the Spotify Web API returned them. eg: True</summary> ///<summary>True to sort result items by name prior to returning to the caller; otherwise, False to return results in the order that the Spotify Web API returned them. eg: True</summary>
[JsonPropertyName("sort_result")] [JsonPropertyName("sort_result")]
public bool? SortResult { get; init; } public bool? SortResult { get; init; }
///<summary>True (default) to exclude audiobook shows from the returned list, leaving only podcast shows; otherwise, False to include all results returned by the Spotify Web API. eg: True</summary>
[JsonPropertyName("exclude_audiobooks")]
public bool? ExcludeAudiobooks { get; init; }
} }
public partial record SpotifyplusGetSpotifyConnectDeviceParameters public partial record SpotifyplusGetSpotifyConnectDeviceParameters
@ -7807,6 +7964,29 @@ public partial record SpotifyplusPlayerMediaPlayTracksParameters
public double? Delay { get; init; } public double? Delay { get; init; }
} }
public partial record SpotifyplusPlayerMediaSeekParameters
{
///<summary>Entity ID of the SpotifyPlus device that will make the request to the Spotify Web API. eg: media_player.spotifyplus_username</summary>
[JsonPropertyName("entity_id")]
public string? EntityId { get; init; }
///<summary>The absolute position in milliseconds to seek to; must be a positive number or zero if the `relativePositionMS` argument is specified. Passing in a position that is greater than the length of the track will cause the player to start playing the next song. Example = `25000` to start playing at the 25 second mark. eg: 25000</summary>
[JsonPropertyName("position_ms")]
public double? PositionMs { get; init; }
///<summary>The id or name of the Spotify Connect Player device this command is targeting. If not supplied, the user&apos;s currently active device is the target. If no device is active (or an &apos;*&apos; is specified), then the SpotifyPlus default device is activated. eg: 0d1841b0976bae2a3a310dd74c0f337465899bc8</summary>
[JsonPropertyName("device_id")]
public string? DeviceId { get; init; }
///<summary>Time delay (in seconds) to wait AFTER issuing the final Connect command (if necessary). This delay will give the spotify web api time to process the device list change before another command is issued. Default is 0.50; value range is 0 - 10. eg: 0.50</summary>
[JsonPropertyName("delay")]
public double? Delay { get; init; }
///<summary>The relative position in milliseconds to seek to; can be a positive or negative number, or zero if the `positionMS` argument is specified. Example = `-10000` to seek behind by 10 seconds; `10000` to seek ahead by 10 seconds. eg: 10000</summary>
[JsonPropertyName("relative_position_ms")]
public double? RelativePositionMs { get; init; }
}
public partial record SpotifyplusPlayerResolveDeviceIdParameters public partial record SpotifyplusPlayerResolveDeviceIdParameters
{ {
///<summary>Entity ID of the SpotifyPlus device that will make the request to the Spotify Web API. eg: media_player.spotifyplus_username</summary> ///<summary>Entity ID of the SpotifyPlus device that will make the request to the Spotify Web API. eg: media_player.spotifyplus_username</summary>
@ -8583,6 +8763,21 @@ public partial record SystemLogWriteParameters
public string? Logger { get; init; } public string? Logger { get; init; }
} }
public partial class TemplateServices
{
private readonly IHaContext _haContext;
public TemplateServices(IHaContext haContext)
{
_haContext = haContext;
}
///<summary>Reloads template entities from the YAML-configuration.</summary>
public void Reload(object? data = null)
{
_haContext.CallService("template", "reload", null, data);
}
}
public partial class TimerServices public partial class TimerServices
{ {
private readonly IHaContext _haContext; private readonly IHaContext _haContext;

View file

@ -0,0 +1,87 @@
namespace Spotify;
using FuzzySharp;
using FuzzySharp.Extractor;
using HomeAssistantGenerated;
using NetDaemon.AppModel;
using NetDaemon.HassModel;
using NetDaemon.HassModel.Integration;
using System;
using System.Collections.Generic;
using System.Text.Json;
record PlayPlaylistData(string? playlist);
[NetDaemonApp]
public class PlayPlaylist
{
// Snake-case json options
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
};
public PlayPlaylist(IHaContext ha)
{
ha.RegisterServiceCallBack<PlayPlaylistData>(
"spotify_play_playlist",
async (e) =>
{
string? query = e?.playlist;
var result = (await ha.CallServiceWithResponseAsync(
"spotifyplus",
"get_playlist_favorites",
data: new SpotifyplusGetPlaylistFavoritesParameters
{
Limit = 50,
EntityId = "media_player.spotifyplus",
SortResult = true,
}
)).Value.Deserialize<SpotifyplusPlaylistResponse>(_jsonOptions);
List<PlaylistsItem>? myPlaylists = result?.Result?.Items;
if (query is not null && myPlaylists is not null)
{
PlaylistsItem Query = new();
Query.Name = query.ToLower();
ExtractedResult<PlaylistsItem> match = Process.ExtractOne<PlaylistsItem>(
Query,
myPlaylists,
new Func<PlaylistsItem, string>((item) => (item.Name ?? "").ToLower())
);
string uri = match.Value!.Uri!;
if (match.Score < 85)
{
var otherResult = (await ha.CallServiceWithResponseAsync(
"spotifyplus",
"search_playlists",
data: new SpotifyplusSearchPlaylistsParameters
{
Criteria = query,
Limit = 1,
EntityId = "media_player.spotifyplus",
}
)).Value.Deserialize<SpotifyplusPlaylistResponse>(_jsonOptions);
uri = otherResult!.Result!.Items![0]!.Uri!;
}
ha.CallService(
"spotifyplus",
"player_media_play_context",
data: new SpotifyplusPlayerMediaPlayContextParameters
{
ContextUri = uri,
EntityId = "media_player.spotifyplus"
}
);
}
}
);
}
}

View file

@ -0,0 +1,38 @@
namespace Spotify;
using System.Collections.Generic;
public class PlaylistsItem
{
public bool Collaborative { get; set; }
public string? Description { get; set; }
public ExternalUrls? ExternalUrls { get; set; }
public string? Href { get; set; }
public string? Id { get; set; }
public string? ImageUrl { get; set; }
public List<Image>? Images { get; set; }
public string? Name { get; set; }
public Owner? Owner { get; set; }
public bool? Public { get; set; }
public string? SnapshotId { get; set; }
public Tracks? Tracks { get; set; }
public string? Type { get; set; }
public string? Uri { get; set; }
}
public record PlaylistsResult
{
public string? Href { get; set; }
public int Limit { get; set; }
public object? Next { get; set; }
public int Offset { get; set; }
public object? Previous { get; set; }
public int Total { get; set; }
public List<PlaylistsItem>? Items { get; set; }
}
public class SpotifyplusPlaylistResponse
{
public UserProfile? UserProfile { get; set; }
public PlaylistsResult? Result { get; set; }
}

View file

@ -35,8 +35,25 @@ public record Followers
public record Image public record Image
{ {
public string? Url { get; init; } public string? Url { get; init; }
public int Height { get; init; } public int? Height { get; init; }
public int Width { get; init; } public int? Width { get; init; }
}
public class Owner
{
public string? DisplayName { get; set; }
public ExternalUrls? ExternalUrls { get; set; }
public Followers? Followers { get; set; }
public string? Href { get; set; }
public string? Id { get; set; }
public string? Type { get; set; }
public string? Uri { get; set; }
}
public class Tracks
{
public string? Href { get; set; }
public int Total { get; set; }
} }
public record Restrictions { } public record Restrictions { }

View file

@ -68,7 +68,7 @@ in {
done done
done done
${compiled.fetch-deps} . $(nix build --no-link --print-out-paths --impure --expr "let self = builtins.getFlake (\"$FLAKE\"); inherit (self.nixosConfigurations.homie) pkgs; in (pkgs.callPackage $FLAKE/devices/homie/modules/home-assistant/netdaemon/package.nix {}).fetch-deps") .
alejandra . alejandra .
rm -r "$FLAKE/.config" rm -r "$FLAKE/.config"
''; '';

View file

@ -6,6 +6,11 @@
version = "0.8.4"; version = "0.8.4";
hash = "sha256-L9rLcqnQybPoJCcg60h49bjXfqEarM9SFHqOJUMvxz8="; hash = "sha256-L9rLcqnQybPoJCcg60h49bjXfqEarM9SFHqOJUMvxz8=";
}) })
(fetchNuGet {
pname = "FuzzySharp";
version = "2.0.2";
hash = "sha256-GuWqVOo+AG8MSvIbusLPjKfJFQRJhSSJ9eGWljTBA/c=";
})
(fetchNuGet { (fetchNuGet {
pname = "Microsoft.Extensions.Configuration"; pname = "Microsoft.Extensions.Configuration";
version = "8.0.0"; version = "8.0.0";

View file

@ -34,5 +34,6 @@
<PackageReference Include="NetDaemon.Extensions.Scheduling" Version="24.37.1" /> <PackageReference Include="NetDaemon.Extensions.Scheduling" Version="24.37.1" />
<PackageReference Include="NetDaemon.Extensions.Logging" Version="24.37.1" /> <PackageReference Include="NetDaemon.Extensions.Logging" Version="24.37.1" />
<PackageReference Include="NetDaemon.Extensions.Tts" Version="24.37.1" /> <PackageReference Include="NetDaemon.Extensions.Tts" Version="24.37.1" />
<PackageReference Include="FuzzySharp" Version="2.0.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -2,15 +2,6 @@
language = "en"; language = "en";
intents = { intents = {
PlayArtist.data = [
{
sentences = [
"play[ing] [some] music from [the] [artist] {artist}"
"play[ing] [the] artist {artist}"
];
}
];
PlayAlbum.data = [ PlayAlbum.data = [
{ {
sentences = [ sentences = [
@ -24,18 +15,32 @@
slots.artist = ""; slots.artist = "";
} }
]; ];
PlayArtist.data = [
{
sentences = [
"play[ing] [some] music from [the] [artist] {artist}"
"play[ing] [the] artist {artist}"
];
}
];
PlayPlaylist.data = [
{
sentences = [
"play[ing] [the] playlist {playlist}"
];
}
];
}; };
lists = { lists = {
artist.wildcard = true;
album.wildcard = true; album.wildcard = true;
artist.wildcard = true;
playlist.wildcard = true;
}; };
responses.intents = { responses.intents = {
PlayArtist.default = ''
Searching for {{ slots.artist }} on Spotify and playing their top songs.
'';
PlayAlbum.default = '' PlayAlbum.default = ''
Searching for the album {{ slots.album }} Searching for the album {{ slots.album }}
{% if slots.artist != "" %} {% if slots.artist != "" %}
@ -43,5 +48,13 @@
{% endif %} {% endif %}
on Spotify and playing it. on Spotify and playing it.
''; '';
PlayArtist.default = ''
Searching for the artist {{ slots.artist }} on Spotify and playing their top songs.
'';
PlayPlaylist.default = ''
Searching for {{ slots.playlist }} in your favorites, or elsewhere if not found, and playing it.
'';
}; };
} }

View file

@ -35,16 +35,6 @@ in {
]; ];
config.intent_script = { config.intent_script = {
PlayArtist = {
async_action = "false";
action = [
{
service = "netdaemon.spotify_play_artist";
data.artist = "{{ artist }}";
}
];
};
PlayAlbum = { PlayAlbum = {
async_action = "false"; async_action = "false";
action = [ action = [
@ -57,6 +47,26 @@ in {
} }
]; ];
}; };
PlayArtist = {
async_action = "false";
action = [
{
service = "netdaemon.spotify_play_artist";
data.artist = "{{ artist }}";
}
];
};
PlayPlaylist = {
async_action = "false";
action = [
{
service = "netdaemon.spotify_play_playlist";
data.playlist = "{{ playlist }}";
}
];
};
}; };
}; };
} }

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

@ -227,10 +227,6 @@ let
owner = "fwartner"; owner = "fwartner";
repo = "home-assistant-wakewords-collection"; repo = "home-assistant-wakewords-collection";
} }
{
owner = "don86nl";
repo = "ha_intents";
}
{ {
owner = "berti24"; owner = "berti24";
repo = "dracul-ha"; repo = "dracul-ha";

View file

@ -182,7 +182,6 @@
nodejs_latest nodejs_latest
; ;
}; };
text = '' text = ''
npm i --package-lock-only || true # this command will fail but still updates the main lockfile npm i --package-lock-only || true # this command will fail but still updates the main lockfile
prefetch-npm-deps ./package-lock.json prefetch-npm-deps ./package-lock.json