You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did an implementation following example 17 for a pump (in a rainwater container) - but home app is behaving quite confused, sometimes it works, sometimes it does not. This seems to be limited to activating the faucet from the dashboard tile, when going "inside" the faucet tile it seems to work (probably some status info missing?)
Just double checked again if i did something different, but cannot find the spot...
Pump(SpanCharacteristic name, char mac) {
this->name = name;
remoteDevice = new SpanPoint(mac, sizeof(uint8_t), sizeof(sp_data), 1, true);
active = new Characteristic::Active(false, true);
level = new Characteristic::WaterLevel(0, true);
addLink(new waterValve(this));
}
struct waterValve : Service::Valve {
SpanCharacteristic *active=new Characteristic::Active(1, true); // the Active Characteristic is used to specify whether the Valve is Active (open) or Inactive (closed)
SpanCharacteristic *inUse=new Characteristic::InUse(0, true); // the InUser Characteristic is used to specify whether water is actually flowing through value
Pump *pump;
waterValve(Pump *p) {
pump = p;
new Characteristic::ValveType(Characteristic::ValveType::FAUCET);
}
boolean update() override { // HomeSpan calls this whenever the Home App requests a change in a Valve's Active Characteristic
if (pump->active->getVal()) { // here's where we use the pointer to Pump: ONLY if the Pump object itself is active---
bool go = active->getNewVal();
inUse->setVal(go); // --- do we update the InUse Characteristic to reflect a change in the status of flowing water.
}
return(true); // Note that the Valve itself will still change from Active to Inactive (or vice versa) regardless of the status of the Pump
}
void flow(bool active) {
uint8_t x = active ? sp_command_t::on : sp_command_t::off;
boolean success = pump->remoteDevice->send(&x);
logging(iINFO, "pump " + String(active?"on":"off") + " (" + String(success) + ")");
}
void loop() override { // Here we check if the Pump is turned on or off, and determine if that means we need to update the Valve
if (pump->active->getVal() && active->getVal() && !inUse->getVal()) { // If the Pump is Active, and the Valve is Active but NOT showing InUse...
inUse->setVal(1); // ...show Valve as InUse
flow(true);
}
else if (!pump->active->getVal() && inUse->getVal()) { // Otherwise, if the Pump is NOT Active but Valve IS showing InUse...
inUse->setVal(0); // ...show Valve as NOT InUse
flow(false);
}
}
}; // waterValve
void loop() {
if (remoteDevice) {
if (remoteDevice->get(&sp_data)) {
lastUpdate = getEpochTime();
if (sp_data.type == sp_datatype_t::level) {
level->setVal(sp_data.value);
logging(iDEBUG, "container:" + String(sp_data.value, 0) + "%");
}
}
}
}
uint32_t updated() {
return lastUpdate;
}
};
The text was updated successfully, but these errors were encountered:
I'll review in more detail, but starting around mid iOS 15 (if I'm remembering correctly) the Faucet Example starting acting flaky. The valves would sometimes appear and sometimes disappear from the main screen in the Home App, and sometimes they would show the incorrect status. I had considered removing the Faucet Example and replacing with something else, but things worked "most" of the time and I was was hoping Apple would fix whatever bug they introduced in the Home App.
The irrigation example (in Reference Sketches) uses Linked Services the same way and does not seem to have any issues, which is why I think the issue is with the Home App.
I did an implementation following example 17 for a pump (in a rainwater container) - but home app is behaving quite confused, sometimes it works, sometimes it does not. This seems to be limited to activating the faucet from the dashboard tile, when going "inside" the faucet tile it seems to work (probably some status info missing?)
Just double checked again if i did something different, but cannot find the spot...
struct Pump : Service::Faucet {
SpanCharacteristic *name;
SpanCharacteristic *active;
SpanPoint *remoteDevice = NULL;
SpanCharacteristic *level;
uint32_t lastUpdate = 0;
Pump(SpanCharacteristic name, char mac) {
this->name = name;
remoteDevice = new SpanPoint(mac, sizeof(uint8_t), sizeof(sp_data), 1, true);
active = new Characteristic::Active(false, true);
level = new Characteristic::WaterLevel(0, true);
addLink(new waterValve(this));
}
struct waterValve : Service::Valve {
SpanCharacteristic *active=new Characteristic::Active(1, true); // the Active Characteristic is used to specify whether the Valve is Active (open) or Inactive (closed)
SpanCharacteristic *inUse=new Characteristic::InUse(0, true); // the InUser Characteristic is used to specify whether water is actually flowing through value
Pump *pump;
}; // waterValve
void loop() {
if (remoteDevice) {
if (remoteDevice->get(&sp_data)) {
lastUpdate = getEpochTime();
if (sp_data.type == sp_datatype_t::level) {
level->setVal(sp_data.value);
logging(iDEBUG, "container:" + String(sp_data.value, 0) + "%");
}
}
}
}
uint32_t updated() {
return lastUpdate;
}
};
The text was updated successfully, but these errors were encountered: