-
Notifications
You must be signed in to change notification settings - Fork 2
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
Import Errors on first run #1
Comments
So, I have it organised like this:
config/pyscript.yaml has my config in. Then config/pyscript/apps/powerwall/* and config/pyscript/modules/* with the code in. Maybe, try placing your config outside the config/pyscript directory. I don't know if the presence of a yaml file there might upset the python interpreter (maybe it upsets how it detects packages). That would be my first thing to try. Funnily enough, I have encountered relative import errors before when trying to organise my scripts, never got to the bottom of it, only that the current organisation in config/pyscript/modules gets round it. However, your errors are from pyscript itself, but maybe this does suggest some file (eg config) is in the wrong place. |
That appears to have done it thank you - moving the config up to config/ did the trick and I now see: apps_powerwall_refresh_next_day_rates has been triggered by event octopus_energy_electricity_next_day_rates
22:40:22 - 4 minutes ago
apps_powerwall_refresh_current_day_rates has been triggered by event octopus_energy_electricity_current_day_rates
22:40:22 - 4 minutes ago
apps_powerwall_refresh_previous_day_rates has been triggered by event octopus_energy_electricity_previous_day_rates
22:40:22 - 4 minutes ago In the HA logs which appears good on the surface. Are you aware of any way to see responses/output from the powerwall update as these are not yet updated in the Tesla app? |
The utility rate plan info in the app should update. |
Btw, do you have an export mpan? I haven't added export rates yet, as I'm still waiting on paper work so have nothing to test with. |
As of 05:30 this morning the utility rate pricing and schedule have still not updated. Some key info below, please let me know if you'd rather I log a new issue for posterity:
Thanks a lot for your continued help |
No errors in HA under system logs? One thing that comes to mind is I had issues with the release version of teslapy. I had to place a copy of head under config/pyscript_packages. I also renamed the directory from teslapy to teslapy_latest and updated the imports to teslapy_latest to guarantee that version was being used. Yeah, just checked, last release is still from May. |
No errors under HA logs (with or without debug on pyscripts) however, I did not manually install teslapy (though there's a teslapy_wrapper.py under config/pyscript/modules/). Is this something that I should've installed separately? If so, I'd update the readme which currently says: Installation
1. Install Home Assistant Octopus Energy integration.
2. Install Pyscript integration.
3. Copy the contents of the src directory to the Home Assistant directory /config/pyscript.
4. Add Pyscript app configuration:
|
There is a requirements.txt which pyscript should read and process. The corresponding pip install should be visible in the log. Hmmm, maybe that i changed the log level using the log service call to see it. |
This could be an error/lack of knowledge on my part, I'll do a quick recce now that I understand that part of the process. |
Getting nearer - I spotted an issue with one of the other requirements in the debug logs: 2024-01-26 09:55:36.738 DEBUG (SyncWorker_4) [custom_components.pyscript] Ignoring ''urllib3<2'' because it is not a valid package
2024-01-26 09:55:36.745 DEBUG (MainThread) [custom_components.pyscript] Skipping unpinned version of package 'teslapy' because version '2.8.0' is already installed
2024-01-26 09:55:36.745 DEBUG (MainThread) [custom_components.pyscript] No new packages to install
2024-01-26 09:55:36.863 DEBUG (MainThread) [custom_components.pyscript.eval] modules.powerwall_tariff: calling timedelta(, {'days': 1})
2024-01-26 09:55:36.866 INFO (MainThread) [custom_components.pyscript.global_ctx] Loaded /config/pyscript/modules/powerwall_tariff.py |
Do you still have allow_all_imports: true? |
I do: allow_all_imports: true
hass_is_global: true
apps:
powerwall:
...etc etc I checked that it was there (is_global is too as you can see, I assume that's ok?!) Latest logs are the same after config check and restart: 2024-01-26 10:23:11.530 DEBUG (SyncWorker_2) [custom_components.pyscript] Ignoring ''urllib3<2'' because it is not a valid package
2024-01-26 10:23:11.552 DEBUG (MainThread) [custom_components.pyscript] Skipping unpinned version of package 'teslapy' because version '2.8.0' is already installed
2024-01-26 10:23:11.552 DEBUG (MainThread) [custom_components.pyscript] No new packages to install
|
pip list from within the container shows both TeslaPy (2.8.0) and urllib3 (1.26.18) if that's worth anything |
Seems like it has sort of worked then. Try replacing 'urllib3<2' with urllib3==1.26.18 |
It looks much happier with that in the DEBUG logs: 2024-01-26 10:53:52.439 DEBUG (MainThread) [custom_components.pyscript] Skipping unpinned version of package 'teslapy' because version '2.8.0' is already installed
2024-01-26 10:53:52.440 DEBUG (MainThread) [custom_components.pyscript] Version '1.26.18' for package 'urllib3' detected in '['/config/pyscript/apps/powerwall/requirements.txt']' will be ignored because it is already installed
2024-01-26 10:53:52.440 DEBUG (MainThread) [custom_components.pyscript] No new packages to install
2024-01-26 10:53:52.725 DEBUG (MainThread) [custom_components.pyscript.eval] modules.powerwall_tariff: calling timedelta(, {'days': 1})
2024-01-26 10:53:52.728 INFO (MainThread) [custom_components.pyscript.global_ctx] Loaded /config/pyscript/modules/powerwall_tariff.py
2024-01-26 10:53:52.771 INFO (MainThread) [custom_components.pyscript.global_ctx] Loaded /config/pyscript/modules/teslapy_wrapper.py
2024-01-26 10:53:52.771 DEBUG (MainThread) [custom_components.pyscript.eval] apps.powerwall: calling Rates(, {})
2024-01-26 10:53:52.773 INFO (MainThread) [custom_components.pyscript.global_ctx] Reloaded /config/pyscript/apps/powerwall/__init__.py
2024-01-26 10:53:53.646 DEBUG (MainThread) [custom_components.pyscript] adding state changed listener and starting global contexts
2024-01-26 10:53:53.663 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_previous_day_rates is active
2024-01-26 10:53:53.663 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_current_day_rates is active
2024-01-26 10:53:53.663 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_next_day_rates is active
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_previous_day_rates adding event_trigger octopus_energy_electricity_previous_day_rates
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.event] event.notify_add(octopus_energy_electricity_previous_day_rates) -> adding event listener
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_previous_day_rates waiting for state change or event
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_current_day_rates adding event_trigger octopus_energy_electricity_current_day_rates
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.event] event.notify_add(octopus_energy_electricity_current_day_rates) -> adding event listener
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_current_day_rates waiting for state change or event
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_next_day_rates adding event_trigger octopus_energy_electricity_next_day_rates
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.event] event.notify_add(octopus_energy_electricity_next_day_rates) -> adding event listener
2024-01-26 10:53:53.668 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger apps.powerwall.refresh_next_day_rates waiting for state change or event Is there any indication of how long it should take to update the Powerwalls utility plan settings? I'll leave it running for a few hours now and check the logs when I can. LMK if I can buy you a coffee/beer or support the project...once it's up and working it'll be invaluable to me and I'm sure many others. |
Cool, I'll make that change in head then. I can also add a log statement when the tariff info is pushed to pw. It should happen immediately once the previous/current/next rates have been retrieved. |
It's grabbed all the latest rates but for one reason or another it's not updated the pw yet. |
There is a debug line for tariff data just before it updates the pw (
check for that in the log, and to avoid messing around with log levels, can change the debug function to log to info:
Also, try the head version of teslapy (see #1 (comment)). |
Thanks, it's still not updating (nothing in the log to say it's attempting/failing) and I'm about to be travelling for a few hours so I'll leave it running and then when I get back tonight I shall check again and try the head version. I'll log a new issue if required as the original is certainly resolved. (lmk about that project support/coffee/beer). |
No problem, project support would be much appreciated. |
Firstly thank you for your efforts - the idea of this is amazing for an Octopus/Powerwall user.
Home Assistant - Fresh install with default integrations
HACS - Fresh install
config/configuration.yaml:
I added an include after trying the config in the config/configuration.yaml without success
config/pyscript/config.yaml:
My errors are:
Any assistance greatly appreciated
The text was updated successfully, but these errors were encountered: