connect the hostname ObservableValue to observers
@@ -25,11 +25,21 @@ SensESPApp::SensESPApp() {
// connect systemhz
- SystemHz* syshz = new SystemHz();
- Passthrough<float>* syshz_value = new Passthrough<float>("sensors.unknown.system_hz");
- syshz->attach([syshz, syshz_value](){ syshz_value->set_input(syshz->get()); });
- devices.push_back(syshz);
- computations.push_back(syshz_value);
+ SystemHz* syshz_dev = new SystemHz();
+ Passthrough<float>* syshz_comp = new Passthrough<float>(
+ "sensors.unknown.system_hz");
+ // update the SK path if hostname changes
+ hostname->attach(
+ [hostname, syshz_comp](){
+ syshz_comp->set_sk_path(String("sensors.") +
+ hostname->get() +
+ ".system_hz");
+ });
+ syshz_dev->attach([syshz_dev, syshz_comp](){
+ syshz_comp->set_input(syshz_dev->get());
+ });
+ devices.push_back(syshz_dev);
+ computations.push_back(syshz_comp);
// connect freemem
