mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 05:36:39 +00:00
6.4.1.10 Fix Hass discovery of MHZ19(B)
6.4.1.10 20190121 * Fix Hass discovery of MHZ19(B) sensors (#4992)
This commit is contained in:
parent
2b7fbe22e3
commit
dcabb9c6dc
@ -1,4 +1,7 @@
|
|||||||
/* 6.4.1.9 20190115
|
/* 6.4.1.10 20190121
|
||||||
|
* Fix Hass discovery of MHZ19(B) sensors (#4992)
|
||||||
|
*
|
||||||
|
* 6.4.1.9 20190115
|
||||||
* Add support for Mi LED Desk Lamp with rotary switch (#4887)
|
* Add support for Mi LED Desk Lamp with rotary switch (#4887)
|
||||||
* Fix mDNS addService (#4938, #4951)
|
* Fix mDNS addService (#4938, #4951)
|
||||||
* Fix allowable MAX_RULE_VARS to 16 (#4933)
|
* Fix allowable MAX_RULE_VARS to 16 (#4933)
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
#define D_JSON_MAC "Mac"
|
#define D_JSON_MAC "Mac"
|
||||||
#define D_JSON_MASK "Mask"
|
#define D_JSON_MASK "Mask"
|
||||||
#define D_JSON_MINIMAL "minimal"
|
#define D_JSON_MINIMAL "minimal"
|
||||||
|
#define D_JSON_MODEL "Model"
|
||||||
#define D_JSON_NO "No"
|
#define D_JSON_NO "No"
|
||||||
#define D_JSON_NOISE "Noise"
|
#define D_JSON_NOISE "Noise"
|
||||||
#define D_JSON_NONE "None"
|
#define D_JSON_NONE "None"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef _SONOFF_VERSION_H_
|
#ifndef _SONOFF_VERSION_H_
|
||||||
#define _SONOFF_VERSION_H_
|
#define _SONOFF_VERSION_H_
|
||||||
|
|
||||||
#define VERSION 0x06040109
|
#define VERSION 0x0604010A
|
||||||
|
|
||||||
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
||||||
#define D_AUTHOR "Theo Arends"
|
#define D_AUTHOR "Theo Arends"
|
||||||
|
@ -70,7 +70,7 @@ enum MhzFilterOptions {MHZ19_FILTER_OFF, MHZ19_FILTER_OFF_ALLSAMPLES, MHZ19_FILT
|
|||||||
|
|
||||||
TasmotaSerial *MhzSerial;
|
TasmotaSerial *MhzSerial;
|
||||||
|
|
||||||
const char kMhzTypes[] PROGMEM = "MHZ19|MHZ19B";
|
const char kMhzModels[] PROGMEM = "|B";
|
||||||
|
|
||||||
enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000 };
|
enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000 };
|
||||||
const uint8_t kMhzCommands[][4] PROGMEM = {
|
const uint8_t kMhzCommands[][4] PROGMEM = {
|
||||||
@ -90,7 +90,6 @@ uint16_t mhz_last_ppm = 0;
|
|||||||
uint8_t mhz_filter = MHZ19_FILTER_OPTION;
|
uint8_t mhz_filter = MHZ19_FILTER_OPTION;
|
||||||
bool mhz_abc_enable = MHZ19_ABC_ENABLE;
|
bool mhz_abc_enable = MHZ19_ABC_ENABLE;
|
||||||
bool mhz_abc_must_apply = false;
|
bool mhz_abc_must_apply = false;
|
||||||
char mhz_types[7];
|
|
||||||
|
|
||||||
float mhz_temperature = 0;
|
float mhz_temperature = 0;
|
||||||
uint8_t mhz_retry = MHZ19_RETRY_COUNT;
|
uint8_t mhz_retry = MHZ19_RETRY_COUNT;
|
||||||
@ -322,19 +321,21 @@ void MhzInit(void)
|
|||||||
|
|
||||||
void MhzShow(boolean json)
|
void MhzShow(boolean json)
|
||||||
{
|
{
|
||||||
|
char types[7] = "MHZ19B"; // MHZ19B for legacy reasons. Prefered is MHZ19
|
||||||
char temperature[33];
|
char temperature[33];
|
||||||
dtostrfd(mhz_temperature, Settings.flag2.temperature_resolution, temperature);
|
dtostrfd(mhz_temperature, Settings.flag2.temperature_resolution, temperature);
|
||||||
GetTextIndexed(mhz_types, sizeof(mhz_types), mhz_type -1, kMhzTypes);
|
char model[3];
|
||||||
|
GetTextIndexed(model, sizeof(model), mhz_type -1, kMhzModels);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"%s\":{\"" D_JSON_CO2 "\":%d,\"" D_JSON_TEMPERATURE "\":%s}"), mqtt_data, mhz_types, mhz_last_ppm, temperature);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"%s\":{\"" D_JSON_MODEL "\":\"%s\",\"" D_JSON_CO2 "\":%d,\"" D_JSON_TEMPERATURE "\":%s}"), mqtt_data, types, model, mhz_last_ppm, temperature);
|
||||||
#ifdef USE_DOMOTICZ
|
#ifdef USE_DOMOTICZ
|
||||||
if (0 == tele_period) DomoticzSensor(DZ_AIRQUALITY, mhz_last_ppm);
|
if (0 == tele_period) DomoticzSensor(DZ_AIRQUALITY, mhz_last_ppm);
|
||||||
#endif // USE_DOMOTICZ
|
#endif // USE_DOMOTICZ
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_CO2, mqtt_data, mhz_types, mhz_last_ppm);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_CO2, mqtt_data, types, mhz_last_ppm);
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, mhz_types, temperature, TempUnit());
|
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_TEMP, mqtt_data, types, temperature, TempUnit());
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user