esphome/esphome/components/mqtt/mqtt_climate.h
puuu 1d136ab0df MQTT climate features (#913)
* mqtt_climate: add action support

* mqtt_climate: add fan and swing mode support

* mqtt_climate: reduce length of discovery payload by using abbreviations

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/mqtt/abbreviations.py
2020-02-09 13:20:56 +01:00

50 lines
1.5 KiB
C++

#pragma once
#include "esphome/core/defines.h"
#ifdef USE_CLIMATE
#include "esphome/components/climate/climate.h"
#include "mqtt_component.h"
namespace esphome {
namespace mqtt {
class MQTTClimateComponent : public mqtt::MQTTComponent {
public:
MQTTClimateComponent(climate::Climate *device);
void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override;
bool send_initial_state() override;
bool is_internal() override;
std::string component_type() const override;
void setup() override;
MQTT_COMPONENT_CUSTOM_TOPIC(current_temperature, state)
MQTT_COMPONENT_CUSTOM_TOPIC(mode, state)
MQTT_COMPONENT_CUSTOM_TOPIC(mode, command)
MQTT_COMPONENT_CUSTOM_TOPIC(target_temperature, state)
MQTT_COMPONENT_CUSTOM_TOPIC(target_temperature, command)
MQTT_COMPONENT_CUSTOM_TOPIC(target_temperature_low, state)
MQTT_COMPONENT_CUSTOM_TOPIC(target_temperature_low, command)
MQTT_COMPONENT_CUSTOM_TOPIC(target_temperature_high, state)
MQTT_COMPONENT_CUSTOM_TOPIC(target_temperature_high, command)
MQTT_COMPONENT_CUSTOM_TOPIC(away, state)
MQTT_COMPONENT_CUSTOM_TOPIC(away, command)
MQTT_COMPONENT_CUSTOM_TOPIC(action, state)
MQTT_COMPONENT_CUSTOM_TOPIC(fan_mode, state)
MQTT_COMPONENT_CUSTOM_TOPIC(fan_mode, command)
MQTT_COMPONENT_CUSTOM_TOPIC(swing_mode, state)
MQTT_COMPONENT_CUSTOM_TOPIC(swing_mode, command)
protected:
std::string friendly_name() const override;
bool publish_state_();
climate::Climate *device_;
};
} // namespace mqtt
} // namespace esphome
#endif