Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
31b7789873 | |||
6e27f40bf1 |
@ -21,7 +21,7 @@ ESP-NOW based switch for ESP32 ESP-IDF and ESP8266 RTOS SDK. Alternate firmware
|
||||
2. ESP-NOW mesh network based on the [zh_network](https://github.com/aZholtikov/zh_network).
|
||||
3. For initial settings use "menuconfig -> ZH ESP-NOW Switch Configuration". After first boot all settings will be stored in NVS memory for prevente change during OTA firmware update.
|
||||
4. To restart the switch, send the "restart" command to the root topic of the switch (example - "homeassistant/espnow_switch/24-62-AB-F9-1F-A8").
|
||||
5. To update the switch firmware, send the "update" command to the root topic of the switch (example - "homeassistant/espnow_switch/70-03-9F-44-BE-F7"). The update path should be like as "https://your_server/zh_espnow_switch_esp32.bin" (for ESP32) or "https://your_server/zh_espnow_switch_esp8266.app1.bin + https://your_server/zh_espnow_switch_esp8266.app2.bin" (for ESP8266). The time and success of the update depends on the load on WiFi channel 1. Average update time is up to five minutes. The online status of the update will be displayed in the root switch topic.
|
||||
5. To update the switch firmware, send the "update" command to the root topic of the switch (example - "homeassistant/espnow_switch/70-03-9F-44-BE-F7"). The update path should be like as "https://your_server/zh_espnow_switch_esp32.bin" (for ESP32) or "https://your_server/zh_espnow_switch_esp8266.app1.bin + https://your_server/zh_espnow_switch_esp8266.app2.bin" (for ESP8266). Average update time is up to some minutes. The online status of the update will be displayed in the root switch topic.
|
||||
6. To change initial settings of the switch (except work mode), send the X1,X2,X3,X4,X5,X6,X7,X8,X9,X10 command to the hardware topic of the switch (example - "homeassistant/espnow_switch/70-03-9F-44-BE-F7/hardware"). The configuration will only be accepted if it does not cause errors. The current configuration status is displayed in the configuration topic of the switch (example - "homeassistant/espnow_switch/70-03-9F-44-BE-F7/config").
|
||||
|
||||
MQTT configuration message should filled according to the template "X1,X2,X3,X4,X5,X6,X7,X8,X9,X10". Where:
|
||||
|
Submodule components/zh_config updated: c568d84e56...db717bf6ee
Submodule components/zh_ds18b20 updated: 18afcab1d9...cbf2c69e44
Submodule components/zh_espnow updated: 742c807c41...39fdb2eb49
Submodule components/zh_network updated: 783b44fbca...10fefb2912
Submodule components/zh_onewire updated: 4d1286cfb2...d006e1e40c
@ -471,57 +471,39 @@ void zh_send_sensor_status_message_task(void *pvParameter)
|
||||
data.payload_data.status_message.sensor_status_message.sensor_type = switch_config->hardware_config.sensor_type;
|
||||
for (;;)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
switch (switch_config->hardware_config.sensor_type)
|
||||
{
|
||||
case HAST_DS18B20:
|
||||
ZH_DS18B20_READ:
|
||||
switch (zh_ds18b20_read(NULL, &temperature))
|
||||
err = zh_ds18b20_read(NULL, &temperature);
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
case ESP_OK:
|
||||
data.payload_data.status_message.sensor_status_message.temperature = temperature;
|
||||
data.payload_data.status_message.sensor_status_message.voltage = 3.3; // For compatibility with zh_espnow_sensor.
|
||||
break;
|
||||
case ESP_FAIL:
|
||||
vTaskDelay(10000 / portTICK_PERIOD_MS);
|
||||
goto ZH_DS18B20_READ;
|
||||
break;
|
||||
case ESP_ERR_INVALID_CRC:
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
goto ZH_DS18B20_READ;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
data.payload_data.status_message.sensor_status_message.voltage = 3.3; // For future development.
|
||||
}
|
||||
break;
|
||||
case HAST_DHT:
|
||||
ZH_DHT_READ:
|
||||
switch (zh_dht_read(&humidity, &temperature))
|
||||
err = zh_dht_read(&humidity, &temperature);
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
case ESP_OK:
|
||||
data.payload_data.status_message.sensor_status_message.humidity = humidity;
|
||||
data.payload_data.status_message.sensor_status_message.temperature = temperature;
|
||||
data.payload_data.status_message.sensor_status_message.voltage = 3.3; // For compatibility with zh_espnow_sensor.
|
||||
break;
|
||||
case ESP_ERR_INVALID_RESPONSE:
|
||||
vTaskDelay(10000 / portTICK_PERIOD_MS);
|
||||
goto ZH_DHT_READ;
|
||||
break;
|
||||
case ESP_ERR_TIMEOUT:
|
||||
vTaskDelay(10000 / portTICK_PERIOD_MS);
|
||||
goto ZH_DHT_READ;
|
||||
break;
|
||||
case ESP_ERR_INVALID_CRC:
|
||||
vTaskDelay(3000 / portTICK_PERIOD_MS);
|
||||
goto ZH_DHT_READ;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
data.payload_data.status_message.sensor_status_message.voltage = 3.3; // For future development.
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
zh_send_message(switch_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
zh_send_message(switch_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
data.payload_type = ZHPT_ERROR;
|
||||
strcpy(data.payload_data.status_message.error_message.message, "Sensor reading error.");
|
||||
zh_send_message(switch_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
}
|
||||
vTaskDelay(ZH_SENSOR_STATUS_MESSAGE_FREQUENCY * 1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
|
@ -159,14 +159,14 @@ void zh_send_switch_attributes_message_task(void *pvParameter);
|
||||
void zh_send_switch_config_message(const switch_config_t *switch_config);
|
||||
|
||||
/**
|
||||
* @brief Function for prepare the sensor hardware configuration message and sending it to the gateway.
|
||||
* @brief Function for prepare the switch hardware configuration message and sending it to the gateway.
|
||||
*
|
||||
* @param[in] switch_config Pointer to the structure of data exchange between tasks, functions and event handlers.
|
||||
*/
|
||||
void zh_send_switch_hardware_config_message(const switch_config_t *switch_config);
|
||||
|
||||
/**
|
||||
* @brief Task for prepare the sensor keep alive message and sending it to the gateway.
|
||||
* @brief Task for prepare the switch keep alive message and sending it to the gateway.
|
||||
*
|
||||
* @param[in] pvParameter Pointer to the structure of data exchange between tasks, functions and event handlers.
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
1.0.3
|
||||
1.0.4
|
Reference in New Issue
Block a user