예제 #1
0
    def test_find_percentage_in_range_altered_inverted(self):
        """Test find percentage in range with altered range and inverted."""
        mqtt_cover = MqttCover(
            name='cover.test',
            state_topic='state-topic',
            get_position_topic=None,
            command_topic='command-topic',
            availability_topic=None,
            tilt_command_topic='tilt-command-topic',
            tilt_status_topic='tilt-status-topic',
            qos=0,
            retain=False,
            state_open='OPEN', state_closed='CLOSE',
            position_open=80, position_closed=180,
            payload_open='OPEN', payload_close='CLOSE', payload_stop='STOP',
            payload_available=None, payload_not_available=None,
            optimistic=False, value_template=None,
            tilt_open_position=180, tilt_closed_position=80,
            tilt_min=80, tilt_max=180, tilt_optimistic=False,
            tilt_invert=True,
            set_position_topic=None, set_position_template=None,
            unique_id=None, device_config=None, discovery_hash=None)

        assert 60 == mqtt_cover.find_percentage_in_range(120)
        assert 60 == mqtt_cover.find_percentage_in_range(120, 'cover')
예제 #2
0
    def test_find_percentage_in_range_altered_inverted(self):
        """Test find percentage in range with altered range and inverted."""
        mqtt_cover = MqttCover(
            {
                'name': 'cover.test',
                'state_topic': 'state-topic',
                'get_position_topic': None,
                'command_topic': 'command-topic',
                'availability_topic': None,
                'tilt_command_topic': 'tilt-command-topic',
                'tilt_status_topic': 'tilt-status-topic',
                'qos': 0,
                'retain': False,
                'state_open': 'OPEN', 'state_closed': 'CLOSE',
                'position_open': 80,  'position_closed': 180,
                'payload_open': 'OPEN', 'payload_close': 'CLOSE',
                'payload_stop': 'STOP',
                'payload_available': None, 'payload_not_available': None,
                'optimistic': False, 'value_template': None,
                'tilt_open_position': 180, 'tilt_closed_position': 80,
                'tilt_min': 80, 'tilt_max': 180, 'tilt_optimistic': False,
                'tilt_invert_state': True,
                'set_position_topic': None, 'set_position_template': None,
                'unique_id': None, 'device_config': None,
            },
            None)

        assert 60 == mqtt_cover.find_percentage_in_range(120)
        assert 60 == mqtt_cover.find_percentage_in_range(120, 'cover')
예제 #3
0
    def test_find_percentage_in_range_altered_inverted(self):
        """Test find percentage in range with altered range and inverted."""
        mqtt_cover = MqttCover('cover.test', 'foo', 'bar', 'fooBar',
                               "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN',
                               'CLOSE', 'STOP', False, None, 180, 80, 80, 180,
                               False, True)

        self.assertEqual(60, mqtt_cover.find_percentage_in_range(120))
예제 #4
0
    def test_find_percentage_in_range_defaults_inverted(self):
        """Test find percentage in range with default range but inverted."""
        mqtt_cover = MqttCover('cover.test', 'foo', 'bar', 'fooBar',
                               "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN',
                               'CLOSE', 'STOP', False, None, 100, 0, 0, 100,
                               False, True)

        self.assertEqual(56, mqtt_cover.find_percentage_in_range(44))
예제 #5
0
    def test_find_percentage_in_range_altered_inverted(self):
        """Test find percentage in range with altered range and inverted."""
        mqtt_cover = MqttCover(
            'cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False,
            'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None,
            180, 80, 80, 180, False, True)

        self.assertEqual(60, mqtt_cover.find_percentage_in_range(120))
예제 #6
0
    def test_find_percentage_in_range_defaults_inverted(self):
        """Test find percentage in range with default range but inverted."""
        mqtt_cover = MqttCover(
            'cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False,
            'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None,
            100, 0, 0, 100, False, True)

        self.assertEqual(56, mqtt_cover.find_percentage_in_range(44))
예제 #7
0
    def test_find_percentage_in_range_altered_inverted(self):
        """Test find percentage in range with altered range and inverted."""
        mqtt_cover = MqttCover(
            'cover.test', 'state-topic', 'command-topic', None,
            'tilt-command-topic', 'tilt-status-topic', 0, False,
            'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', None, None,
            False, None, 180, 80, 80, 180, False, True, None, None)

        self.assertEqual(60, mqtt_cover.find_percentage_in_range(120))
예제 #8
0
    def test_find_percentage_in_range_defaults_inverted(self):
        """Test find percentage in range with default range but inverted."""
        mqtt_cover = MqttCover(
            'cover.test', 'state-topic', 'command-topic', None,
            'tilt-command-topic', 'tilt-status-topic', 0, False,
            'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', None, None,
            False, None, 100, 0, 0, 100, False, True, None, None)

        self.assertEqual(56, mqtt_cover.find_percentage_in_range(44))
예제 #9
0
    def test_find_percentage_in_range_altered_inverted(self):
        """Test find percentage in range with altered range and inverted."""
        mqtt_cover = MqttCover('cover.test', 'state-topic', 'command-topic',
                               None, 'tilt-command-topic', 'tilt-status-topic',
                               0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE',
                               'STOP', None, None, False, None, 180, 80, 80,
                               180, False, True, None, None, None, None, None)

        self.assertEqual(60, mqtt_cover.find_percentage_in_range(120))
예제 #10
0
    def test_find_percentage_in_range_defaults_inverted(self):
        """Test find percentage in range with default range but inverted."""
        mqtt_cover = MqttCover('cover.test', 'state-topic', 'command-topic',
                               None, 'tilt-command-topic', 'tilt-status-topic',
                               0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE',
                               'STOP', None, None, False, None, 100, 0, 0, 100,
                               False, True, None, None, None, None, None)

        self.assertEqual(56, mqtt_cover.find_percentage_in_range(44))
예제 #11
0
    def test_find_percentage_in_range_altered_inverted(self):
        """Test find percentage in range with altered range and inverted."""
        mqtt_cover = MqttCover(name='cover.test',
                               state_topic='state-topic',
                               get_position_topic=None,
                               command_topic='command-topic',
                               availability_topic=None,
                               tilt_command_topic='tilt-command-topic',
                               tilt_status_topic='tilt-status-topic',
                               qos=0,
                               retain=False,
                               state_open='OPEN',
                               state_closed='CLOSE',
                               position_open=80,
                               position_closed=180,
                               payload_open='OPEN',
                               payload_close='CLOSE',
                               payload_stop='STOP',
                               payload_available=None,
                               payload_not_available=None,
                               optimistic=False,
                               value_template=None,
                               tilt_open_position=180,
                               tilt_closed_position=80,
                               tilt_min=80,
                               tilt_max=180,
                               tilt_optimistic=False,
                               tilt_invert=True,
                               set_position_topic=None,
                               set_position_template=None,
                               unique_id=None,
                               device_config=None,
                               discovery_hash=None)

        assert 60 == mqtt_cover.find_percentage_in_range(120)
        assert 60 == mqtt_cover.find_percentage_in_range(120, 'cover')