Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/sensor/dsmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.string,
vol.Optional(CONF_HOST, default=None): cv.string,
vol.Optional(CONF_DSMR_VERSION, default=DEFAULT_DSMR_VERSION): vol.All(
cv.string, vol.In(['4', '2.2'])),
cv.string, vol.In(['5', '4', '2.2'])),
vol.Optional(CONF_RECONNECT_INTERVAL, default=30): int,
})

Expand Down Expand Up @@ -93,7 +93,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
devices = [DSMREntity(name, obis) for name, obis in obis_mapping]

# Protocol version specific obis
if dsmr_version == '4':
if dsmr_version in ['4', '5']:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a set instead a list, that is faster

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lists this size there is no significant difference as far as I can measure.

import timeit
>>> timeit.timeit(stmt='"4" in a', setup='a = ("4","5")', number=100000)
0.0047658109997428255
>>> timeit.timeit(stmt='"4" in a', setup='a = ["4","5"]', number=100000)
0.004662344001189922
>>> timeit.timeit(stmt='"2.2" in a', setup='a = ("4","5")', number=100000)
0.0070196070009842515
>>> timeit.timeit(stmt='"2.2" in a', setup='a = ["4","5"]', number=100000)
0.00696941199930734

gas_obis = obis_ref.HOURLY_GAS_METER_READING
else:
gas_obis = obis_ref.GAS_METER_READING
Expand Down