Advertisement
Milfeldt

Pillemåler

Dec 14th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. esphome:
  2. name: pillebeholder
  3. friendly_name: Pillebeholder
  4.  
  5. esp32:
  6. board: esp32dev
  7. framework:
  8. type: esp-idf
  9.  
  10. # Enable logging
  11. logger:
  12.  
  13. # Enable Home Assistant API
  14. api:
  15. encryption:
  16. key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  17.  
  18. ota:
  19. - platform: esphome
  20. password: "xxxxxxxxxxxxxxxxxxxx"
  21.  
  22. wifi:
  23. ssid: !secret wifi_ssid
  24. password: !secret wifi_password
  25. manual_ip:
  26. static_ip: xxx.xxx.xxx.xxx
  27. gateway: xxx.xxx.xxx.xxx
  28. subnet: xxx.xxx.xxx.xxx
  29. dns1: xxx.xxx.xxx.xxx
  30.  
  31.  
  32.  
  33. # Enable fallback hotspot (captive portal) in case wifi connection fails
  34. ap:
  35. ssid: "Pillebeholder Fallback Hotspot"
  36. password: "xxxxxxx"
  37.  
  38. captive_portal:
  39.  
  40. web_server:
  41. port: 80
  42.  
  43. i2c:
  44. sda: GPIO16
  45. scl: GPIO17
  46. scan: true
  47. id: bus_a
  48.  
  49. sensor:
  50. - platform: vl53l0x
  51. address: 0x29
  52. name: "Afstand"
  53. id: distance
  54. update_interval: 30s
  55. long_range: false
  56.  
  57. - platform: template
  58. id: level
  59. name: Pilletop
  60. unit_of_measurement: '%'
  61. update_interval: 30s
  62. lambda: |-
  63. if (isnan(id(distance).state)) return 0;
  64. auto r = (id(distance).state - 0.75) * (100.0 - 0.0) / (0.1 - 0.75) + 0.0;
  65. if (r > 100) return 100;
  66. if (r < 0) return 0;
  67. return r;
  68.  
  69. ## auto r = (id(distance).state - 0.55) * (100.0 - 0.0) / (0.1 - 0.55) + 0.0; ## 0.55 TIL 0.7 VISER 0%
  70. ## auto r = (id(distance).state - 0.8) * (100.0 - 0.0) / (0.1 - 0.8) + 0.0; ## VISER 15%
  71. ## auto r = (id(distance).state - 0.75) * (100.0 - 0.0) / (0.1 - 0.75) + 0.0; ## VISER 7,5-9,5%
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement