mirror of
https://github.com/esphome/esphome.git
synced 2026-09-22 20:48:43 +00:00
Add device class support to Switch (#3012)
Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
This commit is contained in:
co-authored by
Oxan van Leeuwen
parent
21803607e7
commit
e7864a28a1
@@ -46,5 +46,12 @@ void Switch::set_inverted(bool inverted) { this->inverted_ = inverted; }
|
||||
uint32_t Switch::hash_base() { return 3129890955UL; }
|
||||
bool Switch::is_inverted() const { return this->inverted_; }
|
||||
|
||||
std::string Switch::get_device_class() {
|
||||
if (this->device_class_.has_value())
|
||||
return *this->device_class_;
|
||||
return "";
|
||||
}
|
||||
void Switch::set_device_class(const std::string &device_class) { this->device_class_ = device_class; }
|
||||
|
||||
} // namespace switch_
|
||||
} // namespace esphome
|
||||
|
||||
Reference in New Issue
Block a user