#!/usr/bin/env python
# Copyright (c) 2022 Clément Martin <twisla@twis.la. All rights reserved.
# Unauthorized copying of this file, via any medium is strictly prohibited

"""Home network diagram
"""

from diagrams import Cluster, Diagram

from audio import Amplifier, AudioStreamer, BlueSoundSpeaker, TubeAmp, TurnTable
from consoles import NintendoSwitch, PlayStation4
from devices import AndroidPhone, EliteBook, IPhone, Laptop, NUC, Printer, Rpi4, SynologyDS, ThinkPad, WashingMachine
from edges import MyEdge
from electricity import Boxx, CPL
from fitbit import Aria
from lights import HueBridge, HueBulb, HueSpot, SmartPlug, Tradfri
from network import IndustrialRouter, Modem, ProximusBBox, ProximusInternet, Switch, TelenetInternet, UniFiAP
from video import ProximusTV, Television, UltraWideScreen

with Diagram('Konijnenberg', direction='TB', show=False):
    with Cluster('Bureau', direction='TB'):
        office_cpl      = CPL('')
        ps4             = PlayStation4()
        printer         = Printer()
        rainbow         = Rpi4('Rainbow')
        switch          = Switch('')
        walter          = NUC('walter')
        zippo           = SynologyDS('Zippo')
        rpi4s           = [ Rpi4(f'RPI4/{x}') for x in range(5) ]

        switch          << MyEdge('ethernet') >> [office_cpl, ps4, printer, rainbow, walter, zippo] + rpi4s

    with Cluster('Salon'):
        hue             = HueBridge('')
        living_cpl      = CPL('')
        malkovitch      = IndustrialRouter('malkovitch')
        proximus        = ProximusInternet('')
        proximus_router = ProximusBBox('')
        proximus_tv     = ProximusTV('')
        telenet         = TelenetInternet('')
        telenet_router  = ProximusBBox('')  # FIXME: find the correct icon.

        malkovitch      << MyEdge('ethernet') >> [living_cpl, proximus_router, telenet_router]
        proximus_router << MyEdge('adsl')     >> proximus
        proximus_router << MyEdge('ethernet') >> [ hue, proximus_tv ]
        telenet_router  << MyEdge('cable')    >> telenet

    with Cluster('Wireless', direction='TB'):
        wifi_ap = UniFiAP('NanoHD')

        with Cluster('Misc'):
            with Cluster('Salon'):
                boxx       = Boxx('Thermostat')
            with Cluster('Salle de bain'):
                balance    = Aria('')
            with Cluster('Garage', direction='TB'):
                lessiveuse = WashingMachine('')
        with Cluster('Sound'):
            with Cluster('Cuisine', direction='TB'):
                flex2i = BlueSoundSpeaker('')
            with Cluster('Salon'):
                # ampli = Amplifier('Ampli')  # has buletooth
                hifi  = BlueSoundSpeaker('')
        with Cluster('Video'):
            with Cluster('Salon'):
                tv_salon = Television('')
                jack     = Rpi4('')
        with Cluster('User Devices'):
            with Cluster('Clément'):
                laptop_clement  = ThinkPad('')
                tel_clement     = AndroidPhone('')
            with Cluster('Maïthé'):
                laptop_maithe   = EliteBook('')
                tel_maithe      = IPhone('')
            with Cluster('Alistair'):
                nintendo_switch = NintendoSwitch('')
                tel_alistair    = AndroidPhone('')
            wifi_devices    = [ nintendo_switch, laptop_clement, laptop_maithe,
                                tel_alistair, tel_maithe, tel_clement ]


        wifi_ap << MyEdge('wifi') >> [ tv_salon, jack, boxx, hifi ]
        wifi_ap << MyEdge('wifi') >> wifi_devices
        wifi_ap << MyEdge('wifi') >> balance
        wifi_ap << MyEdge('wifi') >> flex2i
        wifi_ap << MyEdge('wifi') >> lessiveuse


    living_cpl << MyEdge('electric') >> office_cpl
    wifi_ap    << MyEdge('ethernet') >> malkovitch
