Update syntax of platform random (#14767)
This commit is contained in:
parent
e7985c970b
commit
ad86e68c1e
2 changed files with 6 additions and 10 deletions
|
@ -4,7 +4,6 @@ Support for showing random states.
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/binary_sensor.random/
|
https://home-assistant.io/components/binary_sensor.random/
|
||||||
"""
|
"""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -24,8 +23,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def async_setup_platform(
|
||||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
hass, config, async_add_devices, discovery_info=None):
|
||||||
"""Set up the Random binary sensor."""
|
"""Set up the Random binary sensor."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
device_class = config.get(CONF_DEVICE_CLASS)
|
device_class = config.get(CONF_DEVICE_CLASS)
|
||||||
|
@ -57,8 +56,7 @@ class RandomSensor(BinarySensorDevice):
|
||||||
"""Return the sensor class of the sensor."""
|
"""Return the sensor class of the sensor."""
|
||||||
return self._device_class
|
return self._device_class
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def async_update(self):
|
||||||
def async_update(self):
|
|
||||||
"""Get new state and update the sensor's state."""
|
"""Get new state and update the sensor's state."""
|
||||||
from random import getrandbits
|
from random import getrandbits
|
||||||
self._state = bool(getrandbits(1))
|
self._state = bool(getrandbits(1))
|
||||||
|
|
|
@ -4,7 +4,6 @@ Support for showing random numbers.
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/sensor.random/
|
https://home-assistant.io/components/sensor.random/
|
||||||
"""
|
"""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -34,8 +33,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def async_setup_platform(
|
||||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
hass, config, async_add_devices, discovery_info=None):
|
||||||
"""Set up the Random number sensor."""
|
"""Set up the Random number sensor."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
minimum = config.get(CONF_MINIMUM)
|
minimum = config.get(CONF_MINIMUM)
|
||||||
|
@ -84,8 +83,7 @@ class RandomSensor(Entity):
|
||||||
ATTR_MINIMUM: self._minimum,
|
ATTR_MINIMUM: self._minimum,
|
||||||
}
|
}
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def async_update(self):
|
||||||
def async_update(self):
|
|
||||||
"""Get a new number and updates the states."""
|
"""Get a new number and updates the states."""
|
||||||
from random import randrange
|
from random import randrange
|
||||||
self._state = randrange(self._minimum, self._maximum + 1)
|
self._state = randrange(self._minimum, self._maximum + 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue