| 16 | #include <switch/switch.hpp> |
| 17 | |
| 18 | NSPMButton::NSPMButton(uint32_t button_id) : ButtonEntity(button_id) { |
| 19 | // Process Home Assistant specific details. General button data is loaded in the "Button" constructor. |
| 20 | |
| 21 | if (this->_controller != MQTT_MANAGER_ENTITY_CONTROLLER::HOME_ASSISTANT) { |
| 22 | SPDLOG_ERROR("HomeAssistantSwitch has not been recognized as controlled by HOME_ASSISTANT. Will stop processing switch."); |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | auto db_switch = database_manager::database.get<database_manager::Entity>(this->_id); |
| 27 | nlohmann::json entity_data = db_switch.get_entity_data_json(); |
| 28 | if (entity_data.contains("home_assistant_name")) { |
| 29 | this->_home_assistant_name = entity_data["home_assistant_name"]; |
| 30 | } else { |
| 31 | SPDLOG_ERROR("No Home Assistant name defined for switch {}::{}", this->_id, this->_name); |
| 32 | } |
| 33 | SPDLOG_DEBUG("Loaded Switch {}::{}, home assistant entity ID: {}", this->_id, this->_name, this->_home_assistant_name); |
| 34 | } |
| 35 | |
| 36 | NSPMButton::~NSPMButton() { |
| 37 | } |
nothing calls this directly
no test coverage detected