Skip to content

Commit

Permalink
Merge branch 'development' into pre-release-8.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
arendst committed Oct 2, 2020
2 parents b1782f3 + cc6fb36 commit e1df24b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/OneWire-Stickbreaker-20190506-1.1/OneWire.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void directModeOutput(IO_REG_TYPE pin)
#define DIRECT_WRITE_HIGH(base, pin) directWriteHigh(pin)
#define DIRECT_MODE_INPUT(base, pin) directModeInput(pin)
#define DIRECT_MODE_OUTPUT(base, pin) directModeOutput(pin)
#warning "ESP32 OneWire testing"
//#warning "ESP32 OneWire testing"

#elif defined(__SAMD21G18A__)
#define PIN_TO_BASEREG(pin) portModeRegister(digitalPinToPort(pin))
Expand Down
1 change: 1 addition & 0 deletions tasmota/support_device_groups.ino
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de

#ifdef DEVICE_GROUPS_DEBUG
switch (item) {
case DGR_ITEM_FLAGS:
case DGR_ITEM_LIGHT_FADE:
case DGR_ITEM_LIGHT_SPEED:
case DGR_ITEM_LIGHT_BRI:
Expand Down
30 changes: 14 additions & 16 deletions tasmota/xdrv_12_home_assistant.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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_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 "|" 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 =
"||||"
"VA|%|A|Cm|Hz|%|LX|"
"VA|%|A|cm|Hz|%|lux|"
"%|ppd|ppd|ppd|ppd|ppd|ppd|µg/m³|µg/m³|µg/m³|Cos φ|W| |"
"VAr|kWh|kWh|V|Kg|kWh|"
"ppm|ppm|ppb|R|G|B|" D_UNIT_KELVIN "| |LX|";
"VAr|kWh|kWh|V|kg|kWh|"
"ppm|ppm|ppb|R|G|B|" D_UNIT_KELVIN "| |";

const char kHAssJsonSensorDevCla[] PROGMEM =
"dev_cla\":\"temperature|ic\":\"mdi:weather-rainy|dev_cla\":\"pressure|dev_cla\":\"pressure|"
Expand Down Expand Up @@ -193,8 +193,8 @@ const char HASS_DISCOVER_DEVICE[] PROGMEM = // Basic par
"\"tp\":[\"%s\",\"%s\",\"%s\"]," // Topics for command, stat and tele
"\"rl\":[%s],\"swc\":[%s],\"btn\":[%s]," // Inputs / Outputs
"\"so\":{\"11\":%d,\"13\":%d,\"17\":%d,\"20\":%d," // SetOptions
"\"30\":%d,\"37\":%d,\"68\":%d,\"73\":%d,\"80\":%d},"
"\"lt_st\":%d,\"ver\":1}"; // Light SubType, and Discovery version
"\"30\":%d,\"68\":%d,\"73\":%d,\"80\":%d},"
"\"lk\":%d,\"lt_st\":%d,\"ver\":1}"; // Light SubType, and Discovery version

void NewHAssDiscovery(void)
{
Expand Down Expand Up @@ -239,10 +239,7 @@ void NewHAssDiscovery(void)
// Full 12 chars MAC address as ID
String mac_address = WiFi.macAddress();
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(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);
GetTopic_P(state_topic, TELE, mqtt_topic, PSTR(D_RSLT_HASS_STATE));

Expand All @@ -253,13 +250,13 @@ void NewHAssDiscovery(void)
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,
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);

if (!Settings.flag.hass_discovery) {
snprintf_P(stopic, sizeof(stopic), PSTR("tasmota/discovery/%s/sensors"), unique_id);
Response_P(PSTR("{"));
Response_P(PSTR("{\"sn\":"));
MqttShowSensor();
ResponseAppend_P(PSTR(",\"ver\":1}"));
MqttPublish(stopic, true);
Expand Down Expand Up @@ -967,7 +964,7 @@ void HAssDiscovery(void)

if (Settings.flag.hass_discovery || (1 == hass_mode))
{ // 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
HAssAnnounceButtons();

Expand All @@ -986,7 +983,7 @@ void HAssDiscovery(void)
// Send info about status sensor
HAssAnnounceDeviceInfoAndStatusSensor();
masterlog_level = 0; // Restores weblog level
hass_mode = 3;
hass_mode = 3; // Needed for generating bluetooth entities for MI_ESP32
}
}

Expand Down Expand Up @@ -1074,6 +1071,7 @@ bool Xdrv12(uint8_t function)
if (!hass_init_step)
{
HAssDiscovery(); // Scheduled discovery using available resources
NewHAssDiscovery(); // Send the topics for Home Assistant Official Integration
}
}
else if (Settings.flag.hass_discovery && Settings.tele_period)
Expand All @@ -1093,9 +1091,9 @@ bool Xdrv12(uint8_t function)
case FUNC_MQTT_INIT:
hass_mode = 0; // Discovery only if Settings.flag.hass_discovery is set
hass_init_step = 2; // Delayed discovery
if (!Settings.flag.hass_discovery) {
NewHAssDiscovery();
}
// if (!Settings.flag.hass_discovery) {
// NewHAssDiscovery();
// }
break;

case FUNC_MQTT_SUBSCRIBE:
Expand Down
12 changes: 6 additions & 6 deletions tasmota/xdrv_35_pwm_dimmer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void PWMDimmerHandleButton(void)
int32_t bri_offset = 0;
uint8_t power_on_bri = 0;
uint8_t dgr_item = 0;
uint8_t dgr_value;
uint8_t dgr_value = 0;
uint8_t dgr_more_to_come = false;
uint32_t button_index = XdrvMailbox.index;
uint32_t now = millis();
Expand Down Expand Up @@ -475,7 +475,7 @@ void PWMDimmerHandleButton(void)
#endif // USE_PWM_DIMMER_REMOTE
power_button_increases_bri ^= 1;
#ifdef USE_PWM_DIMMER_REMOTE
dgr_item = 255;
dgr_item = DGR_ITEM_FLAGS;
state_updated = true;
#endif // USE_PWM_DIMMER_REMOTE
}
Expand Down Expand Up @@ -510,7 +510,7 @@ void PWMDimmerHandleButton(void)
// If the down button was tapped and held, we changed the fixed color. Send a final
// update.
else if (down_button_tapped) {
dgr_item = 255;
dgr_item = DGR_ITEM_FLAGS;
}
}
}
Expand Down Expand Up @@ -551,15 +551,15 @@ void PWMDimmerHandleButton(void)
// button is pressed. The new brightness will be calculated below.
if (button_hold_time[button_index] >= now) {
bri_offset = (is_down_button ? -1 : 1);
dgr_item = 255;
dgr_item = DGR_ITEM_FLAGS;
state_updated = true;
}

// If the button was held and the hold was not processed by a rule, we changed the
// brightness and sent updates with the more-to-come message type while the button was
// held. Send a final update.
else if (!button_hold_processed[button_index]) {
dgr_item = 255;
dgr_item = DGR_ITEM_FLAGS;
state_updated = true;
}
}
Expand Down Expand Up @@ -666,7 +666,7 @@ void PWMDimmerHandleButton(void)
// update.
if (dgr_item) {
#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);
#endif // USE_DEVICE_GROUPS
#ifdef USE_PWM_DIMMER_REMOTE
Expand Down

0 comments on commit e1df24b

Please sign in to comment.