-
-
Notifications
You must be signed in to change notification settings - Fork 101
Fix missing state class for reactive power sensors after #1417 #1451
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
832fb89
fix state_class
N3rdix 414667e
add test for reactive sensor
N3rdix c601b56
Revert test_init.py
N3rdix fe4b198
Add HA unit
N3rdix f51d17f
Add OCPP to HA unit mapping
N3rdix c11aa91
add assert vor reactive unit
N3rdix 635f09a
add separate sensor test
N3rdix 3a5a193
Merge branch 'main' into fix-state-class-reactive-power
drc38 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,35 @@ | ||
"""Test sensor for ocpp integration.""" | ||
|
||
from pytest_homeassistant_custom_component.common import MockConfigEntry | ||
|
||
from custom_components.ocpp.const import DOMAIN as OCPP_DOMAIN | ||
|
||
from homeassistant.const import ATTR_DEVICE_CLASS | ||
from homeassistant.components.sensor.const import ( | ||
SensorDeviceClass, | ||
SensorStateClass, | ||
ATTR_STATE_CLASS, | ||
) | ||
from .const import MOCK_CONFIG_DATA | ||
|
||
|
||
async def test_sensor(hass, socket_enabled): | ||
"""Test sensor.""" | ||
config_entry = MockConfigEntry( | ||
domain=OCPP_DOMAIN, | ||
data=MOCK_CONFIG_DATA, | ||
entry_id="test_cms", | ||
title="test_cms", | ||
) | ||
config_entry.add_to_hass(hass) | ||
assert await hass.config_entries.async_setup(config_entry.entry_id) | ||
await hass.async_block_till_done() | ||
|
||
# Test reactive power sensor | ||
state = hass.states.get("sensor.test_cpid_power_reactive_import") | ||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.REACTIVE_POWER | ||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT | ||
# Test reactive energx sensor, not having own device class yet | ||
state = hass.states.get("sensor.test_cpid_energy_reactive_import_register") | ||
assert state.attributes.get(ATTR_DEVICE_CLASS) is None | ||
assert state.attributes.get(ATTR_STATE_CLASS) is None |
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.
Uh oh!
There was an error while loading. Please reload this page.