core: SMA Solar WebConnect sensors not returning any values

Home Assistant release with the issue: 0.84.6 Last working Home Assistant release (if known): Unknown Operating environment (Hass.io/Docker/Windows/etc.): Docker on Ubuntu 18.10 Component/platform: sensor/sma.py

Description of problem: After adding the required configuration for the SMA Solar WebConnect sensors, the sensors are created but do not return a value (all created sensors have Unknown as value).

There are no errors or warnings in the Home Assistant logs.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

- platform: sma
  host: x.x.x.x
  ssl: false
  verify_ssl: false
  password: xxx
  group: user
  sensors:
    current_power:
    daily_yield:
    total_yield: 

Additional information: When running the example file from pysma (cloned directly from https://github.com/kellerza/pysma) on the physical machine used for Home Assistant, there are no issues and I do get the requested values:

DEBUG:pysma:{"result": {"012F-730A2A43": {"6100_00543100": {"val": null}, "6180_08214800": {"val": [{"tag": 307}]}, "6400_00543A00": {"val": 0}, "6400_00262200": {"val": 203}, "6100_40263F00": {"val": 105}, "6400_00260100": {"val": 6195580}, "6100_0046C200": {"val": 105}, "6100_00464800": {"val": 22742}}}}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (8 by maintainers)

Commits related to this issue

Most upvoted comments

By using the following code, I got rid of all the [pysma] Sensor ... warnings from above, and the sensors are working again:

        # res = next(iter(jmespath.search(JMESPATH_BASE, json_body)))
        if not isinstance(json_body, dict) or 'result' not in json_body:
            _LOGGER.warning("Trying to extract_value from '{}'", json_body)
            return None
        res = next(iter(jmespath.search(JMESPATH_BASE, json_body)))

I now only get the (expected) warnings in the server logs:

2019-01-26 17:49:12 WARNING (MainThread) [pysma] Trying to extract_value from '{}'
2019-01-26 17:49:12 WARNING (MainThread) [pysma] Trying to extract_value from '{}'
2019-01-26 17:49:12 WARNING (MainThread) [pysma] Trying to extract_value from '{}'

Seems like json_body sometimes is Empty, but not always as the sensors are returning the correct values in Home Assistant.

What SMA inverter do you use? I dont think this would have ever worked for you

The latest library allows some flexibility and uses JMES path to extract the values (the HASS component needs a slight change and does not have a config option for this yet…)

To test, you can try to modify the library & change this line to JMESPATH_VAL = '.val' (you will need to find where the pysma library is installed)

If you change it and re-run example.py it might also show you more decoded values…

For reference, you can see the output from my inverter (SB1.5) is somewhat different … and the reason for the current JMESpath value

2018-12-23 22:14:00 DEBUG (MainThread) [pysma] {"result": {"012F-7309879F": {"6400_00260100": {"1": [{"val": 3514949}]}, "6400_00543A00": {"1": [{"val": 16432686}]}, "6100_00543100": {"1": [{"val": 561}]}, "6100_40263F00": {"1": [{"val": null}]}}}}