┆"));
if (temperature_ok) {
char buf[12];
dtostrf(device.temperature / 10.0f, 3, 1, buf);
WSContentSend_PD(PSTR(" ☀️ %s°C"), buf);
}
if (humidity_ok) {
WSContentSend_P(PSTR(" 💧 %d%%"), device.humidity);
}
if (pressure_ok) {
WSContentSend_P(PSTR(" ⛅ %d hPa"), device.pressure);
}
WSContentSend_P(PSTR("{e}"));
}
// Light, switches and plugs
bool power_ok = device.validPower();
if (power_ok) {
uint8_t channels = device.getLightChannels();
if (0xFF == channels) { channels = 5; } // if number of channel is unknown, display all known attributes
WSContentSend_P(PSTR(" |
┆ %s"), device.getPower() ? PSTR(D_ON) : PSTR(D_OFF));
if (device.validDimmer() && (channels >= 1)) {
WSContentSend_P(PSTR(" 🔅 %d%%"), changeUIntScale(device.dimmer,0,254,0,100));
}
if (device.validCT() && ((channels == 2) || (channels == 5))) {
uint32_t ct_k = (((1000000 / device.ct) + 25) / 50) * 50;
WSContentSend_P(PSTR(" ⚪ %dK"), device.ct, ct_k);
}
if (device.validHue() && device.validSat() && (channels >= 3)) {
uint8_t r,g,b;
uint8_t sat = changeUIntScale(device.sat, 0, 254, 0, 255); // scale to 0..255
LightStateClass::HsToRgb(device.hue, sat, &r, &g, &b);
WSContentSend_P(PSTR(" #%02X%02X%02X"), r,g,b,r,g,b);
} else if (device.validX() && device.validY() && (channels >= 3)) {
uint8_t r,g,b;
LightStateClass::XyToRgb(device.x / 65535.0f, device.y / 65535.0f, &r, &g, &b);
WSContentSend_P(PSTR(" #%02X%02X%02X"), r,g,b,r,g,b);
}
if (device.validMainsPower() || device.validMainsVoltage()) {
WSContentSend_P(PSTR(" ⚡ "));
if (device.validMainsVoltage()) {
WSContentSend_P(PSTR(" %dV"), device.mains_voltage);
}
if (device.validMainsPower()) {
WSContentSend_P(PSTR(" %dW"), device.mains_power);
}
}
}
}
WSContentSend_P(PSTR("{t}")); // Terminate current multi column table and open new table
#endif
}
}
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
bool Xdrv23(uint8_t function)
{
bool result = false;
if (zigbee.active) {
switch (function) {
case FUNC_EVERY_50_MSECOND:
if (!zigbee.init_phase) {
zigbee_devices.runTimer();
}
break;
case FUNC_LOOP:
#ifdef USE_ZIGBEE_EZSP
if (ZigbeeUploadXmodem()) {
return false;
}
#endif
if (ZigbeeSerial) {
ZigbeeInputLoop();
ZigbeeOutputLoop(); // send any outstanding data
}
if (zigbee.state_machine) {
ZigbeeStateMachine_Run();
}
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
ZigbeeShow(false);
break;
#endif // USE_WEBSERVER
case FUNC_PRE_INIT:
ZigbeeInit();
break;
case FUNC_COMMAND:
result = DecodeCommand(kZbCommands, ZigbeeCommand);
break;
}
}
return result;
}
#endif // USE_ZIGBEE
|