Skip to main content

SolarCost bridge para capturar Totales de Solar Assistant y publicarlos por HTTP.

Project description

SolarCost Bridge

Bridge en Python para:

  • autenticarse contra SolarAssistant,
  • conectarse al websocket de Phoenix LiveView de la solapa Totales,
  • mantener un estado actualizado y persistido,
  • publicar ese estado por HTTP para que otra aplicacion lo consulte.

Estructura

  • src/sa_totals_bridge: codigo fuente
  • requirements.txt: dependencias
  • data/: base SQLite local generada en ejecucion

Instalacion

sudo apt update
sudo apt install -y python3-full python3-venv
sudo mkdir -p /opt/solarcost/bridge
sudo chown -R "$USER":"$USER" /opt/solarcost/bridge
cd /opt/solarcost/bridge
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install solarcost-bridge
sudo "$(command -v sa_bridge)" init

El comando recomendado es sa_bridge. Los comandos anteriores sa-bridge y sa-totals-bridge siguen funcionando por compatibilidad.

Si prefieres mantener el comando anterior, tambien funciona:

sudo "$(command -v sa-totals-bridge)" init

Si Solar Assistant corre en la misma maquina que el bridge, el asistente propone por defecto http://127.0.0.1.

Desinstalacion

pip uninstall solo elimina el paquete instalado dentro del entorno virtual. No borra automaticamente:

  • el archivo solarcost-bridge.env,
  • la base SQLite,
  • el directorio de trabajo,
  • los unit files de systemd,
  • ni los servicios habilitados.

Eso es intencional para no perder configuracion o datos sin querer.

Si quieres una desinstalacion conservando configuracion:

source .venv/bin/activate
python -m pip uninstall solarcost-bridge

O con el asistente interactivo:

sa_bridge uninstall

Si quieres tocar un servicio system, usa:

sudo "$(command -v sa_bridge)" uninstall

Si quieres una desinstalacion limpia completa:

sudo systemctl stop solarcost-bridge.service
sudo systemctl disable solarcost-bridge.service
sudo rm -f /etc/systemd/system/solarcost-bridge.service
sudo systemctl daemon-reload

rm -f /ruta/a/solarcost-bridge.env
rm -f /ruta/a/data/solar_assistant_totals.sqlite3
rm -rf /ruta/al/directorio/de/trabajo

Uso diario

Para ver logs del servicio:

sudo journalctl -u solarcost-bridge.service -f

Para reiniciarlo:

sudo systemctl restart solarcost-bridge.service

Si prefieres ejecutarlo manualmente:

cd /opt/solarcost/bridge
source .venv/bin/activate
sa_bridge run

La API queda por defecto en http://127.0.0.1:8765.

Actualizacion

cd /opt/solarcost/bridge
source .venv/bin/activate
python -m pip install --upgrade solarcost-bridge
sudo systemctl restart solarcost-bridge.service
  • El collector hace una busqueda hacia atras con prev-daily y prev-monthly, y luego vuelve al periodo actual con next-daily y next-monthly.
  • Por defecto intenta traer 12 periodos diarios anteriores y 5 periodos mensuales anteriores.
  • Swagger UI esta en /docs y carga assets desde CDN.

Build y publicacion

Build local:

python -m pip install --upgrade build
python -m build

El repo incluye workflows de GitHub Actions para:

  • CI en push y pull_request,
  • publicacion manual a TestPyPI con workflow_dispatch,
  • publicacion a PyPI al crear un tag v*.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solarcost_bridge-0.1.2.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solarcost_bridge-0.1.2-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file solarcost_bridge-0.1.2.tar.gz.

File metadata

  • Download URL: solarcost_bridge-0.1.2.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for solarcost_bridge-0.1.2.tar.gz
Algorithm Hash digest
SHA256 82f3791d72e8e3b82e0e01a0d646a19455eb7e332b7ff4abd4ed5e7bc77a6646
MD5 2c15a3016906cb7fa32e6246d342a818
BLAKE2b-256 3f7f0a568d2255dbf13c8aba7e8edef3f7d09c6552e25767b1083635d09e54af

See more details on using hashes here.

Provenance

The following attestation bundles were made for solarcost_bridge-0.1.2.tar.gz:

Publisher: publish.yml on gteijeiro/solarcost-bridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file solarcost_bridge-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for solarcost_bridge-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a1f1c4ec4b7c28ce382486cea20b5294ed455e49669272e631fe044c0c20b3d
MD5 14ead9515c6ea891b0461b8d6c6b90d4
BLAKE2b-256 33204d7c9924a5378ebc622926e8cd73ff8a5089c1053dab22c75fd05945d300

See more details on using hashes here.

Provenance

The following attestation bundles were made for solarcost_bridge-0.1.2-py3-none-any.whl:

Publisher: publish.yml on gteijeiro/solarcost-bridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page