Added password mode to input_text (obscure content of text box) (#11849)

* Round values to one decimal

Temperature detection range: -20 - 60 Deg.C ( + / - 0.3 Deg.C )
Humidity detection range: 0 - 100pct RH ( + / - 0.3pct )
Atmospheric pressure detection range: 30 - 110KPa ( + / - 120Pa )

* Add password mode option

Hide the content of the input_text field

* Revert "Round values to one decimal"

This reverts commit a3124a6aaa2261eff558e2bd37a3eda57d1aac71.

* Added test for mode option

* Added newline (lint)
This commit is contained in:
Eu 2018-02-08 12:29:33 +01:00 committed by Pascal Vizeli
parent 25cbc8317f
commit 905bb36e6a
2 changed files with 47 additions and 3 deletions

View file

@ -64,6 +64,41 @@ class TestInputText(unittest.TestCase):
state = self.hass.states.get(entity_id)
self.assertEqual('testing', str(state.state))
def test_mode(self):
"""Test mode settings."""
self.assertTrue(
setup_component(self.hass, DOMAIN, {DOMAIN: {
'test_default_text': {
'initial': 'test',
'min': 3,
'max': 10,
},
'test_explicit_text': {
'initial': 'test',
'min': 3,
'max': 10,
'mode': 'text',
},
'test_explicit_password': {
'initial': 'test',
'min': 3,
'max': 10,
'mode': 'password',
},
}}))
state = self.hass.states.get('input_text.test_default_text')
assert state
self.assertEqual('text', state.attributes['mode'])
state = self.hass.states.get('input_text.test_explicit_text')
assert state
self.assertEqual('text', state.attributes['mode'])
state = self.hass.states.get('input_text.test_explicit_password')
assert state
self.assertEqual('password', state.attributes['mode'])
@asyncio.coroutine
def test_restore_state(hass):