Пример #1
0
    def test_find_in_range_altered_inverted(self):
        """Test find 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 120 == mqtt_cover.find_in_range_from_percent(60)
        assert 120 == mqtt_cover.find_in_range_from_percent(60, 'cover')
Пример #2
0
    def test_find_in_range_altered_inverted(self):
        """Test find 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 120 == mqtt_cover.find_in_range_from_percent(60)
        assert 120 == mqtt_cover.find_in_range_from_percent(60, 'cover')
Пример #3
0
    def test_find_in_range_altered_inverted(self):
        """Test find 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(120, mqtt_cover.find_in_range_from_percent(60))
Пример #4
0
    def test_find_in_range_defaults_inverted(self):
        """Test find 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(44, mqtt_cover.find_in_range_from_percent(56))
Пример #5
0
    def test_find_in_range_altered_inverted(self):
        """Test find 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(120, mqtt_cover.find_in_range_from_percent(60))
Пример #6
0
    def test_find_in_range_defaults_inverted(self):
        """Test find 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(44, mqtt_cover.find_in_range_from_percent(56))
Пример #7
0
    def test_find_in_range_altered_inverted(self):
        """Test find 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(120, mqtt_cover.find_in_range_from_percent(60))
Пример #8
0
    def test_find_in_range_defaults_inverted(self):
        """Test find 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(44, mqtt_cover.find_in_range_from_percent(56))
Пример #9
0
    def test_find_in_range_altered_inverted(self):
        """Test find 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(120, mqtt_cover.find_in_range_from_percent(60))
Пример #10
0
    def test_find_in_range_defaults_inverted(self):
        """Test find 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(44, mqtt_cover.find_in_range_from_percent(56))
Пример #11
0
    def test_find_in_range_altered_inverted(self):
        """Test find 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 120 == mqtt_cover.find_in_range_from_percent(60)
        assert 120 == mqtt_cover.find_in_range_from_percent(60, 'cover')