Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ enum MQTT_MANAGER_SETTING {
OPTIMISTIC_MODE,
LIGHT_TURN_ON_BRIGHTNESS,
DEFAULT_NSPANEL_TYPE,
BUZZER_SOUND_TOUCH,
BUZZER_SOUND_SCENE_ACTIVATED,
BUZZER_SOUND_SCENE_SAVED,
LAST, // Keep last as to be able to reference the last element in the list.
};

Expand Down Expand Up @@ -228,6 +231,9 @@ class MqttManagerConfig {
{MQTT_MANAGER_SETTING::OPTIMISTIC_MODE, {"optimistic_mode", "True"}},
{MQTT_MANAGER_SETTING::LIGHT_TURN_ON_BRIGHTNESS, {"light_turn_on_brightness", "50"}},
{MQTT_MANAGER_SETTING::DEFAULT_NSPANEL_TYPE, {"default_nspanel_type", "eu"}},
{MQTT_MANAGER_SETTING::BUZZER_SOUND_TOUCH, {"buzzer_sound_touch", ""}}, // RTTTL, empty for no sound
{MQTT_MANAGER_SETTING::BUZZER_SOUND_SCENE_ACTIVATED, {"buzzer_sound_scene_activated", ""}},
{MQTT_MANAGER_SETTING::BUZZER_SOUND_SCENE_SAVED, {"buzzer_sound_scene_saved", ""}},
#if defined(TEST_MODE) && TEST_MODE == 1
{MQTT_MANAGER_SETTING::LAST, {"last", "last_value"}},
#endif
Expand Down
17 changes: 17 additions & 0 deletions docker/MQTTManager/include/nspanel/nspanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include <string>
#include <sys/stat.h>
#include <system_error>
#include <tuple>
#include <vector>
#include <websocket_server/websocket_server.hpp>

NSPanel::NSPanel(uint32_t id) {
Expand Down Expand Up @@ -479,6 +481,21 @@ void NSPanel::send_config() {
SPDLOG_WARN("No global entities pages were loaded while building config for NSPanel {}::{}", this->_id, this->_name);
}

// Load buzzer sounds. A panel setting overrides the global one, an empty value means no sound for that event.
const std::vector<std::tuple<NSPanelConfig_NSPanelSoundEvent, std::string, MQTT_MANAGER_SETTING>> sound_settings = {
{NSPanelConfig_NSPanelSoundEvent_TOUCH, "buzzer_sound_touch", MQTT_MANAGER_SETTING::BUZZER_SOUND_TOUCH},
{NSPanelConfig_NSPanelSoundEvent_SCENE_ACTIVATED, "buzzer_sound_scene_activated", MQTT_MANAGER_SETTING::BUZZER_SOUND_SCENE_ACTIVATED},
{NSPanelConfig_NSPanelSoundEvent_SCENE_SAVED, "buzzer_sound_scene_saved", MQTT_MANAGER_SETTING::BUZZER_SOUND_SCENE_SAVED},
};
for (const auto &[event, nspanel_setting_key, global_setting] : sound_settings) {
std::string rtttl = this->_get_nspanel_setting_with_default(nspanel_setting_key, MqttManagerConfig::get_setting_with_default<std::string>(global_setting));
if (!rtttl.empty()) {
NSPanelConfig_Sound *sound = config.add_sounds();
sound->set_event(event);
sound->set_rtttl(rtttl);
}
}

SPDLOG_DEBUG("Sending updated NSPanelConfig to panel {}::{} over MQTT.", this->_id, this->_name);
MQTT_Manager::publish_protobuf(this->_mqtt_config_topic, config, true);
}
Expand Down
Loading
Loading