Skip to content

Commit

Permalink
Grammar / Requirements / MD
Browse files Browse the repository at this point in the history
- Fixed many grammar related stuff
- Fix markdown related stuff
- Updated requirements.txt
  • Loading branch information
enkama committed Oct 14, 2023
1 parent c709725 commit bdee701
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 119 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,4 @@ ENV/

# mypy
.mypy_cache/
.idea
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"files.trimTrailingWhitespace": true,
"git.ignoreLimitWarning": true,
"git.ignoreLimitWarning": true
}
192 changes: 96 additions & 96 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion custom_components/variable/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from homeassistant.const import Platform

PLAFORM_NAME = "Variables+History"
PLATFORM_NAME = "Variables+History"
DOMAIN = "variable"

PLATFORMS: list[str] = [
Expand Down
2 changes: 1 addition & 1 deletion custom_components/variable/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def force_update(self) -> bool:

@property
def source_type(self) -> SourceType:
"""Return the source type, eg gps or router, of the device."""
"""Return the source type, e.g. gps or router, of the device."""
return self._attr_source_type

@property
Expand Down
14 changes: 6 additions & 8 deletions custom_components/variable/recorder_history_prefilter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ This module fixes that problem.

#### The Home Assistant Recorder Component

When Home Assistant starts, it loads the recorder component. The recorder component gets it's parameters from the HA configuration file (configuration.yaml) and builds the list of entities, globs, etc. to be filtered. It then starts a state change listener to call the filter module whenever an entity's state is changed. The filter determines if the entity should be added to the History database,
When Home Assistant starts, it loads the recorder component. The recorder component gets its parameters from the HA configuration file (configuration.yaml) and builds the list of entities, globs, etc. to be filtered. It then starts a state change listener to call the filter module whenever an entity's state is changed. The filter determines if the entity should be added to the History database,

For efficiency, Home Assistant builds the filter that is checked one time when Home Assistant is loaded. The filter can not be changed or added to by a custom_component.

#### The Recorder History Prefilter

This module injects it's own filter (actually a copy of the recorder's filter) into the HA Recorder component, removes the HA listener that was set up by the HA Recorder and sets up a new state change listener. It is called when an entity's state changes instead of the HA Recorder filter and checks to see if the entity should be filtered. It the entity is not in it's list, the entity is passed to the HA Recorder filter module as it normally would be.


This module injects its own filter (actually a copy of the recorder's filter) into the HA Recorder component, removes the HA listener that was set up by the HA Recorder and sets up a new state change listener. It is called when an entity's state changes instead of the HA Recorder filter and checks to see if the entity should be filtered. It the entity is not in its list, the entity is passed to the HA Recorder filter module as it normally would be.

### Using the Recorder Prefilter

Expand All @@ -30,26 +28,26 @@ The recorder prefilter is contained in the *recorder_prefilter.py* module.

- Download it and add it to your code base.

Import it into the your module that determines the entities to be filtered. This may be in *\__init__.py*, *sensor.py* or another module.
Import it into your module that determines the entities to be filtered. This may be in *\__init__.py*, *sensor.py* or another module.

- `import recorder_prefilter`

The a single entity or a list of entities can be added at one time using the *add_filter* function call.
A single entity or a list of entities can be added at one time using the *add_filter* function call.

- `recorder_prefilter.add_filter(hass, 'icloud3_event_log')`
- `recorder_prefilter.add_filter(hass, ['icloud3_event_log', 'icloud3_wazehist_track', 'gary_iphone_info'])`
- `recorder_prefilter.add_filter(hass, [filtered_entities_list)`

Notes:

- The entity_type (*input_boolean, light, etc* ) needs to be used if it is a non-sensor entity.
- The entity_type (*input_boolean, light, etc.* ) needs to be used if it is a non-sensor entity.
- The first custom component to use the *add_filter* function call will inject the *recorder_prefilter* into the HA Recorder component. All subsequent *add_filter* calls will update the filter list.

#### Removing Entities

Entities can be removed from the filter list using the *remove_filter* function call.

The a single entity or a list of entities can be removed at one time.
A single entity or a list of entities can be removed at one time.

- `recorder_prefilter.remove_filter(hass, 'icloud3_event_log')`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#
# The HA Recorder module was modified in HA 2023.6.0 to no longer allow a
# custom component to insert entity entity names in the '_exclude_e' list
# custom component to insert entity names in the '_exclude_e' list
# that defined entity entities to not be added to the History database
# (home_assistant_v2.db).
#
Expand Down Expand Up @@ -63,7 +63,7 @@ def add_filter(hass: HomeAssistant, entities=None):
hass - HomeAssistant
entities - A list of entity entities
(['gary_last_update', 'lillian_last_update', '*_next_update'])
- A single entity entity ('gary_last_zone')
- A single entity ('gary_last_zone')
Returns:
True - The injection was successful
Expand Down
2 changes: 1 addition & 1 deletion examples/keypad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ script:
entity_id: sensor.keypad
- service: variable.update_sensor
data:
value: 10
value: "10"
target:
entity_id: sensor.keypad_timer
- service: automation.turn_on
Expand Down
20 changes: 11 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Custom requirements

# Pre-commit requirements
codespell==2.1.0
flake8-comprehensions==3.8.0
flake8-docstrings==1.6.0
flake8-noqa==1.2.1
flake8==4.0.1
isort==5.10.1
codespell==2.2.6
flake8-comprehensions==3.14.0
flake8-docstrings==1.7.0
flake8-noqa==1.3.2
flake8==6.1.0
isort==6.0.0b2

# Unit tests requirements
pytest==7.1.2
pytest-cov==3.0.0
pytest-homeassistant-custom-component
pytest==7.4.2
pytest-cov==4.1.0
pytest-homeassistant-custom-component
homeassistant~=2023.4.6
voluptuous~=0.13.1

0 comments on commit bdee701

Please sign in to comment.