Core: Powerwall doesn't show any sensor when the utility data is missing

Created on 14 Apr 2020  Â·  63Comments  Â·  Source: home-assistant/core

The problem

I'm running under HA 0.108.3
I installed the new Tesla PW2 integration, and all went right, but I cannot see any sensor

Environment

HA 0.108.3 installed starting from image for raspberry, downloaded from home assistant web site.

  • Integration causing this issue: Tesla Powerwall 2

Problem-relevant configuration.yaml


Traceback/Error logs


Additional information

powerwall

Most helpful comment

You can also use a browser and navigate to https://<powerwall-ip>/api/system_status/soe and https://<powerwall-ip>/api/meters/aggregates if you don't want to fiddle with python.

All 63 comments

Please fill out the issue template, you can find it by clicking on New Issue and then selecting Report a bug with Home Assistant. Copy and paste the provided template into this already created issue, click preview to take a look at the empty template and then fill out as much as you can. Any additional information can be helpful!

Thanks for understanding :)

Sorry,
it’s my first time in opening an issue on GitHub :)

I hope my corrections are right now.

Thanks a lot,

Enrico

Il giorno 14 apr 2020, alle ore 17:08, springstan notifications@github.com ha scritto:

Please fill out the issue template, you can find it by clicking on New Issue and then selecting Report a bug with Home Assistant. Copy and paste the provided template into this already created issue, click preview to take a look at the empty template and then fill out as much as you can. Any additional information can be helpful!

Thanks for understanding :)

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/34207#issuecomment-613498990, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNBTRQCIFZU7KYICS6LORDRMR375ANCNFSM4MH2CSDA.

Hey there @bdraco, @jrester, mind taking a look at this issue as its been labeled with a integration (powerwall) you are listed as a codeowner for? Thanks!

Hi @mago-kamar

Are there any messages in the log?

Hi @bdraco ,
unfortunately nothig referring to the Tesla PW2 integration.
The installation of the integration didn't show any error, and I have it on the integrations screen.

logger:
  default: debug

Try setting your logging to debug and restarting to see if you get any error related to the powerwall

Hi,
the only errors are referred to Mosquitto, because I'm doing so test.
But nothing about Tesla PW2.

A lòittle cut and paste of the log:
20-04-14 16:05:45 INFO (MainThread) [supervisor.auth] Auth request from core_mosquitto for mqtt_ETM
20-04-14 16:05:50 ERROR (MainThread) [supervisor.homeassistant] Error on call http://172.30.32.1:8123/api/hassio_auth:
20-04-14 16:05:50 ERROR (MainThread) [supervisor.auth] Can't request auth on Home Assistant!
20-04-14 16:05:54 INFO (MainThread) [supervisor.auth] Auth request from core_mosquitto for mqtt_ETM
20-04-14 16:05:59 ERROR (MainThread) [supervisor.homeassistant] Error on call http://172.30.32.1:8123/api/hassio_auth:
20-04-14 16:05:59 ERROR (MainThread) [supervisor.auth] Can't request auth on Home Assistant!
20-04-14 16:06:04 INFO (MainThread) [supervisor.auth] Auth request from core_mosquitto for mqtt_ETM
20-04-14 16:06:08 ERROR (MainThread) [supervisor.homeassistant] Error on call http://172.30.32.1:8123/api/hassio_auth:
20-04-14 16:06:08 ERROR (MainThread) [supervisor.auth] Can't request auth on Home Assistant!
20-04-14 16:06:14 INFO (MainThread) [supervisor.auth] Auth request from core_mosquitto for mqtt_ETM
20-04-14 16:06:17 ERROR (MainThread) [supervisor.homeassistant] Error on call http://172.30.32.1:8123/api/hassio_auth:
20-04-14 16:06:17 ERROR (MainThread) [supervisor.auth] Can't request auth on Home Assistant!
20-04-14 16:06:24 INFO (MainThread) [supervisor.auth] Auth request from core_mosquitto for mqtt_ETM
20-04-14 16:06:27 ERROR (MainThread) [supervisor.homeassistant] Error on call http://172.30.32.1:8123/api/hassio_auth:
20-04-14 16:06:27 ERROR (MainThread) [supervisor.auth] Can't request auth on Home Assistant!

Which version of the firmware does your powerwall have (you can check in the tesla app)?

1.45.2

I've got the same version.

If you use the underlying library (there are some examples on the github page) https://github.com/jrester/tesla_powerwall, can you get the powerwall to give up any information?

You can also use a browser and navigate to https://<powerwall-ip>/api/system_status/soe and https://<powerwall-ip>/api/meters/aggregates if you don't want to fiddle with python.

I already am able to read values from my PW2.
I wrote a phyton code, showing me a web page with the values.
Here a little piece of that code:

Lettura produzione energetica da 123SolarLog ---------------------------

$URL_123solar = "http://192.168.178.30/123solar/programs/programmultilive.php";
$json_123solar = file_get_contents($URL_123solar);

$data_123solar = json_decode($json_123solar, true);
if (isset($data_123solar[0]["GPTOT"]))
{
$kw_prod = $data_123solar[0]["GPTOT"];
} else {
$kw_prod = "0";
}
print "Produzione: $kw_prod Wnn";

----------------------

Please give the https://github.com/jrester/tesla_powerwall library a try and see if it will give you the data.

Installed, but I have a syntax error:

File "test.py", line 92
self.assertEqual(pw._endpoint, f"https://{test_endpoint_1}/api/")
^
SyntaxError: invalid syntax

I run the program, on a raspberry

What python version are you using? It seems you are using python2 but you need python3. Run python --version if you are unsure.

Python 2.7.16

I have not a machine with ver. 3 :(

Please try again with python3. Check if it is installed by executing python3 if not install it. I guess for the rasperrypi you can install it with sudo apt install python3 python3-pip but I am not sure.

Testing with python 3
pi@raspberrypiOwnCloudNew:~/tesla_powerwall/tests $ python3 -V
Python 3.7.3

I'v got this other error:
pi@raspberrypiOwnCloudNew:~/tesla_powerwall/tests $ python3 test.py
Traceback (most recent call last):
File "test.py", line 9, in
from tesla_powerwall import (
ModuleNotFoundError: No module named 'tesla_powerwall'

pip3 install --upgrade tesla_powerwall

Ok, done.

Now no errors, but I cannot see any output.
Where should I take a look?

Did you run the tests (tests/test.py)? Those tests are used for testing the functionality of the library and not for the user. Rather use a python3 shell and execute the commands described in the Readme (on the GitHub page). You can for example try get_meters and get_charge.

Sorry for bothering you :)

Should I execute this command?
python3 tests/test.py get_charge

because that command doesn't show any output

It's alright ^^

No, just execute python3 (without the other arguments). This should give you an interactive python shell in which can execute python commands. From there you can then try connecting to your powerwall. It could look something like this:

$ python3
Python 3.8.2 (default, Feb 26 2020, 22:21:03) 
[GCC 9.2.1 20200130] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tesla_powerwall import Powerwall
>>> p = Powerwall("<powerwall-ip>")
>>> p.get_charge()
67
>>> p.get_meters().battery.get_power()
0.1

The >>> prompts you to input your command, everything without a leading >>> should be output.

Here we go :)

from tesla_powerwall import Powerwall
p = Powerwall("192.168.178.40")
p.get_charge()
9

p.get_meters().battery.get_power()
0.5

It's working :)

Okay, so the problem is not with the API.
Could you try to remove the Integration and add it again? To remove it just go to the integration page and click on the configured powerwall. There should be a trash can in the top right corner. Than add it again and go to the entities tab and search for powerwall.

I deleted the integration, and then I added it again, but in the entities, powerwall is not present :(

You said you can see the the configured Integration, right? What exactly does it show you? Does it show you the version and the site name? For me it looks something like this:

2020-04-14 20 53 59 localhost 31b8478afd2c

I updated the powerwall API and Integration. Those changes should go live in the next release. Maybe this resolves the issue.

Schermata 2020-04-14 alle 20 59 35

If I click on TESLA, here what appear:
Schermata 2020-04-14 alle 21 01 47

@mago-kamar Do you see the sensors in the developer states panel? at https://YOURIP:8123//developer-tools/state ?

@mago-kamar Do you see the sensors in the developer states panel? at https://YOURIP:8123//developer-tools/state ?

No, I don't.

Same happening here. Running latest release.

Could you post the output when navigating those urls:

  • https://<powerwall-ip>/api/meters/aggregates
  • https://<powerwall-ip>/api/sitemaster
  • https://<powerwall-ip>/api/site_info
  • https://<powerwall-ip>/api/status

Here you can find the file attachment
Archivio.zip

Thanks a lot :)

Thanks, that helped a lot! I think I found the issue! For you the site_info response does not include a utility, distributer and retailer key. But the Integration uses utility to create the unique_id of your device and because the access of this key fails there is no device created.
It is just weird that although we have the same version the API responses differ. The only difference is the git-hash so it seems we are using indeed two different versions.

I will take a look into how this could be resolved.

@jester, I manually changed the git-hash, because I tought that it could be a sensitive information. 😟
Do you need the correct git-hash?

Oh yeah, that would be great ;)

Okay, so it seems to be site specific whether those arguments are part of the response.
@bdraco What do think about creating the unique_id from the PackageSerialNumber which is returned by api/powerwalls? This should be unique to the powerwalls and as such also to the site.

Hi,
during the update from 0.108.3 to 0.108.4, I was seeing the log activities, and I discovered these errors referring to Tesla PW addon.
Hope they could be useful for your corrections.

LOG

2020-04-15 17:18:35 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up powerwall platform for binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/src/homeassistant/homeassistant/components/powerwall/binary_sensor.py", line 48, in async_setup_entry
entities.append(sensor_class(coordinator, site_info, status, device_type))
File "/usr/src/homeassistant/homeassistant/components/powerwall/entity.py", line 30, in __init__
site_info[SITE_INFO_UTILITY],
KeyError: 'utility'
2020-04-15 17:18:35 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up powerwall platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/src/homeassistant/homeassistant/components/powerwall/sensor.py", line 42, in async_setup_entry
PowerWallEnergySensor(meter, coordinator, site_info, status, device_type)
File "/usr/src/homeassistant/homeassistant/components/powerwall/sensor.py", line 84, in __init__
super().__init__(coordinator, site_info, status, device_type)
File "/usr/src/homeassistant/homeassistant/components/powerwall/entity.py", line 30, in __init__
site_info[SITE_INFO_UTILITY],
KeyError: 'utility'

Okay, so it seems to be site specific whether those arguments are part of the response.
@bdraco What do think about creating the unique_id from the PackageSerialNumber which is returned by api/powerwalls? This should be unique to the powerwalls and as such also to the site.

@jrester

That would be much better than when I used for the initial version. We could do a sorted join of PackageSerialNumber together in case the order changes later.

We would need to migrate the old unique like I had to do in sense/binary_sensor.py so it wouldn't break anyone.

just upgraded to 108.5 and I've found the same issue.

2020-04-15 17:25:43 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up powerwall platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/usr/src/homeassistant/homeassistant/components/powerwall/binary_sensor.py", line 48, in async_setup_entry entities.append(sensor_class(coordinator, site_info, status, device_type)) File "/usr/src/homeassistant/homeassistant/components/powerwall/entity.py", line 30, in __init__ site_info[SITE_INFO_UTILITY], KeyError: 'utility'

Also, unrelated, but should the Grid Status be a binary sensor?
The API reports 3 different states:

  • SystemGridConnected (Online)
  • SystemIslandedActive (Offiline)
  • SystemTransitionToGrid (Restored, but not yet Online)

I guess the third one will be short lived...
Sorry if this hijacking the ticket.

Sorry for my late response was quite busy.
@LordShadowen Are you sure SystemTransitionToGrid is the current value? I get SystemIslandedReady in the API code but it is never used. Also I don't know what it could mean because we already have SystemIslandedActive. I am not sure if this value is even ever returned from the API. I think a normal sensor would just confuse people because normally you just want the information if the System is connected to the grid or not. What do you think?

My powerwall integration is also not working, returning unknown for every sensor.

Fails at initialization:

2020-04-16 19:47:53 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Home Energy Gateway for powerwall
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 216, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/powerwall/__init__.py", line 72, in async_setup_entry
    powerwall_data = await hass.async_add_executor_job(call_base_info, power_wall)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/powerwall/__init__.py", line 113, in call_base_info
    POWERWALL_API_DEVICE_TYPE: power_wall.device_type,
  File "/usr/local/lib/python3.7/site-packages/tesla_powerwall/__init__.py", line 220, in device_type
    return self._get("api/device_type")
  File "/usr/local/lib/python3.7/site-packages/tesla_powerwall/__init__.py", line 114, in _get
    return self._process_response(response)
  File "/usr/local/lib/python3.7/site-packages/tesla_powerwall/__init__.py", line 97, in _process_response
    response_json = response.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 373, in decode
    raise JSONDecodeError("Extra data", s, end, len(s))
simplejson.errors.JSONDecodeError: Extra data: line 1 column 5 - line 2 column 1 (char 4 - 19)

@ocalvo Could you post what is returned when you go to https://<powerwall-api>/api/device_type?

@ocalvo Could you post what is returned when you go to https://<powerwall-api>/api/device_type?

404

Annotation 2020-04-17 110451

And my tesla gateway is functional:
TG

What powerwall software version are you using?
And could you try https://tesla-gateway/api/status?

What powerwall software version are you using?
And could you try https://tesla-gateway/api/status?

{
"start_time":"2020-04-14 10:15:24 +0800",
"up_time_seconds":"73h0m47.641320644s",
"is_new":false,
"version":"1.46.0",
"git_hash":"26a2d96c17d514867a6080ddd3dd7b2669b612a1",
"commission_count":0,
"device_type":"hec",
"sync_type":"v1"
}

Okay, thanks! It seems there is a new powerwall software version and they changed the API. I will try to update the client API as soon as possible.

@jrester thanks so much for the quick responses.

@ocalvo Could you open an issue in the API repo? The update isn't available for me and I could use some sample responses.

Maybe useful. Here is mine:

{
"start_time": "2020-03-30 07:42:26 +0800",
"up_time_seconds": "436h13m12.052808497s",
"is_new": false,
"version": "1.45.2",
"git_hash": "cf942129df3a4da1f4035efe0bc290e0d012ea64"
}

and

{"device_type":"hec"}

@kayloehmann Thanks for your support, but version 1.4.2 is already implemented :)

@jrester I had my own sensors (based on rest calls) and was following the API reference at https://github.com/vloschiavo/powerwall2, but now I understand you're using the python API at https://github.com/jrester/tesla_powerwall. Those values are in fact different, and I have no idea which one is right :) I've never seen the value showing up myself (again, it's probably very short lived after the power comes back up from the grid). I guess you are right that a boolean would be enough for most situations... but perhaps both? Meaning, a boolean for being "online" and a separate status sensor (or even a property of the binary sensor) with the more detailed status... just a thought

@LordShadowen Hope mine are the correct ones ;) But maybe tesla changed the values again in version 1.46.0... But I think an device attribute for the binary sensor would work great.

New issue here

I reopen this issue.
My GW Tesla version is 1.45.2
HA 0.108.8

No entities are shown

Now HA log doesn't show any error, like in the HA 0.108.6.

Schermata 2020-04-22 alle 17 59 29

I found these errors

@mago-kamar Do you have access to the log files? Not the logs from the ui. Maybe there is more information.

@mago-kamar Do you have access to the log files? Not the logs from the ui. Maybe there is more information.

Where have I to see?
From the console, I saw log using command: ha core logs, but no errors from powerwall.

Have you tried setting the log level to debug? This should show some information regarding the Powerwall.
The file should be located at /config/home-assistant.log. Not sure if this command shows all the logs.

Errors found:

LOG PART 1

2020-04-22 20:47:22 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up powerwall platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/src/homeassistant/homeassistant/components/powerwall/sensor.py", line 42, in async_setup_entry
PowerWallEnergySensor(meter, coordinator, site_info, status, device_type)
File "/usr/src/homeassistant/homeassistant/components/powerwall/sensor.py", line 84, in __init__
super().__init__(coordinator, site_info, status, device_type)
File "/usr/src/homeassistant/homeassistant/components/powerwall/entity.py", line 30, in __init__
site_info[SITE_INFO_UTILITY],
KeyError: 'utility'

LOG PART 2

2020-04-22 20:47:22 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up powerwall platform for binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/src/homeassistant/homeassistant/components/powerwall/binary_sensor.py", line 48, in async_setup_entry
entities.append(sensor_class(coordinator, site_info, status, device_type))
File "/usr/src/homeassistant/homeassistant/components/powerwall/entity.py", line 30, in __init__
site_info[SITE_INFO_UTILITY],
KeyError: 'utility'

Okay, this seems to be the old issue. This should be fixed as of version 0.109.0.

Was this page helpful?
0 / 5 - 0 ratings