Merge branch 'development' into pre-release

This commit is contained in:
Theo Arends 2020-05-13 12:47:48 +02:00
commit b9dcca2f69
6 changed files with 118 additions and 57 deletions

View File

@ -25,14 +25,14 @@
const char kHAssJsonSensorTypes[] PROGMEM =
D_JSON_TEMPERATURE "|" D_JSON_DEWPOINT "|" D_JSON_PRESSURE "|" D_JSON_PRESSUREATSEALEVEL "|"
D_JSON_APPARENT_POWERUSAGE "|Battery|" D_JSON_CURRENT "|" D_JSON_DISTANCE "|" D_JSON_FREQUENCY "|" D_JSON_HUMIDITY "|" D_JSON_ILLUMINANCE "|"
D_JSON_MOISTURE "|PB0.3|PB0.5|PB1|PB2.5|PB5|PB10|PM1|PM2.5|PM10|" D_JSON_POWERFACTOR "|" D_JSON_POWERUSAGE "|"
D_JSON_MOISTURE "|PB0.3|PB0.5|PB1|PB2.5|PB5|PB10|PM1|PM2.5|PM10|" D_JSON_POWERFACTOR "|" D_JSON_POWERUSAGE "|" D_JSON_TOTAL_START_TIME "|"
D_JSON_REACTIVE_POWERUSAGE "|" D_JSON_TODAY "|" D_JSON_TOTAL "|" D_JSON_VOLTAGE "|" D_JSON_WEIGHT "|" D_JSON_YESTERDAY "|"
D_JSON_CO2 "|" D_JSON_ECO2 "|" D_JSON_TVOC "|";
const char kHAssJsonSensorUnits[] PROGMEM =
"||||"
"VA|%|A|Cm|Hz|%|LX|"
"%|ppd|ppd|ppd|ppd|ppd|ppd|µg/m³|µg/m³|µg/m³|Cos φ|W|"
"%|ppd|ppd|ppd|ppd|ppd|ppd|µg/m³|µg/m³|µg/m³|Cos φ|W| |"
"VAr|kWh|kWh|V|Kg|kWh|"
"ppm|ppm|ppb|";
@ -40,7 +40,7 @@ const char kHAssJsonSensorDevCla[] PROGMEM =
"dev_cla\":\"temperature|ic\":\"mdi:weather-rainy|dev_cla\":\"pressure|dev_cla\":\"pressure|"
"dev_cla\":\"power|dev_cla\":\"battery|ic\":\"mdi:alpha-a-circle-outline|ic\":\"mdi:leak|ic\":\"mdi:current-ac|dev_cla\":\"humidity|dev_cla\":\"illuminance|"
"ic\":\"mdi:cup-water|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|ic\":\"mdi:flask|"
"ic\":\"mdi:air-filter|ic\":\"mdi:air-filter|ic\":\"mdi:air-filter|ic\":\"mdi:alpha-f-circle-outline|dev_cla\":\"power|"
"ic\":\"mdi:air-filter|ic\":\"mdi:air-filter|ic\":\"mdi:air-filter|ic\":\"mdi:alpha-f-circle-outline|dev_cla\":\"power|ic\":\"mdi:progress-clock|"
"dev_cla\":\"power|dev_cla\":\"power|dev_cla\":\"power|ic\":\"mdi:alpha-v-circle-outline|ic\":\"mdi:scale|dev_cla\":\"power|"
"ic\":\"mdi:periodic-table-co2|ic\":\"mdi:air-filter|ic\":\"mdi:periodic-table-co2|";
//"ic\":\"mdi:weather-windy|ic\":\"mdi:weather-windy|ic\":\"mdi:weather-windy|ic\":\"mdi:weather-windy|"
@ -141,15 +141,17 @@ const char kHAssTriggerStringButtons[] PROGMEM =
"|SINGLE|DOUBLE|TRIPLE|QUAD|PENTA|HOLD|";
const char kHAssError1[] PROGMEM =
"HASS: MQTT discovery failed due to too long topic or friendly name."
"Please shorten topic and friendly name. Failed to format";
"HASS: MQTT discovery failed due to too long topic or friendly name. Please shorten topic and/or friendly name. Failed to format";
const char kHAssError2[] PROGMEM =
"HASS: The configuration of the Relays is wrong, there is a Light that is using an index lower than the number of the selected relay.\n "
"HASS: The configuration of the Relays is wrong, there is a Light that is using an index higher than the number of the validated relay.\n "
"The Relays have priority over the Lights, an incorrect order could lead to an erroneous Light control.\n "
"Please update your configuration to avoid inconsistent results.\n "
"Entities for Relays and Lights will not be available in Home Assistant until the configuration will be updated.";
const char kHAssError3[] PROGMEM =
"HASS: Unable to create one or more entities from Json data, please check your configuration. Failed to parse";
uint8_t hass_init_step = 0;
uint8_t hass_mode = 0;
int hass_tele_period = 0;
@ -266,7 +268,7 @@ void HAssAnnounceRelayLight(void)
if (PwmMulti) { // SetOption68 - Multi-channel PWM instead of a single light
snprintf_P(channel_num, sizeof(channel_num), PSTR("Channel%d"), i);
} else {
if (!LightControl) { // SetOption37 >= 128 - Color remapping for led channels, also provides an option for allowing independent handling of RGB and white channels
if (!LightControl) { // SetOption37 >= 128 - Color remapping for led channels, also provides an option for allowing independent handling of RGB and white channels
snprintf_P(channel_num, sizeof(channel_num), PSTR("" D_CMND_DIMMER "%d"), dimmer);
dimmer ++;
} else {
@ -530,7 +532,6 @@ void HAssAnnounceButtons(void)
single = 1;
}
}
HAssAnnouncerTriggers(button_index, button_present, 0, 0, 0, single, 1, 6);
}
}
@ -630,11 +631,12 @@ void HAssAnnounceSensors(void)
// USE THE FOLLOWING LINE TO TEST JSON
//snprintf_P(sensordata, sizeof(sensordata), PSTR("{\"HX711\":{\"Weight\":[22,34,1023.4]}}"));
StaticJsonBuffer<500> jsonBuffer;
JsonObject &root = jsonBuffer.parseObject(sensordata);
if (!root.success())
{
AddLog_P2(LOG_LEVEL_ERROR, PSTR("HASS: jsonBuffer failed to parse '%s'"), sensordata);
AddLog_P2(LOG_LEVEL_ERROR, PSTR("%s '%s'"), kHAssError3, sensordata);
continue;
}
for (auto sensor : root)
@ -643,7 +645,7 @@ void HAssAnnounceSensors(void)
JsonObject &sensors = sensor.value.as<JsonObject>();
if (!sensors.success())
{
AddLog_P2(LOG_LEVEL_ERROR, PSTR("HASS: JsonObject failed to parse '%s'"), sensordata);
AddLog_P2(LOG_LEVEL_ERROR, PSTR("%s '%s'"), kHAssError3, sensordata);
continue;
}
@ -791,11 +793,10 @@ void HAssAnyKey(void)
char stopic[TOPSZ];
if (state == 2) {
snprintf_P(trg_state, sizeof(trg_state), PSTR("SINGLE"));
} else if (state == 3) {
if (state == 3) {
snprintf_P(trg_state, sizeof(trg_state), GetStateText(3));
} else {
if (state == 2) { state = 10; }
GetTextIndexed(trg_state, sizeof(trg_state), state -9, kHAssTriggerStringButtons);
}

View File

@ -49,13 +49,14 @@ ZF(ResetAlarm) ZF(ResetAllAlarms)
ZF(HueSat) ZF(Color)
ZF(ShutterOpen) ZF(ShutterClose) ZF(ShutterStop) ZF(ShutterLift) ZF(ShutterTilt) ZF(Shutter)
//ZF(Occupancy)
ZF(DimmerMove) ZF(DimmerStep)
ZF(HueMove) ZF(HueStep) ZF(SatMove) ZF(SatStep) ZF(ColorMove) ZF(ColorStep)
ZF(DimmerMove) ZF(DimmerStep) ZF(DimmerStepUp) ZF(DimmerStepDown)
ZF(HueMove) ZF(HueStep) ZF(HueStepUp) ZF(HueStepDown) ZF(SatMove) ZF(SatStep) ZF(ColorMove) ZF(ColorStep) ZF(ColorTempStep) ZF(ColorTempStepUp) ZF(ColorTempStepDown)
ZF(ArrowClick) ZF(ArrowHold) ZF(ArrowRelease) ZF(ZoneStatusChange)
ZF(xxxx00) ZF(xxxx) ZF(01xxxx) ZF(00) ZF(01) ZF() ZF(xxxxyy) ZF(00190200) ZF(01190200) ZF(xxyyyy) ZF(xx)
ZF(xxxx00) ZF(xxxx) ZF(01xxxx) ZF(03xxxx) ZF(00) ZF(01) ZF() ZF(xxxxyy) ZF(00190200) ZF(01190200) ZF(xxyyyy) ZF(xx)
ZF(xx000A00) ZF(xx0A00) ZF(xxyy0A00) ZF(xxxxyyyy0A00) ZF(xxxx0A00) ZF(xx0A)
ZF(xx190A00) ZF(xx19) ZF(xx190A) ZF(xxxxyyyy) ZF(xxxxyyzz) ZF(xxyyzzzz) ZF(xxyyyyzz)
ZF(00xx0A00) ZF(01xx0A00) ZF(03xx0A00) ZF(01xxxx0A0000000000) ZF(03xxxx0A0000000000) ZF(xxyyyy0A0000000000)
// Cluster specific commands
// Note: the table is both for sending commands, but also displaying received commands
@ -103,17 +104,24 @@ const Z_CommandConverter Z_Commands[] PROGMEM = {
// Decoders only - normally not used to send, and names may be masked by previous definitions
{ Z(Dimmer), 0x0008, 0x00, 0x01, Z(xx) },
{ Z(DimmerMove), 0x0008, 0x01, 0x01, Z(xx0A) },
{ Z(DimmerStepUp), 0x0008, 0x02, 0x01, Z(00xx0A00) },
{ Z(DimmerStepDown), 0x0008, 0x02, 0x01, Z(01xx0A00) },
{ Z(DimmerStep), 0x0008, 0x02, 0x01, Z(xx190A00) },
{ Z(DimmerMove), 0x0008, 0x05, 0x01, Z(xx0A) },
{ Z(DimmerUp), 0x0008, 0x06, 0x01, Z(00) },
{ Z(DimmerDown), 0x0008, 0x06, 0x01, Z(01) },
{ Z(DimmerStop), 0x0008, 0x07, 0x01, Z() },
{ Z(HueMove), 0x0300, 0x01, 0x01, Z(xx19) },
{ Z(HueStepUp), 0x0300, 0x02, 0x01, Z(01xx0A00) },
{ Z(HueStepDown), 0x0300, 0x02, 0x01, Z(03xx0A00) },
{ Z(HueStep), 0x0300, 0x02, 0x01, Z(xx190A00) },
{ Z(SatMove), 0x0300, 0x04, 0x01, Z(xx19) },
{ Z(SatStep), 0x0300, 0x05, 0x01, Z(xx190A) },
{ Z(ColorMove), 0x0300, 0x08, 0x01, Z(xxxxyyyy) },
{ Z(ColorStep), 0x0300, 0x09, 0x01, Z(xxxxyyyy0A00) },
{ Z(ColorTempStepUp), 0x0300, 0x4C, 0x01, Z(01xxxx0A0000000000) }, //xxxx = step
{ Z(ColorTempStepDown),0x0300, 0x4C, 0x01, Z(03xxxx0A0000000000) }, //xxxx = step
{ Z(ColorTempStep), 0x0300, 0x4C, 0x01, Z(xxyyyy0A0000000000) }, //xx = 0x01 up, 0x03 down, yyyy = step
// Tradfri
{ Z(ArrowClick), 0x0005, 0x07, 0x01, Z(xx) }, // xx == 0x01 = left, 0x00 = right
{ Z(ArrowHold), 0x0005, 0x08, 0x01, Z(xx) }, // xx == 0x01 = left, 0x00 = right

View File

@ -109,7 +109,8 @@ const uint8_t ZIGBEE_LABEL_START_COORD = 11; // Start ZNP as coordinator
const uint8_t ZIGBEE_LABEL_INIT_ROUTER = 12; // Start ZNP as router
const uint8_t ZIGBEE_LABEL_START_ROUTER = 13; // Start ZNP as router
const uint8_t ZIGBEE_LABEL_INIT_DEVICE = 14; // Start ZNP as end-device
const uint8_t ZIGBEE_LABEL_START_DEVICE = 15; // Start ZNP as end-device
// const uint8_t ZIGBEE_LABEL_START_DEVICE = 15; // Start ZNP as end-device - same as ZIGBEE_LABEL_START_ROUTER
const uint8_t ZIGBEE_LABEL_FACT_RESET_ROUTER_DEVICE_POST = 19; // common post configuration for router and device
const uint8_t ZIGBEE_LABEL_READY = 20; // goto label 20 for main loop
const uint8_t ZIGBEE_LABEL_MAIN_LOOP = 21; // main loop
const uint8_t ZIGBEE_LABEL_PERMIT_JOIN_CLOSE = 30; // disable permit join
@ -283,6 +284,7 @@ ZBM(ZBS_WNV_ZNPHC, Z_SREQ | Z_SYS, SYS_OSAL_NV_WRITE, Z_B0(ZNP_HAS_CONFIGURED),
// Z_ZDO:startupFromApp
ZBM(ZBS_STARTUPFROMAPP, Z_SREQ | Z_ZDO, ZDO_STARTUP_FROM_APP, 100, 0 /* delay */) // 25406400
ZBM(ZBR_STARTUPFROMAPP, Z_SRSP | Z_ZDO, ZDO_STARTUP_FROM_APP ) // 6540 + 01 for new network, 00 for exisitng network, 02 for error
ZBM(AREQ_STARTUPFROMAPP, Z_AREQ | Z_ZDO, ZDO_STATE_CHANGE_IND ) // 45C00xx - state change
ZBM(AREQ_STARTUPFROMAPP_COORD, Z_AREQ | Z_ZDO, ZDO_STATE_CHANGE_IND, ZDO_DEV_ZB_COORD ) // 45C009 + 08 = starting, 09 = started
ZBM(AREQ_STARTUPFROMAPP_ROUTER, Z_AREQ | Z_ZDO, ZDO_STATE_CHANGE_IND, ZDO_DEV_ROUTER ) // 45C009 + 02 = looking PanID, 07 = started
ZBM(AREQ_STARTUPFROMAPP_DEVICE, Z_AREQ | Z_ZDO, ZDO_STATE_CHANGE_IND, ZDO_DEV_END_DEVICE ) // 45C009 + 02 = looking PanID, 06 = started
@ -456,7 +458,7 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
//ZI_LOG(LOG_LEVEL_INFO, D_LOG_ZIGBEE "starting zigbee coordinator")
ZI_SEND(ZBS_STARTUPFROMAPP) // start coordinator
ZI_WAIT_RECV(2000, ZBR_STARTUPFROMAPP) // wait for sync ack of command
ZI_WAIT_UNTIL(10000, AREQ_STARTUPFROMAPP_COORD) // wait for async message that coordinator started
ZI_WAIT_UNTIL_FUNC(10000, AREQ_STARTUPFROMAPP, &Z_ReceiveStateChange) // wait for async message that coordinator started
ZI_SEND(ZBS_GETDEVICEINFO) // GetDeviceInfo
ZI_WAIT_RECV_FUNC(2000, ZBR_GETDEVICEINFO, &Z_ReceiveDeviceInfo)
//ZI_WAIT_RECV(2000, ZBR_GETDEVICEINFO) // memorize info
@ -542,7 +544,7 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
ZI_WAIT_RECV(1000, ZBR_AF_REGISTER)
ZI_SEND(ZBS_STARTUPFROMAPP) // start router
ZI_WAIT_RECV(2000, ZBR_STARTUPFROMAPP) // wait for sync ack of command
ZI_WAIT_UNTIL_FUNC(0xFFFF, AREQ_STARTUPFROMAPP_ROUTER, &Z_ReceiveStateChange) // wait for async message that coordinator started
ZI_WAIT_UNTIL_FUNC(0xFFFF, AREQ_STARTUPFROMAPP, &Z_ReceiveStateChange) // wait for async message that coordinator started
ZI_SEND(ZBS_GETDEVICEINFO) // GetDeviceInfo
ZI_WAIT_RECV_FUNC(2000, ZBR_GETDEVICEINFO, &Z_ReceiveDeviceInfo)
ZI_GOTO(ZIGBEE_LABEL_READY)
@ -556,6 +558,7 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
ZI_WAIT_RECV(5000, ZBR_RESET)
ZI_SEND(ZBS_W_LOGTYP_ROUTER) // write Logical Type = router
ZI_WAIT_RECV(1000, ZBR_W_OK)
ZI_LABEL(ZIGBEE_LABEL_FACT_RESET_ROUTER_DEVICE_POST)
ZI_SEND(ZBS_W_ALL_PAN) // write universal PAN ID = 0xFFFF
ZI_WAIT_RECV(1000, ZBR_W_OK)
ZI_SEND(ZBS_W_ALL_CHANN) // write Allows all CHANNELS = 0x07FFF800, 11-26
@ -580,17 +583,19 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
ZI_SEND(ZBS_LOGTYPE) // check the logical type
ZI_WAIT_RECV(1000, ZBS_LOGTYPE_DEVICE) // it should be coordinator
ZI_LABEL(ZIGBEE_LABEL_START_DEVICE) // Init as a router
ZI_MQTT_STATE(ZIGBEE_STATUS_STARTING, kConfiguredDevice)
ZI_ON_ERROR_GOTO(ZIGBEE_LABEL_ABORT)
ZI_SEND(ZBS_AF_REGISTER_ALL) // Z_AF register for endpoint 01, profile 0x0104 Home Automation
ZI_WAIT_RECV(1000, ZBR_AF_REGISTER)
ZI_SEND(ZBS_STARTUPFROMAPP) // start router
ZI_WAIT_RECV(2000, ZBR_STARTUPFROMAPP) // wait for sync ack of command
ZI_WAIT_UNTIL_FUNC(0xFFFF, AREQ_STARTUPFROMAPP_ROUTER, &Z_ReceiveStateChange) // wait forever for async message that coordinator started
ZI_SEND(ZBS_GETDEVICEINFO) // GetDeviceInfo
ZI_WAIT_RECV_FUNC(2000, ZBR_GETDEVICEINFO, &Z_ReceiveDeviceInfo)
ZI_GOTO(ZIGBEE_LABEL_READY)
ZI_GOTO(ZIGBEE_LABEL_START_ROUTER)
// Device and Router code is common from now
// ZI_LABEL(ZIGBEE_LABEL_START_DEVICE) // Init as a router
// ZI_MQTT_STATE(ZIGBEE_STATUS_STARTING, kConfiguredDevice)
// ZI_ON_ERROR_GOTO(ZIGBEE_LABEL_ABORT)
// ZI_SEND(ZBS_AF_REGISTER_ALL) // Z_AF register for endpoint 01, profile 0x0104 Home Automation
// ZI_WAIT_RECV(1000, ZBR_AF_REGISTER)
// ZI_SEND(ZBS_STARTUPFROMAPP) // start router
// ZI_WAIT_RECV(2000, ZBR_STARTUPFROMAPP) // wait for sync ack of command
// ZI_WAIT_UNTIL_FUNC(0xFFFF, AREQ_STARTUPFROMAPP, &Z_ReceiveStateChange) // wait forever for async message that coordinator started
// ZI_SEND(ZBS_GETDEVICEINFO) // GetDeviceInfo
// ZI_WAIT_RECV_FUNC(2000, ZBR_GETDEVICEINFO, &Z_ReceiveDeviceInfo)
// ZI_GOTO(ZIGBEE_LABEL_READY)
ZI_LABEL(ZIGBEE_LABEL_FACT_RESET_DEVICE) // Factory reset for router
ZI_MQTT_STATE(ZIGBEE_STATUS_RESET_CONF, kResetting)
@ -601,18 +606,21 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
ZI_WAIT_RECV(5000, ZBR_RESET)
ZI_SEND(ZBS_W_LOGTYP_DEVICE) // write Logical Type = router
ZI_WAIT_RECV(1000, ZBR_W_OK)
ZI_SEND(ZBS_W_ALL_PAN) // write universal PAN ID = 0xFFFF
ZI_WAIT_RECV(1000, ZBR_W_OK)
ZI_SEND(ZBS_W_ALL_CHANN) // write Allows all CHANNELS = 0x07FFF800, 11-26
ZI_WAIT_RECV(1000, ZBR_W_OK)
ZI_GOTO(ZIGBEE_LABEL_FACT_RESET_ROUTER_DEVICE_POST)
// Now mark the device as ready, writing 0x55 in memory slot 0x0F00
ZI_SEND(ZBS_WNV_INITZNPHC) // Init NV ZNP Has Configured
ZI_WAIT_RECV_FUNC(1000, ZBR_WNV_INIT_OK, &Z_CheckNVWrite)
ZI_SEND(ZBS_WNV_ZNPHC) // Write NV ZNP Has Configured
ZI_WAIT_RECV(1000, ZBR_WNV_OK)
// ZI_SEND(ZBS_W_ALL_PAN) // write universal PAN ID = 0xFFFF
// ZI_WAIT_RECV(1000, ZBR_W_OK)
// ZI_SEND(ZBS_W_ALL_CHANN) // write Allows all CHANNELS = 0x07FFF800, 11-26
// ZI_WAIT_RECV(1000, ZBR_W_OK)
ZI_GOTO(ZIGBEE_LABEL_START_DEVICE)
// // Now mark the device as ready, writing 0x55 in memory slot 0x0F00
// ZI_SEND(ZBS_WNV_INITZNPHC) // Init NV ZNP Has Configured
// ZI_WAIT_RECV_FUNC(1000, ZBR_WNV_INIT_OK, &Z_CheckNVWrite)
// ZI_SEND(ZBS_WNV_ZNPHC) // Write NV ZNP Has Configured
// ZI_WAIT_RECV(1000, ZBR_WNV_OK)
// ZI_GOTO(ZIGBEE_LABEL_START_ROUTER)
// ZI_GOTO(ZIGBEE_LABEL_START_DEVICE)
ZI_LABEL(ZIGBEE_LABEL_UNSUPPORTED_VERSION)

View File

@ -321,20 +321,62 @@ int32_t Z_DataConfirm(int32_t res, const class SBuffer &buf) {
//
// Handle State Change Indication incoming message
//
// Reference:
// 0x00: Initialized - not started automatically
// 0x01: Initialized - not connected to anything
// 0x02: Discovering PAN's to join
// 0x03: Joining a PAN
// 0x04: Rejoining a PAN, only for end devices
// 0x05: Joined but not yet authenticated by trust center
// 0x06: Started as device after authentication
// 0x07: Device joined, authenticated and is a router
// 0x08: Starting as ZigBee Coordinator
// 0x09: Started as ZigBee Coordinator
// 0x0A: Device has lost information about its parent
int32_t Z_ReceiveStateChange(int32_t res, const class SBuffer &buf) {
uint8_t state = buf.get8(2);
const char * msg = nullptr;
if (ZDO_DEV_NWK_DISC == state) {
switch (state) {
case ZDO_DEV_NWK_DISC: // 0x02
msg = PSTR("Scanning Zigbee network");
break;
case ZDO_DEV_NWK_JOINING: // 0x03
case ZDO_DEV_NWK_REJOIN: // 0x04
msg = PSTR("Joining a PAN");
break;
case ZDO_DEV_END_DEVICE_UNAUTH: // 0x05
msg = PSTR("Joined, not yet authenticated");
break;
case ZDO_DEV_END_DEVICE: // 0x06
msg = PSTR("Started as device");
break;
case ZDO_DEV_ROUTER: // 0x07
msg = PSTR("Started as router");
break;
case ZDO_DEV_ZB_COORD: // 0x09
msg = PSTR("Started as coordinator");
break;
case ZDO_DEV_NWK_ORPHAN: // 0x0A
msg = PSTR("Device has lost its parent");
break;
};
if (msg) {
Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{"
"\"Status\":%d,\"Message\":\"%s\"}}"),
ZIGBEE_STATUS_SCANNING, PSTR("Scanning Zigbee network")
"\"Status\":%d,\"NewState\":%d,\"Message\":\"%s\"}}"),
ZIGBEE_STATUS_SCANNING, state, msg
);
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED));
XdrvRulesProcess();
}
return res;
if ((ZDO_DEV_END_DEVICE == state) || (ZDO_DEV_ROUTER == state) || (ZDO_DEV_ZB_COORD == state)) {
return 0; // device sucessfully started
} else {
return -1; // ignore
}
}
//

View File

@ -227,24 +227,26 @@ void WindMeterShow(bool json)
if (json) {
WindMeter.last_tele_speed = WindMeter.speed;
#ifndef USE_WINDMETER_NOSTATISTICS
ResponseAppend_P(PSTR(",\"" D_WINDMETER_NAME "\":{\"" D_JSON_SPEED "\":{\"Act\":%s,\"Avg\":%s,\"Min\":%s,\"Max\":%s},\"Dir\":{\"Card\":\"%s\",\"Deg\":%s,\"Avg\":%s,\"AvgCard\":\"%s\",\"Min\":%s,\"Max\":%s,\"Range\":%s}}"),
//ResponseAppend_P(PSTR(",\"" D_WINDMETER_NAME "\":{\"" D_JSON_SPEED "\":{\"Act\":%s,\"Avg\":%s,\"Min\":%s,\"Max\":%s},\"Dir\":{\"Card\":\"%s\",\"Deg\":%s,\"Avg\":%s,\"AvgCard\":\"%s\",\"Min\":%s,\"Max\":%s,\"Range\":%s}}"),
ResponseAppend_P(PSTR(",\"" D_WINDMETER_NAME "\":{\"" D_JSON_SPEED "\":{\"Act\":%s,\"Avg\":%s,\"Min\":%s,\"Max\":%s}}"),
speed_string,
speed_avg_string,
speed_min_string,
speed_max_string,
"n/a", //direction_cardinal_string,
"n/a", //direction_string,
"n/a", //direction_avg_string,
"n/a", //direction_avg_cardinal_string,
"n/a", //direction_min_string,
"n/a", //direction_max_string,
"n/a" //direction_range_string
speed_max_string
//direction_cardinal_string,
//direction_string,
//direction_avg_string,
//direction_avg_cardinal_string,
//direction_min_string,
//direction_max_string,
//direction_range_string
);
#else // USE_WINDMETER_NOSTATISTICS
ResponseAppend_P(PSTR(",\"" D_WINDMETER_NAME "\":{\"" D_JSON_SPEED "\":{\"Act\":%s},\"Dir\":{\"Card\":\"%s\",\"Deg\":%s}}"),
speed_string,
"n/a", //wind_direction_cardinal_string,
"n/a" //wind_direction_string
//ResponseAppend_P(PSTR(",\"" D_WINDMETER_NAME "\":{\"" D_JSON_SPEED "\":{\"Act\":%s},\"Dir\":{\"Card\":\"%s\",\"Deg\":%s}}"),
ResponseAppend_P(PSTR(",\"" D_WINDMETER_NAME "\":{\"" D_JSON_SPEED "\":{\"Act\":%s}}"),
speed_string
//wind_direction_cardinal_string,
//wind_direction_string
);
#endif // USE_WINDMETER_NOSTATISTICS
#ifdef USE_WEBSERVER