@@ -62,29 +62,23 @@ void MqttManager::setDeviceData(String deviceName, String hardware, String devic
62
62
63
63
if (m_mqttDiscoveryEnabled)
64
64
{
65
- m_deviceStatusSensor = new MqttDiscoveryComponent (" binary_sensor" , m_deviceName + " Status" );
66
- m_deviceStatusSensor->discovery_prefix = discovery_prefix;
65
+ m_deviceStatusSensor = new MqttDiscoveryComponent (" binary_sensor" , m_deviceName + " Status" , discovery_prefix);
67
66
m_deviceStatusSensor->setConfigurtionVariable (" device_class" , " connectivity" );
68
67
m_discoveryComponents.push_back (m_deviceStatusSensor);
69
68
70
- m_deviceIpSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " IP" );
71
- m_deviceIpSensor->discovery_prefix = discovery_prefix;
69
+ m_deviceIpSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " IP" , discovery_prefix);
72
70
m_discoveryComponents.push_back (m_deviceIpSensor);
73
71
74
- m_deviceMacSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " MAC" );
75
- m_deviceMacSensor->discovery_prefix = discovery_prefix;
72
+ m_deviceMacSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " MAC" , discovery_prefix);
76
73
m_discoveryComponents.push_back (m_deviceMacSensor);
77
74
78
- m_deviceHardwareSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " Hardware" );
79
- m_deviceHardwareSensor->discovery_prefix = discovery_prefix;
75
+ m_deviceHardwareSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " Hardware" , discovery_prefix);
80
76
m_discoveryComponents.push_back (m_deviceHardwareSensor);
81
77
82
- m_deviceFirmwareSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " Firmware" );
83
- m_deviceFirmwareSensor->discovery_prefix = discovery_prefix;
78
+ m_deviceFirmwareSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " Firmware" , discovery_prefix);
84
79
m_discoveryComponents.push_back (m_deviceFirmwareSensor);
85
80
86
- m_deviceFirmwareVersionSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " Firmware Version" );
87
- m_deviceFirmwareVersionSensor->discovery_prefix = discovery_prefix;
81
+ m_deviceFirmwareVersionSensor = new MqttDiscoveryComponent (" sensor" , m_deviceName + " Firmware Version" , discovery_prefix);
88
82
m_discoveryComponents.push_back (m_deviceFirmwareVersionSensor);
89
83
90
84
this ->setLastWillMQTT (m_deviceStatusSensor->getStateTopic (), m_lastWillPayload);
0 commit comments