diff --git a/homeassistant/components/sensor/bitcoin.py b/homeassistant/components/sensor/bitcoin.py index ca921f4fca7..dc11f7038c2 100644 --- a/homeassistant/components/sensor/bitcoin.py +++ b/homeassistant/components/sensor/bitcoin.py @@ -17,24 +17,24 @@ REQUIREMENTS = ['blockchain==1.1.2'] _LOGGER = logging.getLogger(__name__) OPTION_TYPES = { 'wallet': ['Wallet balance', 'BTC'], - 'exchangerate': ['Exchange rate (1 BTC)', ''], + 'exchangerate': ['Exchange rate (1 BTC)', None], 'trade_volume_btc': ['Trade volume', 'BTC'], 'miners_revenue_usd': ['Miners revenue', 'USD'], 'btc_mined': ['Mined', 'BTC'], 'trade_volume_usd': ['Trade volume', 'USD'], - 'difficulty': ['Difficulty', ''], + 'difficulty': ['Difficulty', None], 'minutes_between_blocks': ['Time between Blocks', 'min'], - 'number_of_transactions': ['No. of Transactions', ''], + 'number_of_transactions': ['No. of Transactions', None], 'hash_rate': ['Hash rate', 'PH/s'], - 'timestamp': ['Timestamp', ''], - 'mined_blocks': ['Minded Blocks', ''], - 'blocks_size': ['Block size', ''], + 'timestamp': ['Timestamp', None], + 'mined_blocks': ['Minded Blocks', None], + 'blocks_size': ['Block size', None], 'total_fees_btc': ['Total fees', 'BTC'], 'total_btc_sent': ['Total sent', 'BTC'], 'estimated_btc_sent': ['Estimated sent', 'BTC'], 'total_btc': ['Total', 'BTC'], - 'total_blocks': ['Total Blocks', ''], - 'next_retarget': ['Next retarget', ''], + 'total_blocks': ['Total Blocks', None], + 'next_retarget': ['Next retarget', None], 'estimated_transaction_volume_usd': ['Est. Transaction volume', 'USD'], 'miners_revenue_btc': ['Miners revenue', 'BTC'], 'market_price_usd': ['Market price', 'USD'] diff --git a/homeassistant/components/sensor/dht.py b/homeassistant/components/sensor/dht.py index 0e39ef7382f..4f11ba7734f 100644 --- a/homeassistant/components/sensor/dht.py +++ b/homeassistant/components/sensor/dht.py @@ -20,7 +20,7 @@ REQUIREMENTS = ['http://github.com/mala-zaba/Adafruit_Python_DHT/archive/' _LOGGER = logging.getLogger(__name__) SENSOR_TYPES = { - 'temperature': ['Temperature', ''], + 'temperature': ['Temperature', None], 'humidity': ['Humidity', '%'] } # Return cached results if last scan was less then this time ago diff --git a/homeassistant/components/sensor/ecobee.py b/homeassistant/components/sensor/ecobee.py index 02a2575d88b..91892f63617 100644 --- a/homeassistant/components/sensor/ecobee.py +++ b/homeassistant/components/sensor/ecobee.py @@ -36,7 +36,7 @@ DEPENDENCIES = ['ecobee'] SENSOR_TYPES = { 'temperature': ['Temperature', TEMP_FAHRENHEIT], 'humidity': ['Humidity', '%'], - 'occupancy': ['Occupancy', ''] + 'occupancy': ['Occupancy', None] } _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensor/efergy.py b/homeassistant/components/sensor/efergy.py index 447903a714e..8eba0149408 100644 --- a/homeassistant/components/sensor/efergy.py +++ b/homeassistant/components/sensor/efergy.py @@ -16,8 +16,8 @@ _LOGGER = logging.getLogger(__name__) _RESOURCE = 'https://engage.efergy.com/mobile_proxy/' SENSOR_TYPES = { 'instant_readings': ['Energy Usage', 'kW'], - 'budget': ['Energy Budget', ''], - 'cost': ['Energy Cost', ''], + 'budget': ['Energy Budget', None], + 'cost': ['Energy Cost', None], } diff --git a/homeassistant/components/sensor/forecast.py b/homeassistant/components/sensor/forecast.py index 42fbe26b9cf..8cbc332678e 100644 --- a/homeassistant/components/sensor/forecast.py +++ b/homeassistant/components/sensor/forecast.py @@ -19,13 +19,13 @@ _LOGGER = logging.getLogger(__name__) # Sensor types are defined like so: # Name, si unit, us unit, ca unit, uk unit, uk2 unit SENSOR_TYPES = { - 'summary': ['Summary', '', '', '', '', ''], - 'icon': ['Icon', '', '', '', '', ''], + 'summary': ['Summary', None, None, None, None, None], + 'icon': ['Icon', None, None, None, None, None], 'nearest_storm_distance': ['Nearest Storm Distance', 'km', 'm', 'km', 'km', 'm'], 'nearest_storm_bearing': ['Nearest Storm Bearing', '°', '°', '°', '°', '°'], - 'precip_type': ['Precip', '', '', '', '', ''], + 'precip_type': ['Precip', None, None, None, None, None], 'precip_intensity': ['Precip Intensity', 'mm', 'in', 'mm', 'mm', 'mm'], 'precip_probability': ['Precip Probability', '%', '%', '%', '%', '%'], 'temperature': ['Temperature', '°C', '°F', '°C', '°C', '°C'], diff --git a/homeassistant/components/sensor/glances.py b/homeassistant/components/sensor/glances.py index c2bd96c8eea..eb38e3df265 100644 --- a/homeassistant/components/sensor/glances.py +++ b/homeassistant/components/sensor/glances.py @@ -31,11 +31,11 @@ SENSOR_TYPES = { 'swap_use_percent': ['Swap Use', '%'], 'swap_use': ['Swap Use', 'GiB'], 'swap_free': ['Swap Free', 'GiB'], - 'processor_load': ['CPU Load', ''], - 'process_running': ['Running', ''], - 'process_total': ['Total', ''], - 'process_thread': ['Thread', ''], - 'process_sleeping': ['Sleeping', ''] + 'processor_load': ['CPU Load', None], + 'process_running': ['Running', None], + 'process_total': ['Total', None], + 'process_thread': ['Thread', None], + 'process_sleeping': ['Sleeping', None] } _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensor/openweathermap.py b/homeassistant/components/sensor/openweathermap.py index 84784a19546..a5509904264 100644 --- a/homeassistant/components/sensor/openweathermap.py +++ b/homeassistant/components/sensor/openweathermap.py @@ -16,8 +16,8 @@ from homeassistant.helpers.entity import Entity REQUIREMENTS = ['pyowm==2.3.0'] _LOGGER = logging.getLogger(__name__) SENSOR_TYPES = { - 'weather': ['Condition', ''], - 'temperature': ['Temperature', ''], + 'weather': ['Condition', None], + 'temperature': ['Temperature', None], 'wind_speed': ['Wind speed', 'm/s'], 'humidity': ['Humidity', '%'], 'pressure': ['Pressure', 'mbar'], @@ -71,7 +71,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): pass if forecast == 1: - SENSOR_TYPES['forecast'] = ['Forecast', ''] + SENSOR_TYPES['forecast'] = ['Forecast', None] dev.append(OpenWeatherMapSensor(data, 'forecast', unit)) add_devices(dev) diff --git a/homeassistant/components/sensor/sabnzbd.py b/homeassistant/components/sensor/sabnzbd.py index 98d76a302dd..6b42453b5d3 100644 --- a/homeassistant/components/sensor/sabnzbd.py +++ b/homeassistant/components/sensor/sabnzbd.py @@ -17,7 +17,7 @@ REQUIREMENTS = ['https://github.com/jamespcole/home-assistant-nzb-clients/' '#python-sabnzbd==0.1'] SENSOR_TYPES = { - 'current_status': ['Status', ''], + 'current_status': ['Status', None], 'speed': ['Speed', 'MB/s'], 'queue_size': ['Queue', 'MB'], 'queue_remaining': ['Left', 'MB'], diff --git a/homeassistant/components/sensor/transmission.py b/homeassistant/components/sensor/transmission.py index 62afdd39bf4..26062cbba4d 100644 --- a/homeassistant/components/sensor/transmission.py +++ b/homeassistant/components/sensor/transmission.py @@ -15,7 +15,7 @@ from homeassistant.helpers.entity import Entity REQUIREMENTS = ['transmissionrpc==0.11'] SENSOR_TYPES = { - 'current_status': ['Status', ''], + 'current_status': ['Status', None], 'download_speed': ['Down Speed', 'MB/s'], 'upload_speed': ['Up Speed', 'MB/s'] } diff --git a/homeassistant/components/sensor/verisure.py b/homeassistant/components/sensor/verisure.py index e7c6a30b558..dec678677b4 100644 --- a/homeassistant/components/sensor/verisure.py +++ b/homeassistant/components/sensor/verisure.py @@ -67,7 +67,7 @@ class VerisureThermometer(Entity): return TEMP_CELCIUS # can verisure report in fahrenheit? def update(self): - ''' update sensor ''' + """ update sensor """ verisure.update_climate() @@ -96,5 +96,5 @@ class VerisureHygrometer(Entity): return "%" def update(self): - ''' update sensor ''' + """ update sensor """ verisure.update_climate() diff --git a/homeassistant/components/sensor/yr.py b/homeassistant/components/sensor/yr.py index 24f565feb48..08abffb758d 100644 --- a/homeassistant/components/sensor/yr.py +++ b/homeassistant/components/sensor/yr.py @@ -21,7 +21,7 @@ REQUIREMENTS = ['xmltodict'] # Sensor types are defined like so: SENSOR_TYPES = { - 'symbol': ['Symbol', ''], + 'symbol': ['Symbol', None], 'precipitation': ['Condition', 'mm'], 'temperature': ['Temperature', '°C'], 'windSpeed': ['Wind speed', 'm/s'], diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index fd2611889c9..980504d1829 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -101,17 +101,18 @@ class Entity(object): state = str(self.state) attr = self.state_attributes or {} - if ATTR_FRIENDLY_NAME not in attr and self.name: - attr[ATTR_FRIENDLY_NAME] = self.name + if ATTR_FRIENDLY_NAME not in attr and self.name is not None: + attr[ATTR_FRIENDLY_NAME] = str(self.name) - if ATTR_UNIT_OF_MEASUREMENT not in attr and self.unit_of_measurement: - attr[ATTR_UNIT_OF_MEASUREMENT] = self.unit_of_measurement + if ATTR_UNIT_OF_MEASUREMENT not in attr and \ + self.unit_of_measurement is not None: + attr[ATTR_UNIT_OF_MEASUREMENT] = str(self.unit_of_measurement) - if ATTR_ICON not in attr and self.icon: - attr[ATTR_ICON] = self.icon + if ATTR_ICON not in attr and self.icon is not None: + attr[ATTR_ICON] = str(self.icon) if self.hidden: - attr[ATTR_HIDDEN] = self.hidden + attr[ATTR_HIDDEN] = bool(self.hidden) # overwrite properties that have been set in the config file attr.update(_OVERWRITE.get(self.entity_id, {}))