limengdu / MR24HPC1_ESPHome_external_components

MIT License
12 stars 12 forks source link

Extract data through the API without using esp home #6

Closed SanzISE closed 7 months ago

SanzISE commented 7 months ago

Hi, I´m trying to use the mmwave Human Detector Sensor kit from Seed Studio without using esphome / home assistant cause I can´t have it for now. I was searching for some information and I discovered the .yaml files, I have configured one and I am able to connect my device to my Wifi network, perform successful pings and read the data logs that the sensor throws.

But, what I really need is to extract that data through other source (In my case, I´m using Postman to send some GET request). Using the following .yaml configuration:

substitutions:
  name: "seeedstudio-mmwave-kit"
  friendly_name: "SeeedStudio mmWave Kit"

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"
  name_add_mac_suffix: true
  project:
    name: "seeedstudio.mmwave_kit"
    version: "2.0"
  platformio_options:
    board_build.flash_mode: dio
    board_build.mcu: esp32c3

external_components:
  - source: github://limengdu/mmwave-kit-external-components@main
    refresh: 0s

esp32:
  board: esp32-c3-devkitm-1
  variant: esp32c3
  framework:
    type: esp-idf

# Enable logging
logger:
  hardware_uart: USB_SERIAL_JTAG
  level: DEBUG

api:

ota:

wifi:
    ssid: "MyWifi"
    password: "MiWifiPass"
    manual_ip:
      static_ip: "192.168.88.100" 
      gateway: "192.168.88.1"   
      subnet: "255.255.255.0" 

I got this logs in the cmd terminal:

[15:35:56][D][sensor:094]: 'Body Movement Parameter': Sending state 6.00000  with 0 decimals of accuracy
[15:35:57][D][sensor:094]: 'Body Movement Parameter': Sending state 6.00000  with 0 decimals of accuracy
[15:36:00][D][sensor:094]: 'Body Movement Parameter': Sending state 6.00000  with 0 decimals of accuracy
[15:36:00][D][select:015]: 'Scene': Sending state Living Room (index 1)
[15:36:00][D][number:012]: 'Sensitivity': Sending state 3.000000
[15:36:00][D][select:015]: 'Time For Entering No Person State (Standard Function)': Sending state 30s (index 2)
[15:36:00][D][text_sensor:064]: 'Motion Information': Sending state 'Active'
[15:36:00][D][sensor:094]: 'Body Movement Parameter': Sending state 6.00000  with 0 decimals of accuracy
[15:36:00][D][text_sensor:064]: 'Active Reporting Of Proximity': Sending state 'None'
[15:36:00][D][text_sensor:064]: 'Custom Mode Status': Sending state 'Not in custom mode'
[15:36:00][D][number:012]: 'Custom Mode': Sending state 0.000000
[15:36:00][D][sensor:094]: 'Current Custom Mode': Sending state 0.00000  with 0 decimals of accuracy
[15:36:00][D][text_sensor:064]: 'Heartbeat': Sending state 'Equipment Normal'
[15:36:00][D][select:015]: 'Existence Boundary': Sending state 5.0m (index 9)
[15:36:00][D][select:015]: 'Motion Boundary': Sending state 5.0m (index 9)

In postman:

GET http://192.168.88.100:6053/api/

Returns in my terminal:

[15:37:00][D][api:102]: Accepted 192.168.88.246
[15:37:00][W][api.connection:107]: : Reading failed: BAD_INDICATOR errno=11

I already tested the following api configuration in the .yaml:

api:
  encryption:
    key:  "Base64 password"

And using that key in postman request Header: Key: Authorization value: Base64 password

Returns in my terminal:

[15:43:43][D][api:102]: Accepted 192.168.88.246
[15:43:43][W][api.connection:092]: : Socket operation failed: BAD_INDICATOR errno=11

Do you know how can I extract the sensor data trough an API? Or maybe I´m writing wrong topics in my requests or the problem is in my .yaml file?

Sorry for the time,

Best regards, Sergio.

limengdu commented 7 months ago

I'm sorry I don't have experience with Postman and can't answer your query. But from your first log, I have a feeling that the data should be error free and the messages are being reported properly. Maybe you need to seek help about Postman inside the ESPHome community.

SanzISE commented 7 months ago

Don't worry, I talked about Postman as an example, my problem is that I need to know how Home Assistant / ESPHome accesses the data. I understand that it does it through an api, but I need information about the topics to use. For example http://ESP_IP:ESP_PORT/topic1/topic2 etc..

limengdu commented 7 months ago

I see what you mean, I don't think the device is connected to ESPHome in a way that you can listen to it. But I would suggest you to get the data listening by additionally configuring the mqtt service, here is the example I found on the web.

mqtt:
  broker: '192.168.1.10'
  username: 'youruser'
  password: 'yourpassword'

switch:
  - platform: gpio
    name: "Living Room Light"
    pin: D1
    id: living_room_light
    mqtt:
      state_topic: "home/living_room/light/state"
      command_topic: "home/living_room/light/switch"
SanzISE commented 7 months ago

It works! I am so gratefull with you!