esphome / esphome/feature-requests

Pulse generator forS0-signal generation

Open
#2,220 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you have/What new integration you would like**
I would like to generate S0 pulses (as a smart meter does). Basically the opposite of the Pulse Meter Sensor.

Usecase: I get the current power (from grid) measured by my smart meter via SML. I would like to send the measured power to my solar inverter. For that the inverter provides two interfaces: Either S0 or modbus. However, the modbus protocoll is not well documented and I assume using S0 pulses would be the easiest way.

My current installation has a separate meter to measure power and generate S0 pulses. Basically, I want to remove that additional meter.

**Please describe your use case for this integration and alternatives you've tried:**

I tried to achieve the desired behaviour by using a simple script, where S0_period is a global variable.
```
script:
- id: S0_script
then:
- while:
condition:
lambda: 'return true;'
then:
- logger.log:
format: "current period %i ms"
args: [ 'id(S0_period)' ]
- if:
condition:
lambda: 'return id(S0_period) > ${S0_impulse_duration};'
then:
- light.turn_on: S0_out
- delay: !lambda 'return ${S0_impulse_duration};'
- light.turn_off: S0_out
- delay: !lambda 'return id(S0_period) - ${S0_impulse_duration};'
else:
- delay: 1000 ms
```
Whenever the SML meter sends a new value, I update the S0_period to an appropriate value.
However,
* the script crashes after some hours and the (currently attached) LED stops blinking
* The blinking is unreliable, i.e. the timing does not match well

I also tried to find a solution via light effects of the light platform, but could not achieve what I need.

So, I would like to have a pulse generator making use of the esp32 hardware timers with:
* adjustable period length / frequency, via variable off-time, i.e. 50ms ... 10 seconds
* fix on-time, i.e. 50 ms or 100ms

**Additional context**

* Docu of pulse meter sensor https://esphome.io/components/sensor/pulse_meter.html
* Docu of the light platform https://esphome.io/components/light/index.html

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the Pulse Meter Sensor documentation at https://esphome.io/components/sensor/pulse_meter.html and the light platform documentation at https://esphome.io/components/light/index.html, then inspect how the existing script drives S0_out. Done means ESPHome can generate S0 pulses with configurable frequency or off-time and a fixed on-time, with reliable timing on the target hardware.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.