Skip to content

Commit

Permalink
HA auto discovery - Add numbers for interval and scans netween connec…
Browse files Browse the repository at this point in the history
…ts (#1357)

To be able to set those values directly through the HA interface
  • Loading branch information
1technophile authored Dec 12, 2022
1 parent 1aabfb8 commit 31403d8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions main/ZmqttDiscovery.ino
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ void createDiscovery(const char* sensor_type,
if (payload_on[0]) {
if (strcmp(sensor_type, "button") == 0) {
sensor["pl_prs"] = payload_on; // payload_press for a button press
} else if (strcmp(sensor_type, "number") == 0) {
sensor["cmd_tpl"] = payload_on; // payload_on for a switch
} else {
sensor["pl_on"] = payload_on; // payload_on for a switch
}
Expand Down Expand Up @@ -924,21 +926,21 @@ void pubMqttDiscovery() {
# endif

# ifdef ZgatewayBT
createDiscovery("sensor", //set Type
createDiscovery("number", //set Type
subjectSYStoMQTT, "BT: Interval between scans", (char*)getUniqueId("interval", "").c_str(), //set state_topic,name,uniqueId
"", "", "{{ value_json.interval }}", //set availability_topic,device_class,value_template,
"", "", "ms", //set,payload_on,payload_off,unit_of_meas,
"", "", "{{ value_json.interval/1000 }}", //set availability_topic,device_class,value_template,
"{\"interval\":{{value*1000}}}", "", "s", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
"", "", true, subjectMQTTtoBTset, //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain,
stateClassNone //State Class
);
createDiscovery("sensor", //set Type
createDiscovery("number", //set Type
subjectSYStoMQTT, "BT: Connnect every X scan(s)", (char*)getUniqueId("scanbcnct", "").c_str(), //set state_topic,name,uniqueId
"", "", "{{ value_json.scanbcnct }}", //set availability_topic,device_class,value_template,
"", "", "", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
"", "", true, "", //set,payload_avalaible,payload_not avalaible ,is a gateway entity, command topic
"{\"scanbcnct\":{{value}}}", "", "", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
"", "", true, subjectMQTTtoBTset, //set,payload_avalaible,payload_not avalaible,is a gateway entity, command topic
"", "", "", "", false, // device name, device manufacturer, device model, device MAC, retain
stateClassNone //State Class
);
Expand Down

0 comments on commit 31403d8

Please sign in to comment.