-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New sensor component : ds248x #6616
Draft
alainstark
wants to merge
46
commits into
esphome:dev
Choose a base branch
from
alainstark:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 39 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
1e3655a
Create __init__.py
alainstark 524dc67
Create sensor.py
alainstark fe39f28
Create ds248x.h
alainstark 4be59c1
Create ds248x.cpp
alainstark 18d6b3e
Update ds248x.h
alainstark 6a74998
Update sensor.py
alainstark 604325e
Update __init__.py
alainstark 74cd8ac
Update __init__.py
alainstark 51f3195
Update __init__.py
alainstark b90f22a
Update ds248x.h
alainstark 1d72e61
Create test.esp32.yaml
alainstark a47ce74
Create test.esp32-c3-idf.yaml
alainstark 2a76cab
Create test.esp32-c3.yaml
alainstark da53326
Create test.esp32-idf.yaml
alainstark d9bd32b
Create test.esp8266.yaml
alainstark c4f653b
Create test.rp2040.yaml
alainstark 902b8f7
Update __init__.py
alainstark d4a922c
Update __init__.py
alainstark a20be88
Update __init__.py
alainstark 808b87d
Update __init__.py
alainstark 342f92b
Update test.esp32-c3.yaml
alainstark 996f453
Update test.esp32-c3-idf.yaml
alainstark 858f5ea
Update ds248x.h
alainstark d0c7709
Update ds248x.cpp
alainstark fc219f1
Update ds248x.h
alainstark cb82bed
Update ds248x.cpp
alainstark bfe072f
Update ds248x.cpp
alainstark cee308a
Update ds248x.cpp
alainstark 46918f6
Update ds248x.cpp
alainstark 2948591
Update ds248x.cpp
alainstark 49cfaab
Update ds248x.cpp
alainstark b024c53
Update ds248x.h
alainstark 13161b1
Update ds248x.cpp
alainstark dd5f076
Update ds248x.cpp
alainstark 4de9b83
Update ds248x.cpp
alainstark 80d1333
Update ds248x.cpp
alainstark 9bfe338
Update __init__.py
alainstark f4474ab
Update __init__.py
alainstark d51c5d2
Update __init__.py
alainstark 7fc73c7
Create __init__.py
alainstark 4740759
Create ds248x_temperature_sensor.h
alainstark 19cd5e9
Create ds248x_temperature_sensor.cpp
alainstark 4924478
Delete esphome/components/ds248x/sensor.py
alainstark 877c7af
Update __init__.py
alainstark 8a03ddc
Update ds248x.cpp
alainstark 0a6698d
Update ds248x.h
alainstark File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import esphome.codegen as cg | ||
import esphome.config_validation as cv | ||
from esphome import pins | ||
from esphome.const import CONF_ID, CONF_SLEEP_PIN, CONF_TYPE | ||
from esphome.components import i2c | ||
|
||
CODEOWNERS = ["@alainstark"] | ||
|
||
MULTI_CONF = True | ||
AUTO_LOAD = ["sensor"] | ||
DEPENDENCIES = ["i2c"] | ||
|
||
CONF_BUS_SLEEP = "bus_sleep" | ||
CONF_HUB_SLEEP = "hub_sleep" | ||
CONF_ACTIVE_PULLUP = "active_pullup" | ||
CONF_STRONG_PULLUP = "strong_pullup" | ||
|
||
ds248x_ns = cg.esphome_ns.namespace("ds248x") | ||
DS248xComponent = ds248x_ns.class_( | ||
"DS248xComponent", cg.PollingComponent, i2c.I2CDevice | ||
) | ||
|
||
ds248xType = ds248x_ns.enum("DS248xType", is_class=True) | ||
|
||
DS248X_TYPES = { | ||
"ds2482-100": ds248xType.DS2482_100, | ||
"ds2482-800": ds248xType.DS2482_800, | ||
} | ||
|
||
|
||
CONFIG_SCHEMA = ( | ||
cv.Schema( | ||
{ | ||
cv.GenerateID(): cv.declare_id(DS248xComponent), | ||
cv.Required(CONF_TYPE): cv.enum(DS248X_TYPES, lower=True), | ||
cv.Optional(CONF_SLEEP_PIN): pins.internal_gpio_output_pin_schema, | ||
cv.Optional(CONF_BUS_SLEEP, default=False): cv.boolean, | ||
cv.Optional(CONF_HUB_SLEEP, default=False): cv.boolean, | ||
cv.Optional(CONF_ACTIVE_PULLUP, default=False): cv.boolean, | ||
cv.Optional(CONF_STRONG_PULLUP, default=False): cv.boolean, | ||
} | ||
) | ||
.extend(cv.polling_component_schema("60s")) | ||
.extend(i2c.i2c_device_schema(0x18)) | ||
) | ||
|
||
|
||
async def to_code(config): | ||
var = cg.new_Pvariable(config[CONF_ID]) | ||
await cg.register_component(var, config) | ||
await i2c.register_i2c_device(var, config) | ||
|
||
cg.add(var.set_ds248x_type(config[CONF_TYPE])) | ||
cg.add(var.set_bus_sleep(config[CONF_BUS_SLEEP])) | ||
cg.add(var.set_hub_sleep(config[CONF_HUB_SLEEP])) | ||
cg.add(var.set_active_pullup(config[CONF_ACTIVE_PULLUP])) | ||
cg.add(var.set_strong_pullup(config[CONF_STRONG_PULLUP])) | ||
|
||
if CONF_SLEEP_PIN in config: | ||
pin = await cg.gpio_pin_expression(config[CONF_SLEEP_PIN]) | ||
cg.add(var.set_sleep_pin(pin)) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move all of the sensor code into a
sensor
directory so that the parent component does not rely on the sensor headers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I have make the change but I am a poor git user.
but the commit failed :
Can you help me please ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I used github web interface to change my code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be doing your work on a new branch inside your fork, not the
dev
branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but as said, I'm a beginner with git. What should I do now?