From cd5686438c2a6e515ef4e6a8528abfa9b150574d Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Sun, 12 May 2024 17:54:58 +0200 Subject: [PATCH] Update doc --- docs/index.md | 167 +++--- docs/routers/rem81/router-esphome.yaml | 673 +++++++++++++++++++++++++ 2 files changed, 738 insertions(+), 102 deletions(-) create mode 100644 docs/routers/rem81/router-esphome.yaml diff --git a/docs/index.md b/docs/index.md index b916e97..e207383 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,100 +8,105 @@ description: Home YaS☀️lR is an Arduino / ESP32 firmware for Solar Routers, compatible with most of existing and easy to source hardware components. -If you have a Solar Router at home built by yourself or someone else, there is a good chance that YaS☀️lR will be compatible. +If you already have a Solar Router at home based on ESP32, built by yourself or someone else, there is a good chance that YaS☀️lR will be compatible. [![](./assets/img/screenshots/overview.jpeg)](./assets/img/screenshots/overview.jpeg) -A _Solar Router_ allows to redirect the solar production excess to some appliances instead of returning it to the grid. To work properly, it requires to be connected to a resistive load, such as the resistance of a water tank, because the application will adapt the power sent to this resistance by reducing or increasing its voltage. +**What is a Solar Router ?** -A router can also do more things, like controlling (on/off) the activation of other appliances (with the grid normal voltage and not the dimmed voltage) in case the excess reaches a threshold. For example, one could activate a pump, pool heater, etc if the excess goes above a specific amount, so that this appliance gets the priority over heating the water tank. +A _Solar Router_ allows to redirect the solar production excess to some appliances instead of returning it to the grid. +The particularity of a solar router is that it will dim the voltage and power sent to the appliance in order to match the excess production, in contrary to a simple relay that would just switch on/off the appliance without controlling its power. + +A _Solar Router_ is usually connected to the resistance of a water tank and will heat the water when there is production excess. + +A solar router can also do more things, like controlling (on/off) the activation of other appliances (with the grid normal voltage and not the dimmed voltage) in case the excess reaches a threshold. For example, one could activate a pump, pool heater, etc if the excess goes above a specific amount, so that this appliance gets the priority over heating the water tank. A router can also schedule some forced heating of the water tank to ensure the water reaches a safe temperature, and consequently bypass the dimmed voltage. This is called a bypass relay. +**What YaS☀️lR is not?** + +YaS☀️lR **is not** a product and is not packaged with any hardware. +YaS☀️lR is **only** the software layer that will run on the Solar Router you will have to build (or already have). + ## YaS☀️lR Vision _YaSolR_ is built with this vision in mind: - **OpenSource**: anybody can help and participate in the project -- **Good development practices**, PlatformIO project with versioning and version control, issue management, etc: this is big project and not a simple Arduino project (.ino file) - -- **Flexible**: it is made in a way that you can only pick the components you need depending on the features you want to activate +- **Good development practices**, PlatformIO project with versioning, CI, issue management, etc. + This is big project and not a simple Arduino project (.ino file) - **Hardware compatibility**: supports several phase control systems like Random SSR, Robodyn, many ESP32 boards with WiFi and Ethernet -- **Easy to build**: I wanted to propose a router that everyone can build, with few components to assemble, but at the same time be able to use more powerful components - -- **Easy to repair**: any piece can be easily repaired: there is no complex PCB to solder +- **Flexible**: it is made in a way that you can only pick the components you need depending on the features you want to activate - **Easy to use**: The firmware should be easy to install and use -- **Little to No Harmonics**: Try to be smart about harmonic effects and help you take actions to reduce them or totally remove them with Burst Fire mode - -- **Automation and Integration**: Web API, MQTT Api, Home Assistant auto-discovery, etc +- **Harmonic Regulations**: The firmware gives the user the ability to monitor and limit the router in order to stay below teh levels of harmonic regulations -- **230V 50hz and 110V 60hz**: the dimmer implementation and proposed hardware all support both frequencies ad voltages +- **110/230V 50/60Hz**: the dimmer implementation and proposed hardware all support both frequencies and voltages -- **Statistics / API / Home Automation**: The router exposes a lot of statistics and information through MQTT and REST API and provides a very good integration with Home Assistant or other home automation systems. - The router can be completely controlled remotely through a Home Automation System. - -A Pro version (which includes the use of some commercial libraries) is also provided to get even more features and support. +- **Statistics, API, Home Automation**: Web API, MQTT API, Home Assistant auto-discovery, etc. + The router exposes a lot of statistics and information through MQTT and REST API and provides a very good integration with Home Assistant or other home automation systems. ## YaS☀️lR Features _🚧_ means _In Progress_ -### Up to 2 Routing Outputs +### 2 Routing Outputs A routing output is connected to a resistive load and controls its power. Each output is composed of: -- A **Dimmer** (_required_) to control the power sent to the load. Supported dimmers: +- A **Dimmer** - _required_ - to control the power sent to the load. - - `Robodyn` (Phase Control and Burst mode) - - `Random Solid Sate Relays` (Phase Control and Burst mode) associated with a Zero-Cross Detection module - - `Zero-Cross Solid Sate Relays` (Burst mode) associated with a `Zero-Cross Detection` module (ZCD) + _Supported dimmers:_ + + - `Robodyn` + - `Random Solid Sate Relays` + - `Zero-Cross Solid Sate Relays` _Supported routing algorithms:_ - - `Phase Control` (🚧) (for Robodyn, Random SSR, Triac): more accurate but generates harmonics, should be limited to light loads - - `Burst Fire Control` (🚧) (for Robodyn, Random SSR, Triac, Zero-Cross SSR): no harmonic, but a little less accurate + - `Phase Control` (🚧) (for Robodyn, Random SSR, Triac) + - `Burst Fire Control` (🚧) (for Robodyn, Random SSR, Triac, Zero-Cross SSR) -- A **Bypass Relay** (_recommended_) to force a heating at full power by bypassing the dimmer. - If not installed, the dimmer will be used and set to 100% or 0% to simulate the relay. +- A **Bypass Relay** - _optional_ - to force a heating at full power and bypass the dimmer, because keeping a dimmer `on` generates heat. + If not installed, the dimmer will be used instead and will be set to 0-100% to simulate the relay. - _Supported relays for bypass:_ + _Supported relays:_ + - `Electromagnetic Relays` - `Zero-Cross Solid Sate Relays` - `Random Solid Sate Relays` - - `Electromagnetic Relays` -- A **Temperature Sensor** (_optional_) to monitor the temperature of the water boiler for example. - If not installed, Auto Bypass based on temperature won't be possible. - The Auto Bypass will work but temperature settings will be ignored. - Supported sensors: `DS18B20` +- A **Temperature Sensor** - _optional_ - to monitor the temperature of the water tanker and trigger automatic heating based on temperature thresholds. + + _Supported sensor:_ -- A **Measurement device** (_recommended_) to monitor the power sent to the load. Supported measurement devices: + - `DS18B20` - - `JSY-MK-194T`: to monitor the global routed power and grid power. JSY is limited to only one per UART, but has 2 channels and supports 2-way measurements - - `PZEM-004T V3`: to precisely monitor each output. Several PZ are supported per UART, but only 1 channel and 1-way measurement, which is perfect to measure routed power +- A **Measurement device** - _optional_ - to monitor the power sent to the load. + + _Supported measurement devices:_ + + - `PZEM-004T V3`: can precisely monitor each output independently + - `JSY-MK-194T`: can monitor the global routed power (sum of the two outputs) and grid power with its 2 clamps Each output supports the following features: -- `Auto Bypass`: Plan when to force a heating (days, hours, temperature range) -- `Auto Dimmer`: Take control over the routing yourself or let the router automatically dim based on measured production excess +- `Automatic Bypass`: Automatically force a heating as needed based on days, hours, temperature range +- `Automatic Dimmer`: Automatically send the grid excess to the resistive load through the dimmer (or manually control the dimmer yourself if disabled) - `Dimmer Limit`: Set a limit to the dimmer to avoid routing too much power - `Auto calibration`: Detect and measure the resistive load to provide more accurate routing and statistics - `Remote output` (🚧): Remotely control the router output (dimmer + relay + sensor), in case you need the router control to stay at a place and outputs to be setup remotely - `Statistics`: Harmonic information, power factor, energy, routed power, etc -- `Independent Outputs` (🚧): Outputs are sequential by default meaning that the second output will be activated only when the first one is at 100% and there is still excess power available. - It is possible to switch to `50%/50%` mode or `25%/75%` mode in order to independently activate both outputs and they will both receive the corresponding power. - This is useful to heat 2 water tank at once for example, to avoid one being left at a lower temperature. - `Independent Outputs` requires to install a PZEM measurement module on each output. +- `Independent / Sequential Outputs` (🚧): Outputs are sequential by default (second output activated once first one at 100%). + Independent outputs are also supported to set them at `50%/50%` or `25%/75%` for example -### Up to 2 Relays to connect additional loads +### 2 Relays for additional loads -Relays can be uses to commute (on/off) a load based on a threshold. -Features for each relay: +Relays can be uses to commute (on/off) a load based on a threshold. Features for each relay: - `NO / NC` relay type - `Relay Threshold`: Set a power threshold to automatically switch the relay on/off based on the virtual excess @@ -111,7 +116,8 @@ Features for each relay: Measuring the grid power is essential to know how much power is available to route. The measurement device needs to support 2-way measurement: positive power when importing, negative power when exporting and eventually positive and returned energy counters. -Supported measurement methods: + +_Supported measurement devices:_ - `JSY-MK-194T`: accurate, will also store energy data - `Remote JSY-MK-194T` (🚧): Read the measurement from a JSY board remotely @@ -123,8 +129,8 @@ Thanks to power measurement, the router also provides these features: - `Virtual Excess`: Expose the virtual excess (MQTT, REST API, web) which is composed of the current excess plus the routing power - `EV Charger Compatibility` (i.e OpenEVSE): Don't prevent an EV charge to start (router can have lower priority than an EV box to consume available production excess) -Note that the `JSY-MK-194T` has 2 channels, so it can be used both to measure the grid power but also to measure the total routed power of the router (2 outputs combined). -It cannot be used though to independently measure each router output. +_Note that the `JSY-MK-194T` has 2 channels, so it can be used both to measure the grid power but also to measure the total routed power of the router (2 outputs combined)._ +_It cannot be used though to independently measure each router output._ ### Home Automation Systems @@ -147,9 +153,6 @@ The router can be completely controlled remotely through a Home Automation Syste - `Web console`: View ESP logs live from a Web interface - `Web OTA Firmware Update`: Update firmware through the Web interface - `Stuck relay detection` (🚧): If the relay is associated to some known load, the application will try to detect and warn about a stuck relay. - -Additional components can be installed in the router box: - - `Temperature Sensor`: for router box heat monitoring (Supported type: `DS18B20`) - `Push Button`: Add a push button to restart, reset, activate bypass - `LEDs & Buzzer`: Add LEDs and Buzzer for visual and sound alerts @@ -167,8 +170,8 @@ Additional components can be installed in the router box: ### Pro features -The Pro version is based on [ESP-DASH Pro](https://www.espdash.pro) and provides a better Web interface from which the router can be completely configured and managed. -THe Free version is based on ESP-DASH OSS and is just showing the overview page. +The Pro version is based on [ESP-DASH Pro](https://www.espdash.pro) and [ElegantOTA Pro](https://elegantota.pro), and provides a better Web interface from which the router can be completely configured and managed. +The Free version is based on ESP-DASH OSS and is just showing the overview page. The configuration can still be done online through a "Debug Configuration" page. - `Configuration Pages`: Configure components directly on website @@ -181,53 +184,13 @@ The configuration can still be done online through a "Debug Configuration" page. This project was inspired by the following awesome projects: -**Solar Routers based on RobotDyn AC Dimmer (or similar TRIAC based systems)** - -- [Routeur solaire PV monophasé Le Profes'Solaire](https://sites.google.com/view/le-professolaire/routeur-professolaire) from Anthony -- [Solar Router](https://github.com/benoit-cty/solar-router) from [Benoit Courty](http://courty.fr) -- [Construction d'un Power Router pas à pas](https://ptiwatt.kyna.eu/post/2022/07/09/Construction-d-un-Power-Router-pas-à-pas) de Association P'TIWATT -- Mk2 PV Router - - [MK2 PV Router](https://www.mk2pvrouter.co.uk) (old website) - - [MK2 PV Router](https://mk2pvrouter.com) (new owners) - - [PVRouter-Single](https://github.com/FredM67/PVRouter-Single) (adapted by Frédéric) - - [PVRouter-3-phase](https://github.com/FredM67/PVRouter-3-phase) (adapted by Frédéric) - - [Diverting surplus PV Power, by Robin Emley](https://docs.openenergymonitor.org/pv-diversion/mk2/index.html) -- André (F1ATB): - - [Routeur photovoltaïque Multi-Sources Multi-Modes et Modulaire](https://f1atb.fr/fr/realisation-dun-routeur-photovoltaique-multi-sources-multi-modes-et-modulaire/) - - [Routeur Photovoltaïque Multi-Sources Multi-Modes et Modulaire - Version 8 (DIY)](https://www.youtube.com/watch?v=6aGttWXzGhY) -- Remy (Domo rem81): - - [HA-Routeur Solaire](https://domo.rem81.com/2023/04/14/ha-routeur-solaire/) - - [PV-Routeur Solaire ESP Home](https://domo.rem81.com/2023/07/18/pv-routeur-solaire/) -- Cyril - - [https://ota.apper-solaire.org](https://ota.apper-solaire.org) - - [https://pvrouteur.apper-solaire.org](https://pvrouteur.apper-solaire.org) - - [pv-router-esp32](https://github.com/xlyric/pv-router-esp32) - - [PV-discharge-Dimmer-AC-Dimmer-KIT-Robotdyn](https://github.com/xlyric/PV-discharge-Dimmer-AC-Dimmer-KIT-Robotdyn) - - [FAQ Dimmer de Cyril](https://wiki.apper-solaire.org/index.php?page=faq-dimmer) - -**Solar Routers based on Random SSR** - -- [MaxPV](https://github.com/Jetblack31/MaxPV) -- [Routeur Tignous](https://forum-photovoltaique.fr/viewtopic.php?f=110&t=40512) -- Seb Salva: - - [PV-discharge-Dimmer-AC-Dimmer-KIT-Robotdyn](https://github.com/sebsalva/PV-discharge-Dimmer-AC-Dimmer-KIT-Robotdyn) (fork) - - [MaxPV-relaisext](https://github.com/sebsalva/MaxPV-relaisext) (fork) - -**Solar Routers supporting Burst Mode** - -- Mk2 PV Router - - [MK2 PV Router](https://www.mk2pvrouter.co.uk) (old website) - - [MK2 PV Router](https://mk2pvrouter.com) (new owners) - - [PVRouter-Single](https://github.com/FredM67/PVRouter-Single) (adapted by Frédéric) - - [PVRouter-3-phase](https://github.com/FredM67/PVRouter-3-phase) (adapted by Frédéric) - - [Diverting surplus PV Power, by Robin Emley](https://docs.openenergymonitor.org/pv-diversion/mk2/index.html) -- Cyril - - [https://ota.apper-solaire.org](https://ota.apper-solaire.org) - - [https://pvrouteur.apper-solaire.org](https://pvrouteur.apper-solaire.org) - - [pv-router-esp32](https://github.com/xlyric/pv-router-esp32) - - [PV-discharge-Dimmer-AC-Dimmer-KIT-Robotdyn](https://github.com/xlyric/PV-discharge-Dimmer-AC-Dimmer-KIT-Robotdyn) - - [FAQ Dimmer de Cyril](https://wiki.apper-solaire.org/index.php?page=faq-dimmer) - -**Others** - -- [Tous les routeurs disponibles/connus sur le forum](https://forum-photovoltaique.fr/viewtopic.php?f=49&t=57944&p=640191#p640205) +- [Routeur Solaire Apper](https://ota.apper-solaire.org) (Cyril P.) +- [Routeur Solaire offgrid Réseautonome](https://github.com/SeByDocKy/routeur_solaire) (SeByDocKy) +- [Routeur Solaire MK2 PV Router](https://www.mk2pvrouter.co.uk) (Robin Emley) +- [Routeur Solaire Mk2 PV Router](https://github.com/FredM67/Mk2PVRouter) (Frédéric M.) +- [Routeur Solaire Tignous](https://forum-photovoltaique.fr/viewtopic.php?f=110&t=40512) (Tignous) +- [Routeur Solaire MaxPV](https://github.com/Jetblack31/MaxPV) (Jetblack31) +- [Routeur solaire "Le Profes'Solaire"](https://sites.google.com/view/le-professolaire/routeur-professolaire) (Anthony G.) +- [Routeur solaire "Le Profes'Solaire"](https://github.com/benoit-cty/solar-router) (Adapation from Benoit C.) +- [Routeur solaire Multi-Sources Multi-Modes et Modulaire](https://f1atb.fr/fr/realisation-dun-routeur-photovoltaique-multi-sources-multi-modes-et-modulaire/) (André - F1ATB) +- [Routeur solaire ESP Home](https://domo.rem81.com/index.php/2023/07/18/pv-routeur-solaire/) (Remy) diff --git a/docs/routers/rem81/router-esphome.yaml b/docs/routers/rem81/router-esphome.yaml new file mode 100644 index 0000000..50955ec --- /dev/null +++ b/docs/routers/rem81/router-esphome.yaml @@ -0,0 +1,673 @@ +substitutions: + device_name: "esp176-esp32-routeur-1r" + friendly_name: esp176 + adress_ip: "192.168.0.176" + time_timezone: "Europe/Paris" + +esphome: + name: ${device_name} + platform: ESP32 + board: esp32dev + project: + name: "rem81.esp176-esp32-routeur" + version: "1.2.1" + on_boot: + priority: 800 + # Force mode auto et temperature ok au demarrage + then: + - switch.turn_on: modeauto + - binary_sensor.template.publish: + id: temperatureok + state: ON + +wifi: + networks: + - ssid: !secret wifi + password: !secret mdpwifi + reboot_timeout: 5min + + manual_ip: + static_ip: ${adress_ip} + gateway: 192.168.0.254 + subnet: 255.255.255.0 + +# Enable logging +logger: + baud_rate: 0 + level: DEBUG + # level: INFO + +api: + +ota: + +web_server: + port: 80 + +# Protocole afficheur +i2c: + sda: GPIO21 + scl: GPIO22 + scan: True + id: bus_a + +# Protocole du JSK +uart: + id: mod_bus + tx_pin: 17 + rx_pin: 16 + baud_rate: 38400 + stop_bits: 1 +# debug: +# direction: BOTH +# dummy_receiver: false +# after: +# timeout: 150ms +# sequence: +# - lambda: |- +# UARTDebug::log_string(direction, bytes); + +modbus: + #flow_control_pin: 5 + #send_wait_time: 200ms + id: modbus1 + +modbus_controller: + - id: jsymk + ## the Modbus device addr + address: 0x1 + modbus_id: modbus1 + update_interval: 0.75s + command_throttle: 50ms + + # setup_priority: -10 + +globals: + - id: increment + type: float + restore_value: no + initial_value: "0" + - id: striac + type: float + restore_value: yes + +# Sonde Temperature Dallas +dallas: + - pin: GPIO27 # + update_interval: 60s + +# Informations supplementaires sur le WIFI +#text_sensor: +# - platform: wifi_info +# ip_address: +# name: ${friendly_name}_ESP IP Address +# ssid: +# name: ${friendly_name}_ESP Connected SSID +# bssid: +# name: ${friendly_name}_ESP Connected BSSID +# mac_address: +# name: ${friendly_name}_ESP Mac Wifi Address +# scan_results: +# name: ${friendly_name}_ESP Latest Scan Results + +binary_sensor: + #Etat de la connection + - platform: status + name: "${friendly_name}_Status" + + # Temperature triac OK + - platform: template + name: "${friendly_name} Temp Ok" + id: temperatureok + + # Validation du routeur à déclarer dans HA + - platform: homeassistant + name: "Validation Routeur" + entity_id: "input_boolean.inter_validation_routeur" + publish_initial_state: true + id: val_routeur + +# Input Number +number: + # Seuil Max sortie triac + - platform: template + name: "${friendly_name} P Max" + id: pmax + optimistic: true + restore_value: true + mode: box + min_value: 50 + max_value: 100 + unit_of_measurement: "%" + step: 1 + + # Seuil MAX temperature + - platform: template + name: "${friendly_name} T Max" + id: tmax + optimistic: true + restore_value: true + mode: box + min_value: 0 + max_value: 75 + unit_of_measurement: "C°" + step: 0.1 + + # Coeff Réactivité + - platform: template + name: "${friendly_name} Coeff R" + id: coeff_r + optimistic: true + restore_value: true + mode: box + min_value: 0 + max_value: 10 + unit_of_measurement: "" + step: 0.1 + +sensor: + # tension de l'alimentation + - platform: modbus_controller + modbus_controller_id: jsymk + id: Tension + #name: "${friendly_name} Tension JSYMK" + address: 0x0048 + unit_of_measurement: "V" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # Intensité traversant le tore + - platform: modbus_controller + modbus_controller_id: jsymk + id: Itore + name: "${friendly_name} I_ECS JSYMK" + address: 0x0049 + unit_of_measurement: "A" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # Puissance traversant le tore + - platform: modbus_controller + modbus_controller_id: jsymk + id: puecs + name: "${friendly_name} P_ECS JSYMK" + address: 0x004A + unit_of_measurement: "W" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # Energie lue dans le tore + - platform: modbus_controller + modbus_controller_id: jsymk + id: energietore + name: "${friendly_name} Energie ECS JSYMK" + address: 0x004B + unit_of_measurement: "kWh" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # FP lue dans le tore + - platform: modbus_controller + modbus_controller_id: jsymk + id: fptore + #name: "${friendly_name} FP Tore JSYMK" + address: 0x004C + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # Energie NEG lue dans le tore + - platform: modbus_controller + modbus_controller_id: jsymk + id: energietoren + name: "${friendly_name} Energie ECS Neg JSYMK" + address: 0x004D + unit_of_measurement: "kWh" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + # Sens du courant dans la pince + - platform: modbus_controller + modbus_controller_id: jsymk + id: senspince + #name: "${friendly_name} Sens_Pince JSYMK" + address: 0x004E + register_type: holding + value_type: U_DWORD + bitmask: 0X00010000 + filters: + - multiply: 1 + register_count: 1 + response_size: 4 + # Sens du courant dans le tore + - platform: modbus_controller + modbus_controller_id: jsymk + id: senstor + #name: "${friendly_name} Sens_Tore JSYMK" + address: 0x004E + register_type: holding + value_type: U_DWORD + accuracy_decimals: 0 + bitmask: 0X01000000 + filters: + - multiply: 1 + register_count: 1 + response_size: 4 + + # Fréquence de l'alimentation + - platform: modbus_controller + modbus_controller_id: jsymk + id: frequence + #name: "${friendly_name} Frequence JSYMK" + address: 0x004F + unit_of_measurement: "hz" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.01 + register_count: 1 + response_size: 4 + + # tension de l'alimentation + - platform: modbus_controller + modbus_controller_id: jsymk + id: Tension2 + #name: "${friendly_name} U_Reseau JSYMK" + address: 0x0050 + unit_of_measurement: "V" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # Intensité lue dans la pince + - platform: modbus_controller + modbus_controller_id: jsymk + id: Ireseau + #name: "${friendly_name} I_Reseau JSYMK" + address: 0x0051 + unit_of_measurement: "A" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # puissance lue dans la pince + - platform: modbus_controller + modbus_controller_id: jsymk + id: pureseau + #name: "${friendly_name} P_Reseau JSYMK" + address: 0x0052 + unit_of_measurement: "W" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + on_value: + then: + - lambda: |- + if ( id(senspince).state == 1 ) { + id(pureseau1).publish_state( id(pureseau).state *-1); + } else { + id(pureseau1).publish_state( id(pureseau).state ); + } + + # Energie lue dans la pince + - platform: modbus_controller + modbus_controller_id: jsymk + id: energiepince + #name: "${friendly_name} Energie Reseau JSYMK" + address: 0x0053 + unit_of_measurement: "kWh" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # Energie lue dans le tore + - platform: modbus_controller + modbus_controller_id: jsymk + id: fppince + #name: "${friendly_name} FP Pince JSYMK" + address: 0x0054 + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # Energie NEG lue dans le tore + - platform: modbus_controller + modbus_controller_id: jsymk + id: energienegpince + #name: "${friendly_name} Energie ECS Neg JSYMK" + address: 0x0055 + unit_of_measurement: "kWh" + register_type: holding + value_type: U_DWORD + accuracy_decimals: 1 + filters: + - multiply: 0.0001 + register_count: 1 + response_size: 4 + + # Informations WI_FI + - platform: wifi_signal # Affiche le signal WiFi strength/RSSI en dB + name: "${friendly_name} WiFi Signal dB" + id: wifi_signal_db + update_interval: 60s + entity_category: "diagnostic" + + - platform: copy # Affiche le signal WiFi strength en % + source_id: wifi_signal_db + name: "${friendly_name} WiFi Signal Percent" + filters: + - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); + unit_of_measurement: "Signal %" + entity_category: "diagnostic" + + ############### TEMPLATE ######################" + # Affichage dans HA et sur l'afficheur + - platform: template + name: "${friendly_name} Pu Reseau" + id: pureseau1 + unit_of_measurement: "W" + state_class: "measurement" + + - platform: template + name: "${friendly_name} Increment" + id: afincrement + unit_of_measurement: "" + accuracy_decimals: 2 + state_class: "measurement" + + - platform: template + name: "${friendly_name} Sortie Triac" + id: afstriac + unit_of_measurement: "%" + state_class: "measurement" + accuracy_decimals: 2 + + # Sonde Temperature radiateur + - platform: dallas + address: 0xeb012112e461b128 + name: "${friendly_name} Temp triac" + id: temp_triac + filters: + - filter_out: NAN + +switch: + - platform: gpio + name: "${friendly_name} Relais" + pin: GPIO5 + id: relais + + - platform: template + name: "${friendly_name} Mode Auto" + id: modeauto + optimistic: true + restore_mode: always_on + + - platform: restart + name: "${friendly_name} Restart" + +output: + #LEDS -------------------------------------- + - id: led_conso + platform: gpio + pin: GPIO32 + + - id: led_injec + platform: gpio + pin: GPIO25 + # Pilotage du Dimmer ------------------------ + - platform: ac_dimmer + id: ecs + gate_pin: GPIO33 + method: leading + zero_cross_pin: + number: GPIO34 + mode: + input: true + inverted: yes + min_power: 5% + +light: + - platform: monochromatic + name: "${friendly_name}+STriac" + output: ecs + id: gradateur + default_transition_length: 50ms + +# Affichage +display: + - platform: lcd_pcf8574 + dimensions: 20x4 + address: 0x27 + update_interval: 2s + lambda: |- + it.printf(0,0,"Pr=%0.0fW",id(pureseau1).state); + it.printf(10,0,"Pe=%0.0fW ",id(puecs).state); + it.printf(0,1,"Tr=%0.1f%%",id(striac)); + it.printf(10,1,"Val:%s", id(val_routeur).state ? "OK" : "NOK"); + it.printf(0,2,"Tp=%0.1fc", id(temp_triac).state); + it.printf(10,2,"Etat=%s", id(temperatureok).state ? "OK" : "NOK"); + it.printf(0,3,"Mode=%s", id(modeauto).state ? "Auto" : "Manu"); + it.printf(10,3,"Inc=%0.1f ",id(increment)); + +interval: + - interval: 1s + then: + - script.execute: calcul_injection + + - interval: 2s + then: + - script.execute: etat_production + + # Script activation relais si le triac est au max pendant x sec + - interval: 60s + then: + - script.execute: calcul_relais_surprod + +# ------------------------ Scripts +script: + # + # ------------------------ Calcul puissance injection + - id: calcul_injection + mode: single + then: + - if: + condition: + lambda: "return id(temp_triac).state < (id(tmax).state-2);" + # Si Temp Triac inferieur au seuil-2° alors OK + then: + - binary_sensor.template.publish: + id: temperatureok + state: ON + # Dévalidation du seuil de température + - if: + condition: + lambda: "return id(temp_triac).state >= id(tmax).state;" + # Si Temp Triac supérieur ou égale au seuil alors NOK + then: + - binary_sensor.template.publish: + id: temperatureok + state: OFF + # Validation du seuil de temperature triac + - lambda: |- + id(increment) = id(pureseau1).state*id(coeff_r).state/1000*-1; + + - lambda: |- + id(striac) = id(striac)+id(increment); + + if (!isnan(id(striac))) { + id(striac) = id(striac)+id(increment); + }else{ + id(striac)=0; + } + + if (id(striac) <= 0){ + id(striac) = 0; + } else if(id(striac)>=id(pmax).state){ + id(striac) = id(pmax).state; + } + - logger.log: + format: "Log S Triac %f - Increment %f" + args: ["id(striac)", "id(increment)"] + level: "info" + + # Si Routeur Validé et mode auto et temperature ok alors on active le triac + - if: + condition: + and: + - binary_sensor.is_on: val_routeur + - switch.is_on: modeauto + - binary_sensor.is_on: temperatureok + + then: + - light.turn_on: + id: gradateur + brightness: !lambda |- + return id(striac)/100 ; + - logger.log: + format: "Log Auto OK STriac %f - Increment %f" + args: ["id(striac)", "id(increment)"] + level: "info" + + # Si mode routeur devalidé ou temp NOK alors on désactive le triac + - if: + condition: + and: + - switch.is_on: modeauto + - or: + - binary_sensor.is_off: val_routeur + - binary_sensor.is_off: temperatureok + + then: + - lambda: |- + id(striac) = 0; + id(increment) = 0; + - light.turn_off: gradateur + - logger.log: + format: "Log Auto NOk STriac %f - Increment %f" + args: ["id(striac)", "id(increment)"] + level: "info" + + # Si mode routeur manu + - if: + condition: + and: + - switch.is_off: modeauto + then: + - lambda: |- + id(striac) = 0; + id(increment) = 0; + - logger.log: + format: "Log Manu STriac %f - Increment %f" + args: ["id(striac)", "id(increment)"] + level: "info" + # Affichage STriac et Increment + - lambda: |- + id(afstriac).publish_state( id(striac) ); + id(afincrement).publish_state( id(increment) ); + + - logger.log: + format: "Log Fin STriac %f - Increment %f" + args: ["id(striac)", "id(increment)"] + level: "info" + + # ------------------------------------------- Pilotage led + - id: etat_production + mode: single + then: + - if: + condition: + sensor.in_range: + id: pureseau1 + below: 50 + above: -50 + then: + - output.turn_on: led_conso + - output.turn_on: led_injec + + - if: + condition: + sensor.in_range: + id: pureseau1 + above: 50 + then: + - output.turn_off: led_injec + - output.turn_on: led_conso + + - if: + condition: + sensor.in_range: + id: pureseau1 + below: -50 + then: + - output.turn_off: led_conso + - output.turn_on: led_injec + + # Calcul du relais de surproduction + - id: calcul_relais_surprod + mode: single + then: + # Si sortie triac > pmax-5%, ce qui signifie que le triac est au max sans effet, pendant plus de 30s + # alors on active le relais + # si triac <= 0 alors on desactive le relais + - if: + condition: + - lambda: "return id(striac)>=id(pmax).state-5;" + then: + - delay: 30s + - switch.turn_on: relais + - logger.log: "Relais Activé" + - if: + condition: + - lambda: "return id(striac)<=0;" + then: + - switch.turn_off: relais + - logger.log: "Relais Désactivé"