Add volume number parser
This commit is contained in:
parent
811ac720d1
commit
274ff30d9c
|
@ -26,7 +26,8 @@ void tw7100Number::control(float value) {
|
||||||
|
|
||||||
std::string param;
|
std::string param;
|
||||||
if (cmd_ == "VOL") {
|
if (cmd_ == "VOL") {
|
||||||
ESP_LOGV(TAG, "VOL: ");
|
param = std::to_string((int)value);
|
||||||
|
ESP_LOGV(TAG, "VOL: %s (from %i)", param, (int)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param.length() > 0 && state != value) {
|
if (param.length() > 0 && state != value) {
|
||||||
|
|
|
@ -64,8 +64,8 @@ std::vector<std::string> pwr_on_query_cmds{
|
||||||
*/
|
*/
|
||||||
//
|
//
|
||||||
// Sound settings
|
// Sound settings
|
||||||
/*
|
|
||||||
"VOL?",
|
"VOL?",
|
||||||
|
/*
|
||||||
"AUDIOOUT?",
|
"AUDIOOUT?",
|
||||||
*/
|
*/
|
||||||
//
|
//
|
||||||
|
@ -247,8 +247,12 @@ void tw7100Component::update_sensor(std::pair<std::string, std::string> data) {
|
||||||
call.set_option(source_select_->sources[value_string]);
|
call.set_option(source_select_->sources[value_string]);
|
||||||
call.perform();
|
call.perform();
|
||||||
} else if (cmd == "MUTE") {
|
} else if (cmd == "MUTE") {
|
||||||
ESP_LOGV(TAG, "updating mute switch with value %s", value_string);
|
ESP_LOGV(TAG, "updating mute switch with value %s", value_string.c_str());
|
||||||
mute_switch_->publish_state(value_string == "ON");
|
mute_switch_->publish_state(value_string == "ON");
|
||||||
|
} else if (cmd == "VOL") {
|
||||||
|
int value = std::stoi(value_string);
|
||||||
|
volume_number_->publish_state(value);
|
||||||
|
ESP_LOGV(TAG, "updating volume number with value %s", value_string.c_str());
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "Command %s unknown, skipping updating sensor with value", cmd.c_str());
|
ESP_LOGW(TAG, "Command %s unknown, skipping updating sensor with value", cmd.c_str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue