Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readout of Shelly 3 EM broken with update of ESPHome to 2024.6 & tentative solution #177

Open
fploen opened this issue Jun 20, 2024 · 2 comments

Comments

@fploen
Copy link

fploen commented Jun 20, 2024

Unfortunately, coding changes to http_request does break the previous readout code for Shelly 3 EM.

I thought the below to be a workaround for code file shelly-3em-http-status-json.yaml
https://github.com/syssi/esphome-soyosource-gtn-virtual-meter/blob/main/powermeter-sensor-examples/shelly-3em-http-status-json.yaml

However, I find that the ESP resets itself in regular time periods, but can't seem to find the reason for it... So below possibly still contains a bug I did not find so far.

I suggest the following (works for me). The definition of max_response_buffer_size is important, as the Shelly readout is more than 1k of characters.

substitutions:
  shelly_3em_url: "http://192.168.xxx.x/status/" // adjust to your Shelly 3 EM IP address

http_request:
  id: http_request0
  useragent: esphome/device
  timeout: 1000ms
  esp8266_disable_ssl_support: true (comment if no ESP8266 in use)

sensor:
  - platform: template
    id: powermeter0
    name: "Instantaneous Power"
    unit_of_measurement: W
    device_class: "power"
    accuracy_decimals: 2
    update_interval: never

interval:
  - interval: 1100ms
    then:
      - http_request.get:
          url: ${shelly_3em_url}
          headers:
            Content-Type: application/json
          capture_response: true
          max_response_buffer_size: 2000
		  on_response:
            then:
              - lambda: |-
                  json::parse_json(body, [](JsonObject root) -> bool {
                    id(powermeter0).publish_state(root["total_power"]);
                    return true;
                  });
@fploen fploen changed the title Readout of Shelly 3 EM broken with update of ESPHome to 2024.6 Readout of Shelly 3 EM broken with update of ESPHome to 2024.6 & tentative solution Jun 20, 2024
@syssi
Copy link
Owner

syssi commented Jun 24, 2024

Do you like to make a contribution / prepare a pull request to update the broken(?) snippet.

@fploen
Copy link
Author

fploen commented Jun 24, 2024

Do you like to make a contribution / prepare a pull request to update the broken(?) snippet.

Actually I see a switch to the updated code version is not possible yet, due to an identified bug in the http_request memory allocation, leading to crash of ESP due to short memory. The bug is identified and should be fixed with the next update.

See here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants