MQTT Home Emulation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

home_emulation.py 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import config
  2. import devdi
  3. import devdi.props as props
  4. #import function
  5. #import json
  6. import logging
  7. import mqtt
  8. import os
  9. import report
  10. #import subprocess
  11. import time
  12. logger = logging.getLogger(config.APP_NAME)
  13. if __name__ == "__main__":
  14. #
  15. # Logging
  16. #
  17. if config.DEBUG:
  18. report.appLoggingConfigure(None, 'stdout', ((config.APP_NAME, logging.DEBUG), ),
  19. target_level=logging.WARNING, fmt=report.SHORT_FMT, host='localhost', port=19996)
  20. else:
  21. report.stdoutLoggingConfigure(((config.APP_NAME, logging.WARNING), ), report.SHORT_FMT)
  22. #
  23. # MQTT Client
  24. #
  25. mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
  26. password=config.MQTT_PASSWORD, name=config.APP_NAME)
  27. #
  28. # Smarthome Devices
  29. #
  30. ddi = devdi.devices(mc)
  31. #
  32. # Smart Home Functionality
  33. #
  34. #######
  35. # GFW #
  36. #######
  37. loc = props.LOC_GFW
  38. # DIRK
  39. roo = props.ROO_DIR
  40. sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  41. tml = ddi.get(props.STG_ZGW, loc, roo, props.FUN_MAL)
  42. sml.register_power_on_instance(tml)
  43. # FLOOR
  44. roo = props.ROO_FLO
  45. sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  46. tml = ddi.get(props.STG_ZGW, loc, roo, props.FUN_MAL, 1)
  47. sml.register_power_on_instance(tml)
  48. tml = ddi.get(props.STG_ZGW, loc, roo, props.FUN_MAL, 2)
  49. sml.register_power_on_instance(tml)
  50. #######
  51. # FFW #
  52. #######
  53. loc = props.LOC_FFW
  54. # JULIAN
  55. roo = props.ROO_JUL
  56. sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  57. tml = ddi.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  58. sml.register_power_on_instance(tml)
  59. # LIVINGROOM
  60. roo = props.ROO_LIV
  61. sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  62. tml = ddi.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  63. sml.register_power_on_instance(tml)
  64. # SLEEP
  65. roo = props.ROO_SLP
  66. sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  67. tml = ddi.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  68. sml.register_power_on_instance(tml)
  69. #######
  70. # FFE #
  71. #######
  72. loc = props.LOC_FFE
  73. # LIVINGROOM
  74. roo = props.ROO_LIV
  75. sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  76. tml = ddi.get(props.STG_ZFE, loc, roo, props.FUN_MAL)
  77. sml.register_power_on_instance(tml)
  78. # SLEEP
  79. roo = props.ROO_SLP
  80. sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  81. tml = ddi.get(props.STG_ZFE, loc, roo, props.FUN_MAL)
  82. sml.register_power_on_instance(tml)
  83. while (True):
  84. time.sleep(1)