Hello,
i am trying to read a value from a website and put it in a sensor template so i can see it in the espdevice
running 2025.10
this is the error i get
[E][json:059]: Parse error: IncompleteInput
i want the “Counter” value in sensor template meter_value but i get the error
[E][json:059]: Parse error: IncompleteInput
this is the json output from the website
{
"ActTime" : 1763502375,
"AstrTwilightEnd" : "18:44",
"AstrTwilightStart" : "06:08",
"CivTwilightEnd" : "17:22",
"CivTwilightStart" : "07:31",
"DayLength" : "08:34",
"NautTwilightEnd" : "18:04",
"NautTwilightStart" : "06:48",
"ServerTime" : "2025-11-18 22:46:15",
"SunAtSouth" : "12:26",
"Sunrise" : "08:09",
"Sunset" : "16:43",
"app_version" : "2025.1 (build 16782)",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 1000.0,
"BatteryLevel" : 255,
"Counter" : "3130.049 m3",
"CounterToday" : "486 Liter",
"CustomImage" : 0,
"Data" : "3130.049 m3",
"Description" : "",
"Divider" : 1000.0,
"Favorite" : 1,
"HardwareDisabled" : false,
"HardwareID" : 5,
"HardwareName" : "Dummy",
"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal" : 15,
"HaveTimeout" : false,
"ID" : "141A8",
"LastUpdate" : "2025-11-18 22:17:40",
"Name" : "Watermeter",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
[
0
],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "RFXMeter counter",
"SwitchTypeVal" : 2,
"Timers" : "false",
"Type" : "RFXMeter",
"TypeImg" : "counter",
"Unit" : 1,
"Used" : 1,
"ValueQuantity" : "Custom",
"ValueUnits" : "",
"XOffset" : "0",
"YOffset" : "0",
"idx" : "344",
"price" : "0.9720"
}
],
"status" : "OK",
"title" : "Devices"
}
this is my code
esphome:
name: esp32-watermeter
friendly_name: ESP32-Watermeter
http_request:
verify_ssl: false
useragent: esphome/device
esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
# Enable logging
logger:
level: VERBOSE
baud_rate: 0 ## Must be 0 to prevent reading issues and buffer overflows
# Enable Home Assistant API
api:
reboot_timeout: 0s
ota:
- platform: esphome
password: "fc0ddd346a0faf5c5f5638964fec706b"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.149
gateway: 192.168.1.1
subnet: 255.255.255.0
mqtt:
broker: 192.168.1.50
username: ""
password: ""
captive_portal:
web_server:
local: true
button:
- platform: restart
id: restart_button
name: -Restart
entity_category: diagnostic
- platform: template
name: "meterstand2"
on_press:
then:
- http_request.get:
url: http://192.168.1.50:8084/json.htm?type=command¶m=getdevices&rid=344
request_headers:
Content-Type: application/json
max_response_buffer_size: 10
capture_response: true
on_response:
- if:
condition:
lambda: |-
return response->status_code == 200;
then:
- lambda: |-
json::parse_json(body, [](JsonObject root) -> float {
id(meter_value).publish_state(root["Counter"]);
return true;
});
sensor:
- platform: template
name: "Domoticz watermeter"
id: meter_value
accuracy_decimals: 0
also tried this example from the home assistant site but that one complains a lot about ESP_logi TAG not declared and lots of other errors.
these examples seem so simple but in real life they do not work out of the box
on_...:
- http_request.get:
url: https://esphome.io
capture_response: true
on_response:
then:
- if:
condition:
lambda: return response->status_code == 200;
then:
- lambda: |-
json::parse_json(body, [](JsonObject root) -> bool {
if (root["vol"]) {
id(player_volume).publish_state(root["vol"]);
return true;
}
else {
ESP_LOGI(TAG,"No 'vol' key in this json!");
return false;
}
});
else:
- logger.log:
format: "Error: Response status: %d, message %s"
args: [ 'response->status_code', 'body.c_str()' ]