Add minimum/maximum to counter#20319
Conversation
|
I know this to be a resubmittion of a PR that went wrong. Still you need to reference the previous PR and add the proper description and reference to docs |
|
Updated description |
|
Need to fix your code (tests aren't passing) |
|
Looks like the test changes didn't make it into this one. |
rohankapoorcom
left a comment
There was a problem hiding this comment.
Added some thoughts, mostly stuff where the incorrect changes were applied on top of dev.
| }) | ||
| SERVICE_SCHEMA_SETUP = vol.Schema({ | ||
| ATTR_ENTITY_ID: cv.entity_ids, | ||
| vol.Optional(CONF_MINIMUM): vol.Any(None, vol.Coerce(int)), |
There was a problem hiding this comment.
Is it worth setting the defaults to max_int and min_int respectively? That way there's no need for None checking in check_boundaries.
| }) | ||
|
|
||
| CONFIG_SCHEMA = vol.Schema({ | ||
| DOMAIN: cv.schema_with_slug_keys( |
There was a problem hiding this comment.
This should not have changed.
| SERVICE_SCHEMA = vol.Schema({ | ||
| vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids, | ||
| SERVICE_SCHEMA_SIMPLE = vol.Schema({ | ||
| vol.Optional(ATTR_ENTITY_ID): cv.entity_ids, |
There was a problem hiding this comment.
This should not have changed.
There was a problem hiding this comment.
I'm also confused at how this could be optional in the first place. The docs agree: https://www.home-assistant.io/components/counter/.
Assuming it should not be optional, SERVICE_SCHEMA_SETUP should extend SERVICE_SCHEMA_SIMPLE which I would recommend renaming to SERVICE_SCHEMA_BASE
| ret[CONF_MAXIMUM] = self._max | ||
| return ret | ||
|
|
||
| def __check_boundaries(self): |
There was a problem hiding this comment.
It feels cleaner if this returns a true/false rather than making the change directly.
There was a problem hiding this comment.
And don't use double underscore in the beginning of the name. One underscore is enough.
|
|
||
|
|
||
| class Counter(RestoreEntity): | ||
| class Counter(Entity): |
There was a problem hiding this comment.
This should not have changed.
| }) | ||
| SERVICE_SCHEMA_SETUP = vol.Schema({ | ||
| ATTR_ENTITY_ID: cv.entity_ids, | ||
| vol.Optional(CONF_MINIMUM): vol.Any(None, vol.Coerce(int)), |
There was a problem hiding this comment.
It feels weird that these attributes are using CONF_ constants and not ATTR_ constants.
|
@spacemanspiff2007 are you going to be able to make these changes? I would love to get these features merged in (would be super useful to me!) |
|
Hi, |
|
@spacemanspiff2007 Closing this until you have time to get back to it. Feel free to reopen it once you do have the time! |
Docs: home-assistant/home-assistant.io#6802
OldPR: #17440
Description:
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf the code does not interact with devices: