fhem2fht-bulkupdate.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/bash
  2. ################################################################
  3. #
  4. # Copyright notice
  5. #
  6. # (c) 2008 Copyright: Martin Fischer (m_fischer at gmx dot de)
  7. # All rights reserved
  8. #
  9. # This script free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # The GNU General Public License can be found at
  15. # http://www.gnu.org/copyleft/gpl.html.
  16. # A copy is found in the textfile GPL.txt and important notices to the license
  17. # from the author is found in LICENSE.txt distributed with these scripts.
  18. #
  19. # This script is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. ################################################################
  25. #
  26. # For a proper work it is necessary to set retrycount >4,
  27. # e.g. "attr FHT_device retrycount 7"
  28. # define work days
  29. WORK="mon tue wed thu fri"
  30. # define recreation days
  31. FREE="sat sun"
  32. # define range,
  33. # (from1 to1 from2 to2)
  34. range=(08:00 18:00 24:00 24:00)
  35. # define range for recreation, e.g. "Wochenende",
  36. # (from1 to1 from2 to2)
  37. free=(08:00 18:00 24:00 24:00)
  38. #
  39. daytemp="19.5"
  40. nighttemp="17.5"
  41. lowtempoffset="4"
  42. mode="auto"
  43. windowopentemp="10.0"
  44. # define fhem.pl host:port
  45. FHEM_BIN="/usr/bin/fhem.pl localhost:7072"
  46. ###########################################################
  47. #
  48. # do not change
  49. #
  50. [[ $# -lt 1 ]] && { echo "usage: $0 FHT_device [FHT_device] [FHT_device]"; exit 1; } || FHT_SET="$*"
  51. # set range
  52. week=(${range[*]})
  53. # declare range
  54. span=(from1 to1 from2 to2)
  55. # set special properties
  56. for FHT in ${FHT_SET}; do
  57. ${FHEM_BIN} "set ${FHT} day-temp ${daytemp} night-temp ${nighttemp} mode ${mode}"
  58. ${FHEM_BIN} "set ${FHT} lowtemp-offset ${lowtempoffset} windowopen-temp ${windowopentemp}"
  59. done
  60. # set work days
  61. for ((i=0; i<${#span[@]};i++)); do
  62. for DAY in ${WORK}; do
  63. VALUE="${VALUE}${DAY}-${span[$i]} ${week[$i]} "
  64. done
  65. for FHT in ${FHT_SET}; do
  66. ${FHEM_BIN} "set ${FHT} ${VALUE}"
  67. done
  68. unset VALUE
  69. done
  70. # set recreation days
  71. for ((i=0; i<${#span[@]};i++)); do
  72. for DAY in ${FREE}; do
  73. VALUE="${VALUE}${DAY}-${span[$i]} ${free[$i]} "
  74. done
  75. for FHT in ${FHT_SET}; do
  76. ${FHEM_BIN} "set ${FHT} ${VALUE}"
  77. done
  78. unset VALUE
  79. done
  80. # refreshvalues
  81. #for FHT in ${FHT_SET}; do
  82. # ${FHEM_BIN} "set ${FHT} report1 255 report2 255"
  83. #done
  84. exit 0