mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 19:56:30 +00:00
Merge branch 'development' into pre-release-8.5.1
This commit is contained in:
commit
e1df24be17
@ -243,7 +243,7 @@ void directModeOutput(IO_REG_TYPE pin)
|
|||||||
#define DIRECT_WRITE_HIGH(base, pin) directWriteHigh(pin)
|
#define DIRECT_WRITE_HIGH(base, pin) directWriteHigh(pin)
|
||||||
#define DIRECT_MODE_INPUT(base, pin) directModeInput(pin)
|
#define DIRECT_MODE_INPUT(base, pin) directModeInput(pin)
|
||||||
#define DIRECT_MODE_OUTPUT(base, pin) directModeOutput(pin)
|
#define DIRECT_MODE_OUTPUT(base, pin) directModeOutput(pin)
|
||||||
#warning "ESP32 OneWire testing"
|
//#warning "ESP32 OneWire testing"
|
||||||
|
|
||||||
#elif defined(__SAMD21G18A__)
|
#elif defined(__SAMD21G18A__)
|
||||||
#define PIN_TO_BASEREG(pin) portModeRegister(digitalPinToPort(pin))
|
#define PIN_TO_BASEREG(pin) portModeRegister(digitalPinToPort(pin))
|
||||||
|
@ -312,6 +312,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
|
|||||||
|
|
||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
switch (item) {
|
switch (item) {
|
||||||
|
case DGR_ITEM_FLAGS:
|
||||||
case DGR_ITEM_LIGHT_FADE:
|
case DGR_ITEM_LIGHT_FADE:
|
||||||
case DGR_ITEM_LIGHT_SPEED:
|
case DGR_ITEM_LIGHT_SPEED:
|
||||||
case DGR_ITEM_LIGHT_BRI:
|
case DGR_ITEM_LIGHT_BRI:
|
||||||
|
@ -27,15 +27,15 @@ const char kHAssJsonSensorTypes[] PROGMEM =
|
|||||||
D_JSON_APPARENT_POWERUSAGE "|Battery|" D_JSON_CURRENT "|" D_JSON_DISTANCE "|" D_JSON_FREQUENCY "|" D_JSON_HUMIDITY "|" D_JSON_ILLUMINANCE "|"
|
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_TOTAL_START_TIME "|"
|
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_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 "|" D_COLOR_RED "|" D_COLOR_GREEN "|" D_COLOR_BLUE"|" D_CCT "|" D_PROXIMITY "|Ambient|";
|
D_JSON_CO2 "|" D_JSON_ECO2 "|" D_JSON_TVOC "|Red|Green|Blue|CCT|" D_PROXIMITY "|";
|
||||||
|
|
||||||
|
|
||||||
const char kHAssJsonSensorUnits[] PROGMEM =
|
const char kHAssJsonSensorUnits[] PROGMEM =
|
||||||
"||||"
|
"||||"
|
||||||
"VA|%|A|Cm|Hz|%|LX|"
|
"VA|%|A|cm|Hz|%|lux|"
|
||||||
"%|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|"
|
"VAr|kWh|kWh|V|kg|kWh|"
|
||||||
"ppm|ppm|ppb|R|G|B|" D_UNIT_KELVIN "| |LX|";
|
"ppm|ppm|ppb|R|G|B|" D_UNIT_KELVIN "| |";
|
||||||
|
|
||||||
const char kHAssJsonSensorDevCla[] PROGMEM =
|
const char kHAssJsonSensorDevCla[] PROGMEM =
|
||||||
"dev_cla\":\"temperature|ic\":\"mdi:weather-rainy|dev_cla\":\"pressure|dev_cla\":\"pressure|"
|
"dev_cla\":\"temperature|ic\":\"mdi:weather-rainy|dev_cla\":\"pressure|dev_cla\":\"pressure|"
|
||||||
@ -193,8 +193,8 @@ const char HASS_DISCOVER_DEVICE[] PROGMEM = // Basic par
|
|||||||
"\"tp\":[\"%s\",\"%s\",\"%s\"]," // Topics for command, stat and tele
|
"\"tp\":[\"%s\",\"%s\",\"%s\"]," // Topics for command, stat and tele
|
||||||
"\"rl\":[%s],\"swc\":[%s],\"btn\":[%s]," // Inputs / Outputs
|
"\"rl\":[%s],\"swc\":[%s],\"btn\":[%s]," // Inputs / Outputs
|
||||||
"\"so\":{\"11\":%d,\"13\":%d,\"17\":%d,\"20\":%d," // SetOptions
|
"\"so\":{\"11\":%d,\"13\":%d,\"17\":%d,\"20\":%d," // SetOptions
|
||||||
"\"30\":%d,\"37\":%d,\"68\":%d,\"73\":%d,\"80\":%d},"
|
"\"30\":%d,\"68\":%d,\"73\":%d,\"80\":%d},"
|
||||||
"\"lt_st\":%d,\"ver\":1}"; // Light SubType, and Discovery version
|
"\"lk\":%d,\"lt_st\":%d,\"ver\":1}"; // Light SubType, and Discovery version
|
||||||
|
|
||||||
void NewHAssDiscovery(void)
|
void NewHAssDiscovery(void)
|
||||||
{
|
{
|
||||||
@ -239,10 +239,7 @@ void NewHAssDiscovery(void)
|
|||||||
// Full 12 chars MAC address as ID
|
// Full 12 chars MAC address as ID
|
||||||
String mac_address = WiFi.macAddress();
|
String mac_address = WiFi.macAddress();
|
||||||
mac_address.replace(":", "");
|
mac_address.replace(":", "");
|
||||||
//String mac_part = mac_address.substring(0);
|
|
||||||
snprintf_P(unique_id, sizeof(unique_id), PSTR("%s"), mac_address.c_str());
|
snprintf_P(unique_id, sizeof(unique_id), PSTR("%s"), mac_address.c_str());
|
||||||
|
|
||||||
//snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/discovery/%s/config"), unique_id);
|
|
||||||
snprintf_P(stopic, sizeof(stopic), PSTR("tasmota/discovery/%s/config"), unique_id);
|
snprintf_P(stopic, sizeof(stopic), PSTR("tasmota/discovery/%s/config"), unique_id);
|
||||||
GetTopic_P(state_topic, TELE, mqtt_topic, PSTR(D_RSLT_HASS_STATE));
|
GetTopic_P(state_topic, TELE, mqtt_topic, PSTR(D_RSLT_HASS_STATE));
|
||||||
|
|
||||||
@ -253,13 +250,13 @@ void NewHAssDiscovery(void)
|
|||||||
stemp2, my_hostname, unique_id, ModuleName().c_str(), GetStateText(0), GetStateText(1), GetStateText(2), GetStateText(3),
|
stemp2, my_hostname, unique_id, ModuleName().c_str(), GetStateText(0), GetStateText(1), GetStateText(2), GetStateText(3),
|
||||||
my_version, mqtt_topic, MQTT_FULLTOPIC, SUB_PREFIX, PUB_PREFIX, PUB_PREFIX2, stemp3, stemp4, stemp5, Settings.flag.button_swap,
|
my_version, mqtt_topic, MQTT_FULLTOPIC, SUB_PREFIX, PUB_PREFIX, PUB_PREFIX2, stemp3, stemp4, stemp5, Settings.flag.button_swap,
|
||||||
Settings.flag.button_single, Settings.flag.decimal_text, Settings.flag.not_power_linked, Settings.flag.hass_light,
|
Settings.flag.button_single, Settings.flag.decimal_text, Settings.flag.not_power_linked, Settings.flag.hass_light,
|
||||||
light_controller.isCTRGBLinked(), Settings.flag3.pwm_multi_channels, Settings.flag3.mqtt_buttons, Settings.flag3.shutter_mode, Light.subtype);
|
Settings.flag3.pwm_multi_channels, Settings.flag3.mqtt_buttons, Settings.flag3.shutter_mode, light_controller.isCTRGBLinked(), Light.subtype);
|
||||||
}
|
}
|
||||||
MqttPublish(stopic, true);
|
MqttPublish(stopic, true);
|
||||||
|
|
||||||
if (!Settings.flag.hass_discovery) {
|
if (!Settings.flag.hass_discovery) {
|
||||||
snprintf_P(stopic, sizeof(stopic), PSTR("tasmota/discovery/%s/sensors"), unique_id);
|
snprintf_P(stopic, sizeof(stopic), PSTR("tasmota/discovery/%s/sensors"), unique_id);
|
||||||
Response_P(PSTR("{"));
|
Response_P(PSTR("{\"sn\":"));
|
||||||
MqttShowSensor();
|
MqttShowSensor();
|
||||||
ResponseAppend_P(PSTR(",\"ver\":1}"));
|
ResponseAppend_P(PSTR(",\"ver\":1}"));
|
||||||
MqttPublish(stopic, true);
|
MqttPublish(stopic, true);
|
||||||
@ -967,7 +964,7 @@ void HAssDiscovery(void)
|
|||||||
|
|
||||||
if (Settings.flag.hass_discovery || (1 == hass_mode))
|
if (Settings.flag.hass_discovery || (1 == hass_mode))
|
||||||
{ // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
|
{ // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
|
||||||
hass_mode = 2;
|
hass_mode = 2; // Needed for generating bluetooth entities for MI_ESP32
|
||||||
// Send info about buttons
|
// Send info about buttons
|
||||||
HAssAnnounceButtons();
|
HAssAnnounceButtons();
|
||||||
|
|
||||||
@ -986,7 +983,7 @@ void HAssDiscovery(void)
|
|||||||
// Send info about status sensor
|
// Send info about status sensor
|
||||||
HAssAnnounceDeviceInfoAndStatusSensor();
|
HAssAnnounceDeviceInfoAndStatusSensor();
|
||||||
masterlog_level = 0; // Restores weblog level
|
masterlog_level = 0; // Restores weblog level
|
||||||
hass_mode = 3;
|
hass_mode = 3; // Needed for generating bluetooth entities for MI_ESP32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1074,6 +1071,7 @@ bool Xdrv12(uint8_t function)
|
|||||||
if (!hass_init_step)
|
if (!hass_init_step)
|
||||||
{
|
{
|
||||||
HAssDiscovery(); // Scheduled discovery using available resources
|
HAssDiscovery(); // Scheduled discovery using available resources
|
||||||
|
NewHAssDiscovery(); // Send the topics for Home Assistant Official Integration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Settings.flag.hass_discovery && Settings.tele_period)
|
else if (Settings.flag.hass_discovery && Settings.tele_period)
|
||||||
@ -1093,9 +1091,9 @@ bool Xdrv12(uint8_t function)
|
|||||||
case FUNC_MQTT_INIT:
|
case FUNC_MQTT_INIT:
|
||||||
hass_mode = 0; // Discovery only if Settings.flag.hass_discovery is set
|
hass_mode = 0; // Discovery only if Settings.flag.hass_discovery is set
|
||||||
hass_init_step = 2; // Delayed discovery
|
hass_init_step = 2; // Delayed discovery
|
||||||
if (!Settings.flag.hass_discovery) {
|
// if (!Settings.flag.hass_discovery) {
|
||||||
NewHAssDiscovery();
|
// NewHAssDiscovery();
|
||||||
}
|
// }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUNC_MQTT_SUBSCRIBE:
|
case FUNC_MQTT_SUBSCRIBE:
|
||||||
|
@ -279,7 +279,7 @@ void PWMDimmerHandleButton(void)
|
|||||||
int32_t bri_offset = 0;
|
int32_t bri_offset = 0;
|
||||||
uint8_t power_on_bri = 0;
|
uint8_t power_on_bri = 0;
|
||||||
uint8_t dgr_item = 0;
|
uint8_t dgr_item = 0;
|
||||||
uint8_t dgr_value;
|
uint8_t dgr_value = 0;
|
||||||
uint8_t dgr_more_to_come = false;
|
uint8_t dgr_more_to_come = false;
|
||||||
uint32_t button_index = XdrvMailbox.index;
|
uint32_t button_index = XdrvMailbox.index;
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
@ -475,7 +475,7 @@ void PWMDimmerHandleButton(void)
|
|||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
power_button_increases_bri ^= 1;
|
power_button_increases_bri ^= 1;
|
||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
dgr_item = 255;
|
dgr_item = DGR_ITEM_FLAGS;
|
||||||
state_updated = true;
|
state_updated = true;
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
}
|
}
|
||||||
@ -510,7 +510,7 @@ void PWMDimmerHandleButton(void)
|
|||||||
// If the down button was tapped and held, we changed the fixed color. Send a final
|
// If the down button was tapped and held, we changed the fixed color. Send a final
|
||||||
// update.
|
// update.
|
||||||
else if (down_button_tapped) {
|
else if (down_button_tapped) {
|
||||||
dgr_item = 255;
|
dgr_item = DGR_ITEM_FLAGS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,7 +551,7 @@ void PWMDimmerHandleButton(void)
|
|||||||
// button is pressed. The new brightness will be calculated below.
|
// button is pressed. The new brightness will be calculated below.
|
||||||
if (button_hold_time[button_index] >= now) {
|
if (button_hold_time[button_index] >= now) {
|
||||||
bri_offset = (is_down_button ? -1 : 1);
|
bri_offset = (is_down_button ? -1 : 1);
|
||||||
dgr_item = 255;
|
dgr_item = DGR_ITEM_FLAGS;
|
||||||
state_updated = true;
|
state_updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,7 +559,7 @@ void PWMDimmerHandleButton(void)
|
|||||||
// brightness and sent updates with the more-to-come message type while the button was
|
// brightness and sent updates with the more-to-come message type while the button was
|
||||||
// held. Send a final update.
|
// held. Send a final update.
|
||||||
else if (!button_hold_processed[button_index]) {
|
else if (!button_hold_processed[button_index]) {
|
||||||
dgr_item = 255;
|
dgr_item = DGR_ITEM_FLAGS;
|
||||||
state_updated = true;
|
state_updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -666,7 +666,7 @@ void PWMDimmerHandleButton(void)
|
|||||||
// update.
|
// update.
|
||||||
if (dgr_item) {
|
if (dgr_item) {
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
if (dgr_item == 255) dgr_item = 0;
|
AddLog_P2(LOG_LEVEL_ERROR, PSTR("PWMDimmer: sending DGR item %u"), dgr_item);
|
||||||
SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), dgr_item, dgr_value);
|
SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), dgr_item, dgr_value);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user