Ejemplo n.º 1
0
    def p(self, ccu):
        device = Device(
            ccu,
            {
                'address': 'KEQ0970393',
                #'children': ['KEQ0970393:0',
                #             'KEQ0970393:1',
                #             'KEQ0970393:2',
                #             'KEQ0970393:3',
                #             'KEQ0970393:4',
                #             'KEQ0970393:5',
                #             'KEQ0970393:6',
                'firmware': '1.4',
                'flags': 1,
                'interface': 'KEQ0714972',
                #'paramsets': ['MASTER'],
                'roaming': False,
                'type': 'HM-ES-PMSw1-Pl',
                'updatable': '1',
                'version': 1,
                'channels': [],
            })

        channel = Channel(
            device, {
                'address':
                'KEQ0970393:1',
                'direction':
                1,
                'flags':
                1,
                'index':
                1,
                'link_source_roles':
                ['KEYMATIC', 'SWITCH', 'WINDOW_SWITCH_RECEIVER', 'WINMATIC'],
                'link_target_roles': [],
                'paramsets': ['LINK', 'MASTER', 'VALUES'],
                'type':
                'SHUTTER_CONTACT',
                'version':
                15,
            })
        return Parameter(
            channel, {
                'control': 'SWITCH.STATE',
                'operations': 7,
                'name': 'STATE',
                'min': '0',
                'default': '0',
                'max': '1',
                '_value': True,
                'tab_order': 0,
                'flags': 1,
                'unit': '',
                'type': 'BOOL',
                'id': 'STATE',
                'channel': channel,
            })
Ejemplo n.º 2
0
    def test_channel_unknown_type(self, capfd, ccu):
        # Set loglevel so that we get the debug message
        pmatic.logging(pmatic.DEBUG)

        device = Device(ccu, {
            'address': 'KEQ0970393',
            'firmware': '1.4',
            'flags': 1,
            'interface': 'KEQ0714972',
            'roaming': False,
            'type': 'HM-ES-PMSw1-Pl',
            'updatable': '1',
            'version': 1,
            'channels': [],
        })

        Channel.from_channel_dicts(device, [
            {
                'address': 'KEQ0970393:1',
                'direction': 1,
                'flags': 1,
                'index': 1,
                'link_source_roles': [
                    'KEYMATIC',
                    'SWITCH',
                    'WINDOW_SWITCH_RECEIVER',
                    'WINMATIC'
                ],
                'link_target_roles': [],
                'paramsets': ['LINK', 'MASTER', 'VALUES'],
                'type': 'XXX_SHUTTER_CONTACT',
                'version': 15,
            }
        ])

        out, err = capfd.readouterr()
        assert "Using generic" in err
        assert "XXX_SHUTTER_CONTACT" in err
        assert out == ""

        # revert to default log level
        pmatic.logging()
Ejemplo n.º 3
0
    def test_from_channel_dicts(self, ccu):
        device = Device(ccu, {
            'address': 'KEQ0970393',
            'firmware': '1.4',
            'flags': 1,
            'interface': 'KEQ0714972',
            'roaming': False,
            'type': 'HM-ES-PMSw1-Pl',
            'updatable': '1',
            'version': 1,
            'channels': [],
        })

        channels = Channel.from_channel_dicts(device, [
            {
                'address': 'KEQ0970393:1',
                'direction': 1,
                'flags': 1,
                'index': 1,
                'link_source_roles': [
                    'KEYMATIC',
                    'SWITCH',
                    'WINDOW_SWITCH_RECEIVER',
                    'WINMATIC'
                ],
                'link_target_roles': [],
                'paramsets': ['LINK', 'MASTER', 'VALUES'],
                'type': 'SHUTTER_CONTACT',
                'version': 15,
            },
            {
                'address': 'KEQ0970393:2',
                'direction': 1,
                'flags': 1,
                'index': 2,
                'link_source_roles': [
                    'KEYMATIC',
                    'SWITCH',
                    'WINDOW_SWITCH_RECEIVER',
                    'WINMATIC'
                ],
                'link_target_roles': [],
                'paramsets': ['LINK', 'MASTER', 'VALUES'],
                'type': 'SHUTTER_CONTACT',
                'version': 15,
            }
        ])

        assert len(channels) == 2
        assert 0 not in channels
        assert isinstance(channels[1], ChannelShutterContact)
        assert isinstance(channels[2], ChannelShutterContact)
Ejemplo n.º 4
0
 def test_init_with_invalid_device(self):
     with pytest.raises(PMException) as e:
         Channel(None, {})
     assert "not a Device derived" in str(e)