Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 8 additions & 13 deletions homeassistant/components/light/futurenow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
PLATFORM_SCHEMA)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['pyfnip==0.1']
REQUIREMENTS = ['pyfnip==0.2']

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -75,8 +75,8 @@ def __init__(self, device):
self._dimmable = device['dimmable']
self._channel = device['channel']
self._brightness = None
self._last_brightness = 255
self._state = None
self._skip_update = False

if device['driver'] == CONF_DRIVER_FNIP6X10AD:
self._light = pyfnip.FNIP6x2adOutput(device['host'],
Expand Down Expand Up @@ -111,25 +111,20 @@ def supported_features(self):

def turn_on(self, **kwargs):
"""Turn the light on."""
level = kwargs.get(ATTR_BRIGHTNESS, 255) if self._dimmable else 255
if self._dimmable:
level = kwargs.get(ATTR_BRIGHTNESS, self._last_brightness)
else:
level = 255
self._light.turn_on(to_futurenow_level(level))
self._brightness = level
self._state = True
self._skip_update = True

def turn_off(self, **kwargs):
"""Turn the light off."""
self._light.turn_off()
self._brightness = 0
self._state = False
self._skip_update = True
if self._brightness:
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.

What if brightness is 0? Shouldn't it be stored as last_brightness then?

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.

Brightness 0 is effectively Off state in the dimmer.. Whereas technically it's possible to have state On and brightness 0 this usually happens by some error and the previously set other-than-0 value should be used.

self._last_brightness = self._brightness

def update(self):
"""Fetch new state data for this light."""
if self._skip_update:
self._skip_update = False
return

state = int(self._light.is_on())
self._state = bool(state)
self._brightness = to_hass_level(state)
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ pyflexit==0.3
pyflic-homeassistant==0.4.dev0

# homeassistant.components.light.futurenow
pyfnip==0.1
pyfnip==0.2

# homeassistant.components.fritzbox
pyfritzhome==0.3.7
Expand Down