Unfortunately, I currently have a problem that I can’t solve and can’t find any further information.
I would like to use ESPHome to collect values from a Tasmota device and visualize them on the ESPHome web server.
Tasmota offers the option of outputting data in Json format via web request.
In my case the command is: http://192.168.178.18/cm?cmnd=status%2010
I then get the following response in the browser:
{“StatusSNS”:{“Time”:“2024-07-23T21:18:52”,“DVS7420”:{“energy”:20302.00,”power”:353.150,”Meter_number”:“123456”}}}
Now read the whole thing into ESPHome via http_request.get.
Unfortunately it doesnt work.
YAML
esphome:
name: displaytest
friendly_name: displaytest
esp8266:
board: d1_mini
# Enable logging
logger:
level: VERY_VERBOSE
# Enable Home Assistant API
api:
encryption:
key: "xxxxxx"
ota:
- platform: esphome
password: "xxxxxx"
web_server:
port: 80
version: 3
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "xxxxx"
password: "xxxxxx"
captive_portal:
http_request:
useragent: esphome/device
esp8266_disable_ssl_support: true
timeout: 10s
#verify_ssl: false
#id: http_request_test
time:
- platform: sntp
id: sntp_time
timezone: 'Europe/Berlin'
interval:
- interval: 1min
then:
- http_request.get:
url: http://192.168.178.18/cm?cmnd=status%2010
headers:
Content-Type: application/json
capture_response: true
#max_response_buffer_size: 4096
on_response:
then:
- lambda: |-
json::parse_json(body, [](JsonObject root) -> bool {
id(power_meter).publish_state(root["power"].as< float >());
return true;
});
sensor:
- platform: template
name: "Power"
id: power_meter
- platform: wifi_signal
name: "httptest wifi signal"
update_interval: 60s
- platform: uptime
name: "httptest uptime"
text_sensor:
- platform: wifi_info
ip_address:
name: IP Address
id: ip
ssid:
name: Connected SSID
id: ssid
I get the following error message
[22:59:34][V][sensor:043]: 'httptest uptime': Received new state 42.570999
[22:59:34][D][sensor:093]: 'httptest uptime': Sending state 42.57100 s with 0 decimals of accuracy
[22:59:34][V][json:038]: Attempting to allocate 512 bytes for JSON serialization
[22:59:34][V][json:058]: Size after shrink 76 bytes
[22:59:34][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
key: 2428623192
state: 42.571
missing_state: NO
}
[22:59:34][W][component:237]: Component uptime.sensor took a long time for an operation (66 ms).
[22:59:34][W][component:238]: Components should block for at most 30 ms.
[22:59:34][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=42185 (now=43191)
[22:59:34][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=42192 (now=43198)
[22:59:35][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=43185 (now=44185)
[22:59:35][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=43192 (now=44195)
[22:59:35][VV][scheduler:225]: Running interval 'update' with interval=60000 last_execution=4294951804 (now=44509)
[22:59:36][V][http_request.arduino:055]: ESP8266 HTTP connection with WiFiClient
[22:59:36][W][http_request.arduino:065]: Using HTTP on Arduino version >= 3.1 is **very** slow. Consider setting framework version to 3.0.2 in your YAML, or use HTTPS
[22:59:36][D][http_request.arduino:124]: Content-Length: -1
[22:59:36][E][http_request.arduino:137]: Stream pointer vanished!
[22:59:36][E][http_request.arduino:137]: Stream pointer vanished!
[22:59:36][E][http_request.arduino:137]: Stream pointer vanished!
[22:59:36][E][http_request.arduino:137]: Stream pointer vanished!
I set the LOG level to “VERY VERBOSE” but can’t find the error.
Maybe someone has an idea.