Closed evlo closed 2 years ago
Your output shows that the trigger is sent by esphome, but no reply is seen. To my understanding, your settings are equivalent to the Tasmota example you provided.
Can you set the dummy_receiver
option under uart.debug
? Maybe the meter is answering but my component somehow fails to read the answer.
Closing since I cannot debug this without further information.
uart:
id: uart_bus
tx_pin: GPIO21
rx_pin: GPIO20
baud_rate: 300
data_bits: 7
stop_bits: 1
parity: EVEN
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
this is what i do get with
interval:
- interval: 61sec
then:
- uart.write:
id: uart_bus
data: [0x2F, 0x3F, 0x21, 0x0D, 0x0A]
I think the main issue is that
void OBISBase::read_line() {
while (this->available()) { while (this->available()) {
never actually happens - "it is never available"
Is that with the obis component included in the config, or without? Because to my understanding, with dummy_receiver: false
, something has to read the uart bus in order for the debug to actually be printed.
What's the output without the interval
component, only with obis
?
It works! Sorry, I was being stupid and confused and was trying to modify your code while what i missed was this part
baud_rate: 300
data_bits: 7
stop_bits: 1
parity: EVEN
really. And when i figured that out i did not try again with your original code.
current config:
uart:
id: uart_bus
tx_pin: GPIO21
rx_pin: GPIO20
baud_rate: 300
data_bits: 7
stop_bits: 1
parity: EVEN
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
obis:
uart_id: uart_bus
force_update: # optional
interval: 10000
payload: "\x2F\x3F\x21\x0D\x0A"
sensor:
- platform: obis
name: "L1"
channel: "21.8.0"
unit_of_measurement: kWh
accuracy_decimals: 3
device_class: energy
state_class: total_increasing
text_sensor:
- platform: obis
channel: "0.0.0"
name: "Serial Number"
I do not understand why it sends payload for each line or if it reads each line after interval, but at least now it works. I guess 300 baud is also quite slow, but that is only way this meter communicates with me.
Thank you so much for your help.
I'm thinking that maybe the code should be more like this so it does parse all the lines in the obs_buffer
ESP_LOGVV(TAG, "Received: '%s'", this->buf);
this->handle_line(this->buf);
this->index = 0;
ESP_LOGD(TAG, "Iterating return from meter");
read_line();
break;
}
but again, thi is the first time i'm trying to do anything with cpp
Great that it works now!
You are right, there is a logic bug in the part that sends the trigger and then only reads one line. And maybe just removing the break
you cited would fix that (instead of causing the recursion you suggest). BUT I'm more inclined to go a different path: You mentioned the interval:
component earlier (which I didn't know about). Is it possible to simply use them together like this?
uart:
id: uart_bus
tx_pin: GPIO21
rx_pin: GPIO20
baud_rate: 300
data_bits: 7
stop_bits: 1
parity: EVEN
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
interval:
- interval: 10sec
then:
- uart.write:
id: uart_bus
data: [0x2F, 0x3F, 0x21, 0x0D, 0x0A]
obis:
uart_id: uart_bus
sensor:
- platform: obis
name: "L1"
channel: "21.8.0"
unit_of_measurement: kWh
accuracy_decimals: 3
device_class: energy
state_class: total_increasing
text_sensor:
- platform: obis
channel: "0.0.0"
name: "Serial Number"
Because it sure sounds like ESPhome is already providing everything that is needed to trigger the meter to send the data, and I could just add that to the example config and get rid of the PollingOBISComponent again (which I cannot test anyway since my meter sends the data periodically).
That works too, i thought that the obis component would only parse uart after it sends the payload, so i did not even tried it like that.
Thanks again.
Thank you for testing! I've documented the use of the interval component in 891e392bf462cf0839cfed2ec4104992ea1fe203 and removed the force_update
stuff again.
I'm using this code, but I get no reading from the meter, i wonder what can be wrong
before that I tries esphome "SML", but it complained that "1.8.0" is not valid and anyway i can't send "\x2F\x3F\x21\x0D\x0A" or at least i do not know how to make it send that
Before this i tried tasmota
and was able to get reading, but was never able to use tasmota to parse the results into sensors and also tasmota does not like me :)
This is the output i'm getting, i do not understand why the message is repeated
also esp01 i have has only 1MB of memory so no OTA really, i will try some with larger memory later maybe
this is output from the meter