Fix Button discovery payload #421

This commit is contained in:
fvanroie 2023-01-28 23:10:18 +01:00
parent 972ed6583f
commit d664693407
2 changed files with 49 additions and 32 deletions

View File

@ -10,7 +10,7 @@
// Device Drivers // Device Drivers
#include "dev/device.h" #include "dev/device.h"
#include "drv/tft/tft_driver.h" #include "drv/tft/tft_driver.h"
//#include "drv/touch/touch_driver.h" // #include "drv/touch/touch_driver.h"
#ifdef ARDUINO_ARCH_ESP8266 #ifdef ARDUINO_ARCH_ESP8266
#define INPUT_PULLDOWN INPUT #define INPUT_PULLDOWN INPUT
@ -67,7 +67,7 @@ static inline void gpio_update_group(uint8_t group, lv_obj_t* obj, bool power, i
// uint32_t div_a; /*!<Division factor. Range: 0 ~ 63. */ // uint32_t div_a; /*!<Division factor. Range: 0 ~ 63. */
// } adc_digi_clk_t; // } adc_digi_clk_t;
#include "driver/adc.h" #include "driver/adc.h"
//#include "driver/dac_common.h" // #include "driver/dac_common.h"
#include "driver/ledc.h" #include "driver/ledc.h"
#include "driver/uart.h" #include "driver/uart.h"
#include "esp32-hal-dac.h" #include "esp32-hal-dac.h"
@ -815,7 +815,7 @@ hasp_gpio_config_t gpioGetPinConfig(uint8_t num)
void gpio_discovery(JsonObject& input, JsonArray& relay, JsonArray& light, JsonArray& dimmer) void gpio_discovery(JsonObject& input, JsonArray& relay, JsonArray& light, JsonArray& dimmer)
{ {
char description[20]; char description[20] = "";
for(uint8_t i = 0; i < HASP_NUM_GPIO_CONFIG; i++) { for(uint8_t i = 0; i < HASP_NUM_GPIO_CONFIG; i++) {
switch(gpioConfig[i].type) { switch(gpioConfig[i].type) {
@ -836,6 +836,7 @@ void gpio_discovery(JsonObject& input, JsonArray& relay, JsonArray& light, JsonA
break; break;
case SWITCH: case SWITCH:
case BUTTON ... TOUCH:
strcpy_P(description, PSTR("none")); strcpy_P(description, PSTR("none"));
break; break;
case BATTERY: case BATTERY:
@ -910,9 +911,21 @@ void gpio_discovery(JsonObject& input, JsonArray& relay, JsonArray& light, JsonA
case WINDOW: case WINDOW:
strcpy_P(description, PSTR("window")); strcpy_P(description, PSTR("window"));
break; break;
case CARBON_MONOXIDE:
strcpy_P(description, PSTR("carbon_monoxide"));
break;
case RUNNING:
strcpy_P(description, PSTR("running"));
break;
case TAMPER:
strcpy_P(description, PSTR("tamper"));
break;
case UPDATE:
strcpy_P(description, PSTR("update"));
break;
case hasp_gpio_type_t::FREE: case hasp_gpio_type_t::FREE:
default: default:
break; strcpy_P(description, PSTR("unknown"));
} }
if((gpioConfig[i].type >= hasp_gpio_type_t::SWITCH && gpioConfig[i].type <= hasp_gpio_type_t::WINDOW) || if((gpioConfig[i].type >= hasp_gpio_type_t::SWITCH && gpioConfig[i].type <= hasp_gpio_type_t::WINDOW) ||

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie /* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_GPIO_H #ifndef HASP_GPIO_H
@ -95,6 +95,14 @@ enum hasp_gpio_type_t {
BUZZER = 0x40, BUZZER = 0x40,
HAPTIC = 0x41, HAPTIC = 0x41,
AWNING = 0x89,
BLIND = 0x8A,
CURTAIN = 0x8B,
DAMPER = 0x8C,
GATE = 0x8D,
SHADE = 0x8E,
SHUTTER = 0x8F,
/* Inputs */ /* Inputs */
SWITCH = 0xA0, // Binary Sensors SWITCH = 0xA0, // Binary Sensors
BATTERY = 0xA1, BATTERY = 0xA1,
@ -121,14 +129,10 @@ enum hasp_gpio_type_t {
SOUND = 0xB6, SOUND = 0xB6,
VIBRATION = 0xB7, VIBRATION = 0xB7,
WINDOW = 0xB8, WINDOW = 0xB8,
CARBON_MONOXIDE = 0xB9,
AWNING = 0xB9, RUNNING = 0xBA,
BLIND = 0xBA, TAMPER = 0xBB,
CURTAIN = 0xBB, UPDATE = 0xBC,
DAMPER = 0xBC,
GATE = 0xBD,
SHADE = 0xBE,
SHUTTER = 0xBF,
BUTTON = 0xF0, BUTTON = 0xF0,
BUTTON_TOGGLE_UP = 0xF1, BUTTON_TOGGLE_UP = 0xF1,