Add energy support for zwave_js meter CC entities (#53665)

* Add energy support for zwave_js meter CC entities

* shrink

* comments

* comments

* comments

* Move attributes

* Add tests

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Raman Gupta 2021-07-29 08:18:38 -04:00 committed by GitHub
parent 1019ee22ff
commit 30cbf03b48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 146 additions and 19 deletions

View file

@ -11,6 +11,11 @@ from zwave_js_server.model.driver import Driver
from zwave_js_server.model.node import Node
from zwave_js_server.version import VersionInfo
from homeassistant.components.sensor import ATTR_LAST_RESET
from homeassistant.core import State
from .common import DATETIME_LAST_RESET
from tests.common import MockConfigEntry, load_fixture
# Add-on fixtures
@ -835,3 +840,16 @@ def aeotec_zw164_siren_fixture(client, aeotec_zw164_siren_state):
def firmware_file_fixture():
"""Return mock firmware file stream."""
return io.BytesIO(bytes(10))
@pytest.fixture(name="restore_last_reset")
def restore_last_reset_fixture():
"""Return mock restore last reset."""
state = State(
"sensor.test", "test", {ATTR_LAST_RESET: DATETIME_LAST_RESET.isoformat()}
)
with patch(
"homeassistant.components.zwave_js.sensor.ZWaveMeterSensor.async_get_last_state",
return_value=state,
):
yield state