| 370 | } |
| 371 | |
| 372 | void Light::toggle() { |
| 373 | if (this->_current_state) { |
| 374 | this->turn_off(true); |
| 375 | } else { |
| 376 | // Apply default "turn on brightness" if it is requested to become 0 as that won't work. |
| 377 | if (this->_requested_brightness == 0) { |
| 378 | this->_requested_brightness = std::stoi(MqttManagerConfig::get_setting_with_default("light_turn_on_brightness", "50")); |
| 379 | } |
| 380 | this->turn_on(true); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | std::string_view Light::get_icon() { |
| 385 | if (this->get_state()) { |
no test coverage detected