mirror of
https://github.com/esphome/esphome.git
synced 2024-12-04 04:28:19 +01:00
parent
8439232b11
commit
f2e8e655ba
2 changed files with 15 additions and 8 deletions
|
@ -80,8 +80,7 @@ const EntityBase *MQTTAlarmControlPanelComponent::get_entity() const { return th
|
||||||
|
|
||||||
bool MQTTAlarmControlPanelComponent::send_initial_state() { return this->publish_state(); }
|
bool MQTTAlarmControlPanelComponent::send_initial_state() { return this->publish_state(); }
|
||||||
bool MQTTAlarmControlPanelComponent::publish_state() {
|
bool MQTTAlarmControlPanelComponent::publish_state() {
|
||||||
bool success = true;
|
const char *state_s;
|
||||||
const char *state_s = "";
|
|
||||||
switch (this->alarm_control_panel_->get_state()) {
|
switch (this->alarm_control_panel_->get_state()) {
|
||||||
case ACP_STATE_DISARMED:
|
case ACP_STATE_DISARMED:
|
||||||
state_s = "disarmed";
|
state_s = "disarmed";
|
||||||
|
@ -116,9 +115,7 @@ bool MQTTAlarmControlPanelComponent::publish_state() {
|
||||||
default:
|
default:
|
||||||
state_s = "unknown";
|
state_s = "unknown";
|
||||||
}
|
}
|
||||||
if (!this->publish(this->get_state_topic_(), state_s))
|
return this->publish(this->get_state_topic_(), state_s);
|
||||||
success = false;
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mqtt
|
} // namespace mqtt
|
||||||
|
|
|
@ -257,7 +257,7 @@ const EntityBase *MQTTClimateComponent::get_entity() const { return this->device
|
||||||
bool MQTTClimateComponent::publish_state_() {
|
bool MQTTClimateComponent::publish_state_() {
|
||||||
auto traits = this->device_->get_traits();
|
auto traits = this->device_->get_traits();
|
||||||
// mode
|
// mode
|
||||||
const char *mode_s = "";
|
const char *mode_s;
|
||||||
switch (this->device_->mode) {
|
switch (this->device_->mode) {
|
||||||
case CLIMATE_MODE_OFF:
|
case CLIMATE_MODE_OFF:
|
||||||
mode_s = "off";
|
mode_s = "off";
|
||||||
|
@ -280,6 +280,8 @@ bool MQTTClimateComponent::publish_state_() {
|
||||||
case CLIMATE_MODE_HEAT_COOL:
|
case CLIMATE_MODE_HEAT_COOL:
|
||||||
mode_s = "heat_cool";
|
mode_s = "heat_cool";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
mode_s = "unknown";
|
||||||
}
|
}
|
||||||
bool success = true;
|
bool success = true;
|
||||||
if (!this->publish(this->get_mode_state_topic(), mode_s))
|
if (!this->publish(this->get_mode_state_topic(), mode_s))
|
||||||
|
@ -343,6 +345,8 @@ bool MQTTClimateComponent::publish_state_() {
|
||||||
case CLIMATE_PRESET_ACTIVITY:
|
case CLIMATE_PRESET_ACTIVITY:
|
||||||
payload = "activity";
|
payload = "activity";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
payload = "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this->device_->custom_preset.has_value())
|
if (this->device_->custom_preset.has_value())
|
||||||
|
@ -352,7 +356,7 @@ bool MQTTClimateComponent::publish_state_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (traits.get_supports_action()) {
|
if (traits.get_supports_action()) {
|
||||||
const char *payload = "unknown";
|
const char *payload;
|
||||||
switch (this->device_->action) {
|
switch (this->device_->action) {
|
||||||
case CLIMATE_ACTION_OFF:
|
case CLIMATE_ACTION_OFF:
|
||||||
payload = "off";
|
payload = "off";
|
||||||
|
@ -372,6 +376,8 @@ bool MQTTClimateComponent::publish_state_() {
|
||||||
case CLIMATE_ACTION_FAN:
|
case CLIMATE_ACTION_FAN:
|
||||||
payload = "fan";
|
payload = "fan";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
payload = "unknown";
|
||||||
}
|
}
|
||||||
if (!this->publish(this->get_action_state_topic(), payload))
|
if (!this->publish(this->get_action_state_topic(), payload))
|
||||||
success = false;
|
success = false;
|
||||||
|
@ -411,6 +417,8 @@ bool MQTTClimateComponent::publish_state_() {
|
||||||
case CLIMATE_FAN_QUIET:
|
case CLIMATE_FAN_QUIET:
|
||||||
payload = "quiet";
|
payload = "quiet";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
payload = "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this->device_->custom_fan_mode.has_value())
|
if (this->device_->custom_fan_mode.has_value())
|
||||||
|
@ -420,7 +428,7 @@ bool MQTTClimateComponent::publish_state_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (traits.get_supports_swing_modes()) {
|
if (traits.get_supports_swing_modes()) {
|
||||||
const char *payload = "";
|
const char *payload;
|
||||||
switch (this->device_->swing_mode) {
|
switch (this->device_->swing_mode) {
|
||||||
case CLIMATE_SWING_OFF:
|
case CLIMATE_SWING_OFF:
|
||||||
payload = "off";
|
payload = "off";
|
||||||
|
@ -434,6 +442,8 @@ bool MQTTClimateComponent::publish_state_() {
|
||||||
case CLIMATE_SWING_HORIZONTAL:
|
case CLIMATE_SWING_HORIZONTAL:
|
||||||
payload = "horizontal";
|
payload = "horizontal";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
payload = "unknown";
|
||||||
}
|
}
|
||||||
if (!this->publish(this->get_swing_mode_state_topic(), payload))
|
if (!this->publish(this->get_swing_mode_state_topic(), payload))
|
||||||
success = false;
|
success = false;
|
||||||
|
|
Loading…
Reference in a new issue