Exemplo n.º 1
0
    def test_connect(self, monkeypatch):
        monkeypatch.setattr(pmatic.residents, "SimpleTR64Lan", None)
        with pytest.raises(PMException) as e:
            PersonalDeviceFritzBoxHost._connect()
        assert "simpletr64.actions.lan.Lan" in str(e)
        monkeypatch.undo()

        PersonalDeviceFritzBoxHost.connection = "X"
        PersonalDeviceFritzBoxHost._connect()
        assert PersonalDeviceFritzBoxHost.connection == "X"
        PersonalDeviceFritzBoxHost.connection = None

        PersonalDeviceFritzBoxHost._connect()
        assert isinstance(PersonalDeviceFritzBoxHost.connection, Lan)
Exemplo n.º 2
0
    def test_connect(self, monkeypatch):
        monkeypatch.setattr(pmatic.residents, "SimpleTR64Lan", None)
        with pytest.raises(PMException) as e:
            PersonalDeviceFritzBoxHost._connect()
        assert "simpletr64.actions.lan.Lan" in str(e)
        monkeypatch.undo()

        PersonalDeviceFritzBoxHost.connection = "X"
        PersonalDeviceFritzBoxHost._connect()
        assert PersonalDeviceFritzBoxHost.connection == "X"
        PersonalDeviceFritzBoxHost.connection = None

        PersonalDeviceFritzBoxHost._connect()
        assert isinstance(PersonalDeviceFritzBoxHost.connection, Lan)
Exemplo n.º 3
0
    def test_configure(self):
        assert PersonalDeviceFritzBoxHost._address  == "fritz.box"
        assert PersonalDeviceFritzBoxHost._protocol == "http"
        assert PersonalDeviceFritzBoxHost._port     == 49000
        assert PersonalDeviceFritzBoxHost._user     == ""
        assert PersonalDeviceFritzBoxHost._password == ""

        PersonalDeviceFritzBoxHost.configure("asd123")
        assert PersonalDeviceFritzBoxHost._address  == "asd123"
        assert PersonalDeviceFritzBoxHost._protocol == "http"

        PersonalDeviceFritzBoxHost.configure(protocol="https")
        assert PersonalDeviceFritzBoxHost._address  == "asd123"
        assert PersonalDeviceFritzBoxHost._protocol == "https"

        PersonalDeviceFritzBoxHost.configure("host", "proto", "port", "user", "pw")
        assert PersonalDeviceFritzBoxHost._address  == "host"
        assert PersonalDeviceFritzBoxHost._protocol == "proto"
        assert PersonalDeviceFritzBoxHost._port     == "port"
        assert PersonalDeviceFritzBoxHost._user     == "user"
        assert PersonalDeviceFritzBoxHost._password == "pw"
Exemplo n.º 4
0
    def test_configure(self):
        assert PersonalDeviceFritzBoxHost._address == "fritz.box"
        assert PersonalDeviceFritzBoxHost._protocol == "http"
        assert PersonalDeviceFritzBoxHost._port == 49000
        assert PersonalDeviceFritzBoxHost._user == ""
        assert PersonalDeviceFritzBoxHost._password == ""

        PersonalDeviceFritzBoxHost.configure("asd123")
        assert PersonalDeviceFritzBoxHost._address == "asd123"
        assert PersonalDeviceFritzBoxHost._protocol == "http"

        PersonalDeviceFritzBoxHost.configure(protocol="https")
        assert PersonalDeviceFritzBoxHost._address == "asd123"
        assert PersonalDeviceFritzBoxHost._protocol == "https"

        PersonalDeviceFritzBoxHost.configure("host", "proto", "port", "user",
                                             "pw")
        assert PersonalDeviceFritzBoxHost._address == "host"
        assert PersonalDeviceFritzBoxHost._protocol == "proto"
        assert PersonalDeviceFritzBoxHost._port == "port"
        assert PersonalDeviceFritzBoxHost._user == "user"
        assert PersonalDeviceFritzBoxHost._password == "pw"
# Pmatic has a concept of persons and the presence of persons. For each
# person multiple devices can be configured which can then be used to
# detect the presence of a person. It is implemented as plugin mechanism
# which can be extended easily. For the start there is a plugin to control
# a persons availability by a device which is connected withe a fritz!Box
# in your local network.

import pmatic
ccu = pmatic.CCU(address="http://192.168.1.26",
                 credentials=("Admin", "EPIC-SECRET-PW"))

# Maybe you need to configure your fritz!Box credentials to be able to fetch the
# presence information of the configured devices.
from pmatic.residents import PersonalDeviceFritzBoxHost
PersonalDeviceFritzBoxHost.configure("fritz.box", password="******")

# Now load some resident data.
ccu.residents.from_config({
    "residents": [{
        "id":
        0,
        "name":
        "Lars",
        "email":
        "",
        "mobile":
        "",
        "pushover_token":
        "",
        "devices": [
Exemplo n.º 6
0
 def f(self):
     d = PersonalDeviceFritzBoxHost()
     d.from_config({"mac": "00:de:ad:be:ef:00"})
     return d
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# Pmatic has a concept of persons and the presence of persons. For each
# person multiple devices can be configured which can then be used to
# detect the presence of a person. It is implemented as plugin mechanism
# which can be extended easily. For the start there is a plugin to control
# a persons availability by a device which is connected withe a fritz!Box
# in your local network.

import pmatic
ccu = pmatic.CCU(address="http://192.168.1.26", credentials=("Admin", "EPIC-SECRET-PW"))

# Maybe you need to configure your fritz!Box credentials to be able to fetch the
# presence information of the configured devices.
from pmatic.residents import PersonalDeviceFritzBoxHost
PersonalDeviceFritzBoxHost.configure("fritz.box", password="******")

# Now load some resident data.
ccu.residents.from_config({
    "residents": [
        {
            "id"             : 0,
            "name"           : "Lars",
            "email"          : "",
            "mobile"         : "",
            "pushover_token" : "",
            "devices": [
                {
                    "type_name": "fritz_box_host",
                    "mac": "30:10:E6:10:D4:B2",
                },
Exemplo n.º 8
0
 def f(self):
     d = PersonalDeviceFritzBoxHost()
     d.from_config({"mac": "00:de:ad:be:ef:00"})
     return d