Пример #1
0
    def __init__(self, hass, device):
        """Initialize the device."""

        # add fan unique stuff here if needed
        SonoffDevice.__init__(self, hass, device)
        self._name = device['name']
        self._speed = SPEED_OFF
Пример #2
0
    def __init__(self, hass, device, outlet=None):
        """Initialize the device."""

        # add switch unique stuff here if needed
        SonoffDevice.__init__(self, hass, device)
        self._outlet = outlet
        self._name = '{}{}'.format(
            device['name'], '' if outlet is None else ' ' + str(outlet + 1))

        if outlet is None:
            self._name = device['name']

        else:
            self._attributes['outlet'] = outlet

            if 'tags' in device and 'ck_channel_name' in device['tags']:
                if str(outlet) in device['tags']['ck_channel_name'].keys() and \
                    device['tags']['ck_channel_name'][str(outlet)]:
                    self._name = '{} - {}'.format(
                        device['name'],
                        device['tags']['ck_channel_name'][str(outlet)])

                    self._attributes['outlet_name'] = device['tags'][
                        'ck_channel_name'][str(outlet)]
                else:
                    self._name = '{} {}'.format(device['name'],
                                                ('CH %s' % str(outlet + 1)))
            else:
                self._name = '{} {}'.format(device['name'],
                                            ('CH %s' % str(outlet + 1)))
Пример #3
0
 def __init__(self, hass, device, sensor=None):
     """Initialize the device."""
     SonoffDevice.__init__(self, hass, device)
     self._sensor = sensor
     self._name = '{} {}'.format(device['name'],
                                 SONOFF_SENSORS_MAP[self._sensor]['eid'])
     self._attributes = {}
Пример #4
0
    def __init__(self, hass, device, outlet=None):
        """Initialize the device."""

        # add switch unique stuff here if needed
        SonoffDevice.__init__(self, hass, device)
        self._outlet = outlet
        self._name = '{}{}'.format(
            device['name'], '' if outlet is None else ' ' + str(outlet + 1))
Пример #5
0
 def __init__(self, hass, device, rf = None):
     """Initialize the device."""
     SonoffDevice.__init__(self, hass, device)
     self._rf            = rf
     self._name          = self._rf['name']
     self._state         = None
     self._attributes    = {
         'rfid'  : self._rf['rfVal'],
         'type'  : 'remote_button' if self._rf['type'] == "4" else "alarm"
     }
Пример #6
0
    def __init__(self, hass, device):
        """Initialize the device."""

        # add light unique stuff here if needed
        SonoffDevice.__init__(self, hass, device)

        self._name = device['name']
        self._state = self.get_state()

        self._ch01 = [
            int(device['params']['channel0']),
            int(device['params']['channel1'])
        ]
        self._ch234 = [
            int(device['params']['channel2']),
            int(device['params']['channel3']),
            int(device['params']['channel4'])
        ]

        # calculate the mode
        if int(device['params']['channel0']) > 0 or int(
                device['params']['channel1']) > 0:
            self._mode = EFFECT_WARMCOOL
            self._hs_color = [0, 0]
        else:
            self._mode = EFFECT_COLOR
            self._hs_color = color.color_RGB_to_hs(*self._ch234)

        # @TODO calculate below values
        if int(device['params']['channel0']) > 245 and int(
                device['params']['channel1']) < 10:
            self._color_temp = 155
        elif int(device['params']['channel0']) > 245 and int(
                device['params']['channel1']) > 245:
            self._color_temp = 325
        elif int(device['params']['channel0']) < 10 and int(
                device['params']['channel1']) > 245:
            self._color_temp = 500
        else:
            self._color_temp = 325  # fallback

        # full brightness all the time till i figure a way to calculate it
        self._brightness = 255
Пример #7
0
    def __init__(self, hass, device, outlet=None):
        """Initialize the device."""

        # add switch unique stuff here if needed
        SonoffDevice.__init__(self, hass, device, outlet)