[spa06_i2c] Add SPA06-003 Temperature and Pressure Sensor - I2C support (Part 2 of 3) (#14522)

Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
Daniel Kent
2026-03-21 00:38:04 +00:00
committed by GitHub
co-authored by Jonathan Swoboda
parent a9a8f4cb3b
commit 2d39cc2540
9 changed files with 85 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import esphome.codegen as cg
from esphome.components import i2c
import esphome.config_validation as cv
from ..spa06_base import CONFIG_SCHEMA_BASE, to_code_base
AUTO_LOAD = ["spa06_base"]
CODEOWNERS = ["@danielkent-net"]
DEPENDENCIES = ["i2c"]
spa06_ns = cg.esphome_ns.namespace("spa06_i2c")
SPA06I2CComponent = spa06_ns.class_(
"SPA06I2CComponent", cg.PollingComponent, i2c.I2CDevice
)
CONFIG_SCHEMA = CONFIG_SCHEMA_BASE.extend(
i2c.i2c_device_schema(default_address=0x77)
).extend({cv.GenerateID(): cv.declare_id(SPA06I2CComponent)})
async def to_code(config):
var = await to_code_base(config)
await i2c.register_i2c_device(var, config)
@@ -0,0 +1,14 @@
#include "spa06_i2c.h"
#include "esphome/core/hal.h"
#include "esphome/core/log.h"
namespace esphome::spa06_i2c {
static const char *const TAG = "spa06_i2c";
void SPA06I2CComponent::dump_config() {
LOG_I2C_DEVICE(this);
SPA06Component::dump_config();
}
} // namespace esphome::spa06_i2c
+20
View File
@@ -0,0 +1,20 @@
#pragma once
#include "esphome/components/spa06_base/spa06_base.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome::spa06_i2c {
class SPA06I2CComponent : public spa06_base::SPA06Component, public i2c::I2CDevice {
public:
bool spa_read_byte(uint8_t a_register, uint8_t *data) override { return read_byte(a_register, data); }
bool spa_write_byte(uint8_t a_register, uint8_t data) override { return write_byte(a_register, data); }
bool spa_read_bytes(uint8_t a_register, uint8_t *data, size_t len) override {
return read_bytes(a_register, data, len);
}
bool spa_write_bytes(uint8_t a_register, uint8_t *data, size_t len) override {
return write_bytes(a_register, data, len);
}
void dump_config() override;
};
} // namespace esphome::spa06_i2c