Comments (3)
Thanks for the quick answer. I'm a beginner with python, and was just playing around trying to find the esios api (there are quite a few, with different data) that better fits my small project (displaying in a HA dasboard a graph of prices from current time until end of day, or end of next day if after 20:30). Tinkering with the code from advanced developpers helps a lot, even if often I don't fully understand all the code.
Gracias!
from aiopvpc.
Hi @Eng65745,
To run an isolated piece of async code you need to invoke it with asyncio.run
:
import asyncio
import aiohttp
from datetime import datetime
from aiopvpc import PVPCData
async def _show_current_pvpc_prices():
async with aiohttp.ClientSession() as session:
pvpc_handler = PVPCData(session=session, tariff="2.0TD")
esios_data = await pvpc_handler.async_update_all(
current_data=None, now=datetime.utcnow()
)
print(esios_data.sensors["PVPC"])
asyncio.run(_show_current_pvpc_prices())
In jupyter
, the code-snippet from the README works without problems, as you can await coroutines
in the cells.
For an invocation inside IDLE or as a python script, you'll need to call asyncio.run(coroutine())
.
But the code-snippet is meant to just document how the library works, not to be used like that 😅
from aiopvpc.
To run an isolated piece of async code
For more context take a look here: https://realpython.com/async-io-python/
from aiopvpc.
Related Issues (20)
- Atributo para obtener el precio actual HOT 8
- Setting development environment HOT 4
- Node red integration HOT 2
- Attributes are referred to current and next_day prices HOT 2
- ¿No hay problema de no utilizar token? HOT 1
- No funciona la integración con HA desde el 2 de noviembre HOT 30
- Include self-consumption values HOT 1
- Sensor unavailable desde 02/11 (con actualización) HOT 4
- sensor.pvpc: repeated bad data update, mark component as unavailable source HOT 13
- Component errors in ha log HOT 4
- Sensor unit of measurement should use ISO 4217 monetary format HOT 1
- Recuperar datos que están a 0 por el fallo
- Detected code that uses str for device registry entry_type HOT 1
- Test failures with holidays-0.13 HOT 1
- Add gas compensation cost HOT 7
- Tag the source HOT 1
- aiopvpc - Repository structure for v4.1.0 is not compliant HOT 3
- openevse don't works in HA Hacs HOT 1
- Integrar precio excedentes de autoconsumo en el índice HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiopvpc.