-
-
Notifications
You must be signed in to change notification settings - Fork 6
Regulation not smooth as F1ATB #54
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
Comments
Like we say in French : "Tu compares des choux et des carottes"... Why did you expect setting the reactivity to 50 on both router will produce the same result? The idea behind this keyword is to allow the user to fine tune the reactivity of the energy diverted to avoid flickering. The best way to regulate a signal is to implement a PID (Proportional Integral Derivate) regulation. |
Well, why not ;-) As F1ATB was an inspiration I believed this part was very similar. I tried other values without smoother behavior. Auto-calibration can be a good feature to help finding the best reactivity, if it exists. It is a shame 😭 Bien à toi, |
Ok, let's try to understand what happens. It look like you have an enphase system. It is not natively supported. So how do you do to get the grid exchange values? As far as I remember enphase is providing a measure every 400ms. This could be an explanation. If you can test it, we can create a power meter dedicated to enphase and compare. |
About multiple router management, this is also an idea I have to work on since starting from today, I have two which may run at the same time ... Maybe you can open an issue about this and describe your needs. It could help me during the development of this feature. |
Thanks Xavier 🙏 F1ATB is using a native integration to Enphase API The YAML of the ESP32 is the following esphome:
name: lctsr02
friendly_name: LCTSR02
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
baud_rate: 115200
level: INFO
logs:
component: ERROR
light: ERROR
# Enable Home Assistant API
api:
encryption:
key: !secret solar_router_02_api_encryption_key
ota:
- platform: esphome
password: !secret solar_router_02_ota_password
# Enable improv serial
improv_serial:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Activate web interface
web_server:
port: 80
binary_sensor:
- platform: gpio
name: "Switch"
pin:
number: GPIO13
inverted: True
mode:
input: true
pullup: true
filters:
- delayed_on: 10ms
substitutions:
# Power meter source -----------------------------------------------------------
# Sensor in home assistant gathering the power consumption
main_power_sensor: sensor.power_supply_electric_consumption_w
# Regulator configuration ------------------------------------------------------
# Define GPIO pin connected to the relay gate.
regulator_gate_pin: GPIO33
# LEDs -------------------------------------------------------------------------
# Green LED is reflecting regulation status
# Yellow LED is reflecting power meter status
green_led_pin: GPIO25
yellow_led_pin: GPIO26
red_led_pin: GPIO27
# power_meter_activated has to be set to 1 to activate the power measurment read
power_meter_activated_at_start: "1"
# Temperature sensor
#temperature_sensor: sensor.lctsr02_temperature
# Sensor in home assistant gathering the temperature
DS18B20_pin: GPIO32
# Safety limit LED configuration
red_led_inverted: "False"
temperature_update_interval: 60s
packages:
common:
url: https://github.com/XavierBerger/Solar-Router-for-ESPHome/
file: solar_router/common.yaml
refresh: 1d
power_meter:
url: https://github.com/XavierBerger/Solar-Router-for-ESPHome/
file: solar_router/power_meter_home_assistant.yaml
refresh: 1d
regulator:
url: https://github.com/XavierBerger/Solar-Router-for-ESPHome/
file: solar_router/regulator_solid_state_relay.yaml
refresh: 1d
solar_router:
url: https://github.com/XavierBerger/Solar-Router-for-ESPHome/
file: solar_router/engine.yaml
refresh: 1d
energy_counter:
url: https://github.com/XavierBerger/Solar-Router-for-ESPHome/
file: solar_router/energy_counter_theorical.yaml
refresh: 1d
temperature_limiter:
url: https://github.com/XavierBerger/Solar-Router-for-ESPHome/
file: solar_router/temperature_limiter_DS18B20.yaml
refresh: 1d The HA is It seems the ZWave Sensor is more difined than Enphase in HA: |
OK, here is what happen (presumably). ZWave read the information and HA read this information (I don't know how often, let's say 600ms) - Solar-Router read information from ESPHome (every second). As far as I remember, Enphase is providing an updated value every 400ms. It is then possible to have 4 time more samples to react. Conclusion: requesting directly EnPhase will be far better because, we will have more point for the regulation. We will remove some network communication (taking some time). We will also remove the dependency to HA which is a point of failure on the current architecture. I'll take a look on the internet to see how I can query a EnPhase product and propose a dedicated engine and I'll will ask you to validate it. (Note: I can't tell you when because developing this router is not my main occupation...). |
Good point !! I think your analysis is good, if reaction is late it is less stable and be chaos. It needs to be at least twice faster than the physical behavior if I remember Fourier :-) |
Hello, Voici un code python que j'ai fait générer par une IA pour récupérer les données d'un Envoy-S (j'espère qu'il fonctionne). import requests
import json
# Configuration
ENVOY_IP = "192.168.1.XX" # Remplacez par l'adresse IP de votre Envoy-S
TOKEN = "votre_token_ici" # Remplacez par votre token d'authentification
# URL de l'API
url = f"https://{ENVOY_IP}/ivp/meters/reports"
# En-têtes de la requête
headers = {
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}"
}
try:
# Effectuer la requête GET
response = requests.get(url, headers=headers, verify=False)
response.raise_for_status()
# Analyser la réponse JSON
data = response.json()
print(json.dumps(data, indent=2))
# Extraire la production et la consommation
production = data.get("production", [{}])[0].get("currW", 0)
print(f"Production actuelle : {production} W")
consumption = data.get("consumption", [{}])[0].get("currW", 0)
print(f"Consommation actuelle : {consumption} W")
except requests.exceptions.RequestException as e:
print(f"Erreur lors de la requête : {e}")
except json.JSONDecodeError:
print("Erreur lors du décodage de la réponse JSON") Peux-tu me dire si avec ça tu arrives à récupérer les données de consommation et production ? Important : Dans les issues, encadre le code que tu ajoutes par 3 Note : il faut un token à récupérer sur l'interface de EnPhase qui va bien. Est-ce que tu pourrais écrire une doc qui explique comment faire (en anglais et avec copie d'écran) pour qu'on puisse l'intégrer de la doc du routeur ? Dans mon idée le token sera récupéré une fois par l'utilisateur et rajouté dans ses secrets. |
Ilooo, Je ne suis pas encore passé par ton code. Je vais vérifier d'abord la pérénité du token car j'ai lu que c'était valide 12h. ensuite je peux faire la doc qui va bien si nécessaire.
J'ai trouvé aussi une très bonne documentation sur tout ça avec le code en python: https://mesgeekeries.ch/2023/11/04/decouvrir-les-api-enphase-iq-gateway-envoy-s/ A toute fin utile, le JSON que je viens de récuperer de l'appel /ivp/meters/reports [
{
"createdAt": 1737550707,
"reportType": "production",
"cumulative": {
"currW": 523.558,
"actPower": 523.558,
"apprntPwr": 567.365,
"reactPwr": -214.212,
"whDlvdCum": 13815850.668,
"whRcvdCum": 13067.428,
"varhLagCum": 6165659.509,
"varhLeadCum": 306241.874,
"vahCum": 18484800.482,
"rmsVoltage": 236.827,
"rmsCurrent": 2.395,
"pwrFactor": 0.94,
"freqHz": 50.00
},
"lines": [
{
"currW": 523.558,
"actPower": 523.558,
"apprntPwr": 567.365,
"reactPwr": -214.212,
"whDlvdCum": 13815850.668,
"whRcvdCum": 13067.428,
"varhLagCum": 6165659.509,
"varhLeadCum": 306241.874,
"vahCum": 18484800.482,
"rmsVoltage": 236.827,
"rmsCurrent": 2.395,
"pwrFactor": 0.94,
"freqHz": 50.00
}
]
},
{
"createdAt": 1737550707,
"reportType": "net-consumption",
"cumulative": {
"currW": 23.232,
"actPower": 23.232,
"apprntPwr": 576.017,
"reactPwr": -493.243,
"whDlvdCum": 32391896.002,
"whRcvdCum": 0.000,
"varhLagCum": 31755.973,
"varhLeadCum": 27283502.610,
"vahCum": 50961905.342,
"rmsVoltage": 236.952,
"rmsCurrent": 2.431,
"pwrFactor": 0.04,
"freqHz": 50.00
},
"lines": [
{
"currW": 23.232,
"actPower": 23.232,
"apprntPwr": 576.017,
"reactPwr": -493.243,
"whDlvdCum": 32391896.002,
"whRcvdCum": 0.000,
"varhLagCum": 31755.973,
"varhLeadCum": 27283502.610,
"vahCum": 50961905.342,
"rmsVoltage": 236.952,
"rmsCurrent": 2.431,
"pwrFactor": 0.04,
"freqHz": 50.00
}
]
},
{
"createdAt": 1737550707,
"reportType": "total-consumption",
"cumulative": {
"currW": 546.790,
"actPower": 546.790,
"apprntPwr": 1143.620,
"reactPwr": -707.455,
"whDlvdCum": 46207069.983,
"whRcvdCum": 0.000,
"varhLagCum": -6133903.536,
"varhLeadCum": 26977260.736,
"vahCum": 50961905.342,
"rmsVoltage": 236.952,
"rmsCurrent": 4.826,
"pwrFactor": 0.48,
"freqHz": 50.00
},
"lines": [
{
"currW": 546.790,
"actPower": 546.790,
"apprntPwr": 1143.620,
"reactPwr": -707.455,
"whDlvdCum": 46207069.983,
"whRcvdCum": 0.000,
"varhLagCum": -6133903.536,
"varhLeadCum": 26977260.736,
"vahCum": 50961905.342,
"rmsVoltage": 236.952,
"rmsCurrent": 4.826,
"pwrFactor": 0.48,
"freqHz": 50.00
}
]
}
] Bien à toi, |
Salut Xavier, J'espère que tu vas bien. Tu veux que j'essaie de coder l'usage du login/pwd pour générer le token et l'utiliser ensuite pour aller chercher les données sur la passerelle ? Bien à toi, |
Hello, Si tu veux, c'est avec plaisir que j'intègrerai ton code. Tu peux prendre le lead sur ce dev et je pourrais t'accompagner si tu veux. J'ai demandé à une IA comment fonctionnaient ces tokens. Sa réponse est que pour l'utilisateur, il est valable 1 an (12 heures pour un installateur). Donc en termes d’architecture, je proposerais de mettre à jour le certificat au démarrage de l'ESP. Il y a des mises à jour régulières de ESPHome donc pas la peine de se prendre la tête pour le renouvellement. A chaque mise à jour, le certificat sera renouvelé. Pour l'instant, je me concentre sur des MR de nouveaux moteurs incluant de bypass. J'aurai un peu plus de temps à consacrer à Enphase quand ce sera mergé. N'hésite pas à utiliser l'IA pour ton dev. Même si le code proposé n'est pas toujours fonctionnel, ça donne de bonnes pistes. |
Ok ! J'essaie d'avancer ! Ca fait un moment que je n'ai pas codé mais c'est l'occasion de m'y remettre (surtout en Python, j'ai plutôt fait du C/C++). Entre la doc que j'ai, ton exemple et celui de F1ATB, Ca devrait être faisable. Bien à toi, |
Salut Xavier ! J'espère que tu vas bien. J'ai trouvé des choses intéressantes sur https://mesgeekeries.ch/2024/02/03/enphase-demystifier-les-api-locales-avec-des-projets-open-source-en-python/ qui se base sur la bibilothèque https://pyenphase.readthedocs.io/en/latest/ qui, à priori, est à la base du module "officiel" Enphase sur Home Assistant. si tu l'inclues avec un pip install pyenphase, tu peux l'utiliser et ca réduit considérablement le code et ca gère les différentes versions de firmware
Une fois la partie authentification faite, il faut juste boucler sur l'update et décupérer les 2 valeurs. Avec ce code, on à juste à renseigner 3 valeurs: J'ai testé chez moi et ca me retour bien les valeurs attendues. Bien à toi, |
Après, la valeur qui serait la plus appropriée à monitorer serait "data.ctmeter_consumption.active_power" qui donne le flux entre le réseau et la maison (négatif lorsque l'on que l'on ne produit pas ou plus de batterie) |
Aller, commençons le développement du Je viens de créer une branche dédiée Premier objectif, récupérer le token @Chilgl0rd, peux-tu tester ? J'ai créé un exemple : esp32-s3-power-meter-proxy.yaml) dans une branche dédiée (cf.: Pour l'instant, j'essaye de récupérer le token sur le site d'Enphase. Si tout se passe bien, tu devrais voir apparaître les 10 premiers caractères du token dans l'interface comme ci dessous (sauf que moi, je n'ai pas de compte... et donc je en peux pas tester et pas de token ): |
Super 🎉 J'ai eu un warning à la compîlation: J'ai donc changé enphase_user par enphase_username dans les vars et ça passe. Par contre, j'ai toujours plus loin cette erreur: Bien à toi, |
Je viens de fixer ces erreurs. Mais à part le |
Alors j'ai relancé l'installation. Pas d'erreurs mais pas de token... Tu veux que je passe le logger sur un niveau en particulier pour avoir plus d'info ? |
En passant en Debug, je ne vois rien, tu as mis des traces des différentes étapes ? Peut être afficher le Envoy {envoy.host} running {envoy.firmware}, sn: {envoy.serial_number} afin de s'assurer que l'on choppe bien la passerelle avant l'authentification ? Bien à toi, |
@Chilgl0rd, je viens de modifier mon code. Il y a maintenant un bouton d'ans l'interface pour demander le token (c'est temporaire). Ça permet de capturer les logs plus facilement. Moi, je reçois un (sans surprise) Au fait, tu as vu mon MP sur le forum de HACF.fr ? |
@XavierBerger Salut ! Pourtant j'ai bien fait un copier/coller et rererevérifié login/pwd et c'est bon
Tu veux que je teste un CURL directement sur l'API ? Je n'ai pas regardé hacf.fr, j'ai vais de ce pas ! :-) |
Hello Xavier,
I started Solar Router with F1ATB and then I found yours. I like your integration with ESPHome/HA ! It is much more integrated with HA and give more flexibility and easiest way to customize.
I tested today both with the same configuration and clear blue sky (1600-1900w production) :-)
Same radiator regulated with SSR, reactivity to 50 on both, stable electricity consumption (#500w), target -10w
I have also Enphase with 1100W batteries. Grid probe via Enphase and Qubino Smart Meter Z-Wave Sensor.
I tested both 10 min each and waiting batteries are 100% charging
But it look like in that configuration F1ATB is more stable and smooth.
As you can see in the snapshot, 13:13 to 13h23 F1ATB and then your implementation.
It is a shame to not have the same behavior.
And idea why ? More conflict with the batteries ?
Maybe in a future add a priority option to battery
Best regards,
Xtof
The text was updated successfully, but these errors were encountered: