Szafran

Untitled

Jun 8th, 2023
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. substitutions:
  2. devicename: dp-urc
  3. upper_devicename: "DP - Universal remote control"
  4. upper_devicename_nospace: "DP-Universal-Remote-Control"
  5.  
  6. esphome:
  7. name: ${devicename}
  8. platform: ESP8266
  9. board: esp01_1m
  10.  
  11.  
  12. logger:
  13. # level: NONE
  14. # level: ERROR
  15. # level: WARN
  16. # level: INFO
  17. level: DEBUG
  18. # level: VERBOSE
  19. # level: VERY_VERBOSE
  20.  
  21.  
  22. api:
  23. reboot_timeout: 360s
  24. services:
  25. - service: kod_nec
  26. variables:
  27. adres_przycisku: string
  28. kod_przycisku: string
  29. powtorzenia: int
  30. opoznienie_powtorzenia: string
  31. then:
  32. - remote_transmitter.transmit_nec:
  33. transmitter_id: universal_remote_control
  34. address: !lambda 'return strtoul(adres_przycisku.c_str(), nullptr, 16);'
  35. command: !lambda 'return strtoul(kod_przycisku.c_str(), nullptr, 16);'
  36. repeat:
  37. times: !lambda 'return powtorzenia;'
  38. wait_time: !lambda 'return strtoul(opoznienie_powtorzenia.c_str(), nullptr, 16);'
  39. - service: kod_samsung_32bity
  40. variables:
  41. adres_przycisku: string #dummy - zeby wszystkie services mialy takie same parametry
  42. kod_przycisku: string
  43. powtorzenia: int
  44. opoznienie_powtorzenia: string
  45. then:
  46. - remote_transmitter.transmit_samsung:
  47. transmitter_id: universal_remote_control
  48. data: !lambda 'return strtoul(kod_przycisku.c_str(), nullptr, 16);'
  49. nbits: 32
  50. repeat:
  51. times: !lambda 'return powtorzenia;'
  52. wait_time: !lambda 'return strtoul(opoznienie_powtorzenia.c_str(), nullptr, 16);'
  53. - service: kod_raw_38khz
  54. variables:
  55. adres_przycisku: string #dummy - zeby wszystkie services mialy takie same parametry
  56. kod_przycisku: int[]
  57. powtorzenia: int
  58. opoznienie_powtorzenia: string
  59. then:
  60. - remote_transmitter.transmit_raw:
  61. transmitter_id: universal_remote_control
  62. carrier_frequency: 38kHz
  63. code: !lambda 'return kod_przycisku;'
  64. repeat:
  65. times: !lambda 'return powtorzenia;'
  66. wait_time: !lambda 'return strtoul(opoznienie_powtorzenia.c_str(), nullptr, 16);'
  67. - service: kod_lg_32bity
  68. variables:
  69. adres_przycisku: string #dummy - zeby wszystkie services mialy takie same parametry
  70. kod_przycisku: string
  71. powtorzenia: int
  72. opoznienie_powtorzenia: string
  73. then:
  74. - remote_transmitter.transmit_lg:
  75. transmitter_id: universal_remote_control
  76. data: !lambda 'return strtoul(kod_przycisku.c_str(), nullptr, 16);'
  77. nbits: 32
  78. repeat:
  79. times: !lambda 'return powtorzenia;'
  80. wait_time: !lambda 'return strtoul(opoznienie_powtorzenia.c_str(), nullptr, 16);'
  81.  
  82.  
  83. ota:
  84. password: !secret ota_password
  85.  
  86.  
  87. wifi:
  88. ssid: !secret wifi_ssid
  89. password: !secret wifi_password
  90. reboot_timeout: 5min
  91. use_address: 192.168.1.213
  92. fast_connect: on
  93.  
  94. manual_ip:
  95. static_ip: 192.168.1.213
  96. gateway: 192.168.1.1
  97. subnet: 255.255.255.0
  98. dns1: 192.168.1.1
  99.  
  100.  
  101. ### PRG
  102.  
  103.  
  104. binary_sensor:
  105. - platform: status
  106. name: ${upper_devicename}
  107. id: sensor_status
  108.  
  109.  
  110. text_sensor:
  111. - platform: template
  112. name: "${upper_devicename} - Uptime"
  113. id: uptime_human
  114. icon: mdi:clock-outline
  115. - platform: template
  116. name: "${upper_devicename} - Siła sygnału WiFi"
  117. id: wifi_percentage
  118. icon: mdi:wifi
  119.  
  120.  
  121. time:
  122. - platform: sntp
  123. id: sensor_time
  124. timezone: "Europe/Warsaw"
  125. servers: [ 192.168.1.1, 0.pl.pool.ntp.org, 1.pl.pool.ntp.org ]
  126.  
  127.  
  128. sensor:
  129. - platform: uptime
  130. id: uptime_sensor
  131. update_interval: 5s
  132. internal: true
  133. on_raw_value:
  134. then:
  135. - text_sensor.template.publish:
  136. id: uptime_human
  137. state: !lambda |-
  138. int seconds = round(id(uptime_sensor).raw_state);
  139. int days = seconds / (24 * 3600);
  140. seconds = seconds % (24 * 3600);
  141. int hours = seconds / 3600;
  142. seconds = seconds % 3600;
  143. int minutes = seconds / 60;
  144. seconds = seconds % 60;
  145. return (
  146. (days ? String(days) + "d " : "") +
  147. (hours ? String(hours) + "h " : "") +
  148. (minutes ? String(minutes) + "m " : "") +
  149. (String(seconds) + "s")
  150. ).c_str();
  151. - platform: wifi_signal
  152. id: wifi_sensor
  153. update_interval: 5s
  154. internal: true
  155. on_raw_value:
  156. then:
  157. - text_sensor.template.publish:
  158. id: wifi_percentage
  159. state: !lambda |-
  160. int moc = round(id(wifi_sensor).raw_state);
  161. moc = 2 * (moc + 100);
  162. if (moc > 100) { moc = 100; };
  163. return ((moc ? String(moc) + "%" : "")).c_str();
  164.  
  165.  
  166. remote_transmitter:
  167. id: universal_remote_control
  168. pin: GPIO3
  169. carrier_duty_percent: 50%
  170.  
  171.  
  172. switch:
  173. - platform: restart
  174. name: "${upper_devicename} - Restart"
  175. id: switch_restart
Advertisement
Add Comment
Please, Sign In to add comment