add relative time option to simulated sensors (#14038)

By default simulated sensors are relative to when they're activated,
instead we make this togglable with this new option 'relative_to_epoch',
and instead they become relative to 1970-01-01 00:00:00.
This commit is contained in:
Benedict Aas authored and Paulus Schoutsen committed 2018-06-14 14:06:49 -04:00
1 parent b2440a6d95
commit c8e0de19b6
2 files changed
+20 -5

No files matched your search

+4 -2
View File
@@ -5,8 +5,8 @@ from tests.common import get_test_home_assistant
from homeassistant.components.sensor.simulated import (
CONF_AMP, CONF_FWHM, CONF_MEAN, CONF_PERIOD, CONF_PHASE, CONF_SEED,
CONF_UNIT, DEFAULT_AMP, DEFAULT_FWHM, DEFAULT_MEAN, DEFAULT_NAME,
DEFAULT_PHASE, DEFAULT_SEED)
CONF_UNIT, CONF_RELATIVE_TO_EPOCH, DEFAULT_AMP, DEFAULT_FWHM, DEFAULT_MEAN,
DEFAULT_NAME, DEFAULT_PHASE, DEFAULT_SEED, DEFAULT_RELATIVE_TO_EPOCH)
from homeassistant.const import CONF_FRIENDLY_NAME
from homeassistant.setup import setup_component
@@ -42,3 +42,5 @@ class TestSimulatedSensor(unittest.TestCase):
assert state.attributes.get(CONF_PHASE) == DEFAULT_PHASE
assert state.attributes.get(CONF_FWHM) == DEFAULT_FWHM
assert state.attributes.get(CONF_SEED) == DEFAULT_SEED
assert state.attributes.get(
CONF_RELATIVE_TO_EPOCH) == DEFAULT_RELATIVE_TO_EPOCH