TimCsn
(Tim Carlsson)
December 16, 2024, 10:38am
1
I need help with configuration
sensor:
- platform: homeassistant
name: "Momentary Energy"
entity_id: sensor.momentary_active_import
- platform: homeassistant
name: "Energy last h"
entity_id: sensor.effekt_1h
Those two values from sensors at HomeAssistnat should be output as analog signals from 2 pins at ESP 8266
sensor.momentary_active_import → GPIO5
sensor.effekt_1h → GPIO4
Values should be remapped 0 - 400 → 0 - 3.3v
Example.
sensor.effekt_1h = 200 then GPIO4 should show 1,65 Volt
Tinkerer
(aka DubhAd on GitHub)
December 16, 2024, 10:39am
2
This whole post of yours is confusing.
Let’s clear some things up first here…
Just to be clear, you do have both of these sensors working, the sensor data seems accurate and they are integrated into HA through a different esp board, right?
What exactly are these sensors your using and what are you trying to control or what are you trying to achieve by creating analog outputs? Also, to be clear you are wanting static voltage output and not PWM?
TimCsn
(Tim Carlsson)
December 16, 2024, 12:13pm
5
Yes both sensors are working and one is collected be another ESP and the second one is calculated by Home Assistant.
First one is momentary energy consumption in KW 0-400Kw (Industrial meter)
Second one is calculated value of last 60minutes consumption 0-400Kwh
I try to send those values to an PLC thats controlling the heating system via Analog input on the PLC.
The PLC does not have support for MQTT and Home Asistant cant act like TCP Modbus Slave thats why this seams to be only way.
If pure analog signal not working PWM should be working to with a small cap on signal to smoth the pulses?
TimCsn
(Tim Carlsson)
December 16, 2024, 12:28pm
6
I try to do something like this
output:
- platform: esp8266_pwm
pin: GPIO04
id: sensor.momentary_active_import
- calibrate_linear:
- 0 -> 0.0
- 400 -> 100.0
- platform: esp8266_pwm
pin: GPIO05
id: sensor.effekt_1h
- calibrate_linear:
- 0 -> 0.0
- 400 -> 100.0
sensor:
- platform: homeassistant
name: "Momentary Energy"
entity_id: sensor.momentary_active_import
id: sensor.momentary_active_import
- platform: homeassistant
name: "Energy last h"
entity_id: sensor.effekt_1h
id: sensor.effekt_1h
Karosm
(Karosm)
December 16, 2024, 12:48pm
7
I doubt that even compiles.
output:
- platform: esp8266_pwm
pin: GPIO04
id: output_momentary_active_import
sensor:
- platform: homeassistant
name: "Momentary Energy"
entity_id: sensor.momentary_active_import
id: sensor_momentary_active_import
on_value:
then:
- output.set_level:
id: output_momentary_active_import
level: !lambda "return x/400;"
Be aware that if your receiving circuit wants pure analog value, pwm output doesn’t work.
But you can try, even different frequencies…
If it doesn’t work, then you need dac.
TimCsn
(Tim Carlsson)
December 16, 2024, 1:35pm
8
Have to change value to level then it works like expected!
Thanks for extreamly fast help!!!
on_value:
then:
- output.set_level:
id: output_momentary_active_import
value: !lambda "return x/400;"
on_value:
then:
- output.set_level:
id: output_momentary_active_import
level: !lambda "return x/330;"
Karosm
(Karosm)
December 16, 2024, 1:46pm
9
TimCsn:
value to level
Of course… Sorry for that.
TimCsn
(Tim Carlsson)
December 16, 2024, 2:56pm
10
Thats was an easy fix the compline told to change it, Everything works great Thanks Karosm!
Rudd-O
(Rudd-O)
December 17, 2024, 1:31am
12
Do not forget to handle the case when the imported HA sensor is unavailable.