MCPcopy Create free account
hub / github.com/NSPManager/NSPanelManager / NSPMButton

Method NSPMButton

docker/MQTTManager/include/button/nspm_button.cpp:18–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include <switch/switch.hpp>
17
18NSPMButton::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
36NSPMButton::~NSPMButton() {
37}

Callers

nothing calls this directly

Calls 1

get_entity_data_jsonMethod · 0.80

Tested by

no test coverage detected