Hello i have a strange problem, i use custom sensor component and i send 39768182 but i receive 39768184 in HA and i just cant figure out why this is a simplified code that shows the problem
.yaml
esphome:
name: livingroom
platform: ESP8266
board: esp01_1m
includes:
- my_custom_sensor.h
wifi:
ssid: ""
password: ""
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Livingroom Fallback Hotspot"
password: "tAksgOaENwUm"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
safe_mode: True
sensor:
- platform: custom
lambda: |-
auto my_sensor = new MyCustomSensor();
App.register_component(my_sensor);
return {my_sensor->temperature_sensor, my_sensor->pressure_sensor};
sensors:
- name: "My Custom Temperature Sensor"
unit_of_measurement: °C
accuracy_decimals: 0
- name: "My Custom Pressure Sensor"
unit_of_measurement: hPa
accuracy_decimals: 0
my_custom_sensor.h
class MyCustomSensor : public PollingComponent {
public:
Sensor *temperature_sensor = new Sensor();
Sensor *pressure_sensor = new Sensor();
MyCustomSensor() : PollingComponent(15000) { }
void setup() override {
}
void update() override {
unsigned long test_data=39768182;
temperature_sensor->publish_state(test_data);
pressure_sensor->publish_state(test_data);
}
};
and this is what i get when i run it (same that shows up in ha)
0000 hPa with 0 decimals of accuracy
[19:52:57][D][sensor:092]: 'My Custom Temperature Sensor': Sending state 3976818
4.00000 °C with 0 decimals of accuracy
[19:52:57][D][sensor:092]: 'My Custom Pressure Sensor': Sending state 39768184.0
0000 hPa with 0 decimals of accuracy
[19:53:12][D][sensor:092]: 'My Custom Temperature Sensor': Sending state 3976818
4.00000 °C with 0 decimals of accuracy
[19:53:12][D][sensor:092]: 'My Custom Pressure Sensor': Sending state 39768184.0
0000 hPa with 0 decimals of accuracy
I just cant figure out why and its messing with the custom sensor I’m trying to write
I’m using the latest version of esphome downloaded just a few days ago
any and all tips big and small are welcome thank you!