add device_id to commands, fix #826

This commit is contained in:
MichaelDvP
2022-12-22 13:03:37 +01:00
parent cfa486d8cc
commit 9cbb810fe4
9 changed files with 49 additions and 21 deletions

View File

@@ -273,6 +273,17 @@ bool EMSdevice::has_tag(const uint8_t tag) const {
return false;
}
// check if the device has a command on the with this tag.
bool EMSdevice::has_cmd(const int8_t id, const char * cmd) const {
uint8_t tag = DeviceValueTAG::TAG_HC1 + id - 1;
for (const auto & dv : devicevalues_) {
if ((id < 1 || dv.tag == tag) && dv.has_cmd && strcmp(dv.short_name, cmd) == 0) {
return true;
}
}
return false;
}
// list of registered device entries
// called from the command 'entities'
void EMSdevice::list_device_entries(JsonObject & output) const {
@@ -507,7 +518,7 @@ void EMSdevice::add_device_value(uint8_t tag,
}
// add the command to our library
Command::add(device_type_, short_name, f, fullname, flags);
Command::add(device_type_, device_id_, short_name, f, fullname, flags);
}
// single list of options