15 Ideas for refactoring 2021
mattzz edited this page 2021-05-15 21:13:44 +02:00

Ideas for refactoring 2021

Scary host interaction

The lists haunted_houe, auto_mode_hosts and random_mode_hosts are pupulated via the config URL.

  • This means that they are empty beforehand. However, at least the contents for the local scary host may be referenced by other methods, e.g. for the random_mode or auto_mode URLs at least for the local scary host. This means in the handler methods, work-arounds are then needed, e.g. the random_mode handler.
  • The config URL is used to configure all available hosts so it makes sense to present information on all scarey hosts in the network. However, this is only needed for a UI that controls all devices. Here, the information would be valuable which of the hosts are online so that I don't get active controls shown for scary hosts that are not being available. Even better, it would be good to see which of configured devices are offline.
  • It would be good that a scary determines his own capabilities based on its config.py because its capabilities come with a pumpin.py update anway.
  • A scary host may in the future als call other scary host's scary actions but these no discovery is needed only a work-around for them neing unavailable.
  • In the index and config page, however, we also show controls for the other hosts and here it would be important to only show them if the scary host is available.

Conclusion:

  • A scary host should initialize the lists for its own capabilities from its config.py. --> DONE
  • Local control should be possible without having to discover any other scary host. --> DONE
  • For local control, the remote scary hosts shouldn't even be shown. --> DONE, until they are discovered
  • This way a scary host can operate and can be controlled without any knowledge of the rest of the haunted house. It doesn't even have to know that there is a server controlling it and not a user by a web UI. --> DONE

Possible solution:

  • Discovering other scary hosts could be a scary action of its own (that can also run in auto mode). With the discovery, then other scary hosts will be shown in the index and config pages as well as long as they are online. This scary host would not offer any other local scary actions but all the scary it has found. Then the index page would not run the discovery method any more at all.
  • First Steps:
    • Discovery of entire haunted house now needs to be explicitely called via the discovery route or the discover scary action by the user (or via auto_mode). --> DONE
    • The scary actions of the local scary_host are always discovered automatically. --> DONE
    • This means a scary host will be able to operate independently already now without contacting the other scary hosts unless it's triggered. --> DONE

Other improvements

  • Prevent random mode from being started multiple times --> Done. Use random_mode as a flag. Set on when starting thread, don't start a new thread while it's on and set it to off when ending the thread.
  • Catch the problem if the current host name (e.g. with the :5000) is not defined in config.p< --> Done. Aborting now right after start.
  • The name resolution doesn't always work. Sometimes adding ".local" helps but sometimes only the ip address works.
  • Make waiting time after a scary action in auto_mode configurable so that there is a break between the scary actions --> DONE
  • Show the Volume slider only for a host that offers audio capability (cfg?) --> #134
  • Test what happens if random_mode and auto_mode are both ON