Comments (7)
In order to see setup messages, you have to watch the serial logs over USB.
from esphome_components.
Ah, yes, that works. I also found out the battery level only updates on a device reset.
from esphome_components.
As the battery level only updated on a device reset, I've changed the component from Component to PollingComponent. The diffs:
ip5306.h
@@ -8,10 +8,11 @@
namespace esphome {
namespace ip5306 {
-class IP5306 : public i2c::I2CDevice, public Component {
+class IP5306 : public i2c::I2CDevice, public PollingComponent {
public:
+ IP5306() : PollingComponent(60000) {}
void setup() override;
- void loop() override;
+ void update() override;
float get_setup_priority() const override;
ip5306.cpp
@@ -25,7 +25,7 @@ void IP5306::setup() {
}
}
-void IP5306::loop() {
+void IP5306::update() {
uint8_t data[2];
if (this->battery_level_ != nullptr) {
if (this->read_register(IP5306_REG_LEVEL, data, 1) != i2c::ERROR_OK) {
@@ -40,8 +40,7 @@ void IP5306::loop() {
case 0x80: value = 75; break;
case 0x00: value = 100; break;
}
- if (!this->battery_level_->has_state() || (this->battery_level_->state != value))
- this->battery_level_->publish_state(value);
+ this->battery_level_->publish_state(value);
}
if (this->read_register(IP5306_REG_READ0, data, 2) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "unable to read status");
from esphome_components.
what device are you using? I think my m5stack fire gets battery level updates with the current implementation but I'll check to be sure
from esphome_components.
Hi, I've activated the ip5306 on my T-Journal as stated in https://discord.com/channels/429907082951524364/951213660905287761/1061049798402265228 . It looks like
the removed if statement is not doing what you expect? I suspect it only publishes the state on the first run to create it and never runs again. To me it also seems better to use the PollingComponent instead of Component to limit the updates to a reasonable rate.
from esphome_components.
I don't see what that PR fixes. The current code will update when the battery level changes. If that's not working, then polling is not going to work either since it's still the same code.
from esphome_components.
The code only publishes on a device reset. Or maybe when the battery level changes, i've not seen this happening. This means when Homeassistant restarts there is no value reported and it's shown as NA. So changing it to a PollinComponent that reports the current value on polling fixes this. Both changes work together.
from esphome_components.
Related Issues (20)
- Feature request: configurable line separator for serial text sensor
- ht16k33_alpha: SparkFun pinout support
- Debugging mode via uart_mitm does not work HOT 3
- ht16k33a needs to updated now that ESPTime namespace change (ESPHome 2023.6) HOT 1
- Uart_mitm usage question HOT 1
- Esmart3 HOT 18
- seesaw neopixel [Adafruit StemmaQT Rotary Encoder]
- Problem using magic_switch component HOT 5
- Esmart3 load On Load Off
- Problem with magic_switch pulse timing report HOT 2
- Could not find components folder for source. HOT 3
- Another problem with magic_switch component
- Failed to compile the firmware with Magic Switch for Sonoff Basic R4 HOT 2
- `serial_csv` text and binary sensor
- No response from any Buttons on an ANO rotary encoder
- [pin] is an invalid option for [binary_sensor.seesaw] HOT 2
- [pin] is an invalid option for [sensor.seesaw] and type: encoder HOT 4
- Adafruit I2C Quad Rotary Encoder Breakout with NeoPixel / Seesaw Neopixel LED issue with 4 LED HOT 1
- Request Qr HOT 1
- on_clockwise & on_anticlockwise triggers invalid options for [Adafruit StemmaQT Rotary Encoder] HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esphome_components.