22static const char *
const TAG =
"sendspin.hub";
26 this->
client_ = std::make_unique<sendspin::SendspinClient>(std::move(config));
31#ifdef USE_SENDSPIN_PLAYER
36 this->
client_->set_listener(
this);
37 this->
client_->set_network_provider(
this);
38 this->
client_->set_persistence_provider(
this);
40#ifdef USE_SENDSPIN_CONTROLLER
45#ifdef USE_SENDSPIN_METADATA
50#ifdef USE_SENDSPIN_PLAYER
54 if (!this->
client_->start_server()) {
55 ESP_LOGE(TAG,
"Failed to start Sendspin server");
64 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
68 " Task stack in PSRAM: %s",
84 this->
client_->disconnect(reason);
91 this->
client_->update_state(state);
108 sendspin::SendspinClientConfig config;
110 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
114 config.manufacturer =
"ESPHome";
115 config.software_version = ESPHOME_VERSION;
156 ESP_LOGD(TAG,
"Persisted last played server hash: 0x%08X", hash);
158 ESP_LOGW(TAG,
"Failed to persist last played server hash");
167 ESP_LOGI(TAG,
"Loaded last played server hash: 0x%08X", pref.server_id_hash);
168 return pref.server_id_hash;
175#ifdef USE_SENDSPIN_CONTROLLER
178 std::optional<bool> mute) {
190#ifdef USE_SENDSPIN_METADATA
205#ifdef USE_SENDSPIN_PLAYER
209 return this->
client_->player();
219 ESP_LOGD(TAG,
"Persisted static delay: %u ms", delay_ms);
221 ESP_LOGW(TAG,
"Failed to persist static delay");
230 ESP_LOGI(TAG,
"Loaded static delay: %u ms", pref.delay_ms);
231 return pref.delay_ms;
const StringRef & get_name() const
Get the name of this Application set by pre_setup().
const StringRef & get_friendly_name() const
Get the friendly name of this Application set by pre_setup().
void mark_failed()
Mark this component as failed.
ESPDEPRECATED("Use get_eth_mac_address_pretty_into_buffer() instead. Removed in 2026.9.0", "2026.3.0") std const char * get_eth_mac_address_pretty_into_buffer(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
sendspin::PlayerRoleListener * player_listener_
void update_state(sendspin::SendspinClientState state)
Updates the client's reported playback state on the server.
bool save_last_server_hash(uint32_t hash) override
bool save_static_delay(uint16_t delay_ms) override
CallbackManager< void(const sendspin::ServerMetadataStateObject &)> metadata_update_callbacks_
CallbackManager< void(const sendspin::ServerStateControllerObject &)> controller_state_callbacks_
static const char * get_client_id_into_buffer(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
Writes the active network interface's MAC into buf and returns its data pointer.
void on_release_high_performance() override
bool is_network_ready() override
sendspin::MetadataRole * metadata_role_
CallbackManager< void(const sendspin::GroupUpdateObject &)> group_update_callbacks_
sendspin::PlayerRoleConfig player_config_
void on_metadata(const sendspin::ServerMetadataStateObject &metadata) override
void dump_config() override
sendspin::PlayerRole * get_player_role()
Child components call this to get the PlayerRole instance after setup, so they can push updates to it...
void disconnect_from_server(sendspin::SendspinGoodbyeReason reason)
Disconnects the underlying client from the current server.
std::optional< uint16_t > load_static_delay() override
std::unique_ptr< sendspin::SendspinClient > client_
sendspin::SendspinClientConfig build_client_config_()
Builds the SendspinClientConfig from ESPHome configuration and platform info.
sendspin::ControllerRole * controller_role_
ESPPreferenceObject last_played_server_pref_
bool task_stack_in_psram_
uint32_t get_track_progress_ms() const
Returns the interpolated track progress in milliseconds, or 0 if the hub is not yet ready.
void send_client_command(sendspin::SendspinControllerCommand command, std::optional< uint8_t > volume=std::nullopt, std::optional< bool > mute=std::nullopt)
ESPPreferenceObject static_delay_pref_
void on_request_high_performance() override
std::optional< uint32_t > load_last_server_hash() override
void on_controller_state(const sendspin::ServerStateControllerObject &state) override
void connect_to_server(const std::string &url)
Connects the underlying client to the given Sendspin server.
void on_group_update(const sendspin::GroupUpdateObject &group) override
bool request_high_performance()
Request high-performance mode (no power saving) for improved WiFi latency.
bool release_high_performance()
Release a high-performance mode request.
EthernetComponent * global_eth_component
ESPHOME_ALWAYS_INLINE bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
WiFiComponent * global_wifi_component
ESPPreferences * global_preferences
const char * get_mac_address_pretty_into_buffer(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
Get the device MAC address into the given buffer, in colon-separated uppercase hex notation.
Application App
Global storage of Application pointer - only one Application can exist.
constexpr uint32_t fnv1a_hash(const char *str)
Calculate a FNV-1a hash of str.
ESPPreferenceObject make_preference(size_t, uint32_t, bool)
Persistent storage structure for last played server hash.
Persistent storage structure for player static delay.