Untitled

From Corrupt Eider, 2 Months ago, written in Plain Text, viewed 1 times.
URL https://paste.linuxiarz.pl/view/312b03d6 Embed
Download Paste or View Raw
  1. substitutions:
  2.   devicename: esp32-tools
  3.   sdm1_entity: "SDM-AC"
  4.   pzem_entity: "PZEM-RACK"
  5.   sdm1_entity_under: "sdm_ac"
  6.   pzem_entity_under: "pzem_rack"
  7.   esp_entity: "ESP-TOOLS"
  8.   hostname: $devicename
  9.   update_interval: 20s
  10.    
  11. esphome:
  12.   name: $devicename
  13.   comment: "ESP32/RS485/CC1101/DHT11/PZEM004"
  14.  
  15. esp32:
  16.   board: esp32dev
  17. #  framework:
  18. #    type: arduino
  19. #    version: 2.0.6
  20.    
  21. external_components:
  22.   - source:
  23.       type: git
  24.       url: https://github.com/zdzichu6969/esphome-components
  25.     components: [ heapmon, backup, startup ]
  26.     refresh: 0s
  27.   - source:
  28.       type: git
  29.       url: https://github.com/SzczepanLeon/esphome-components
  30.     components: [ wmbus ]
  31.     refresh: 0s
  32.   - source: github://pr#4444
  33.     components: [async_tcp, web_server_base]
  34.     refresh: always
  35.  
  36.  
  37. # Enable logging
  38. logger:
  39.     level: DEBUG
  40.     baud_rate: 0
  41.  
  42. api:
  43.   encryption:
  44.     key: !secret api_encryption_key
  45.   reboot_timeout: 0s
  46.  
  47. ota:
  48.  - platform: esphome
  49.    password: !secret ota_password
  50.    #safe_mode: True
  51.  
  52.  
  53. wifi:
  54.   ssid: !secret wifi_ssid
  55.   password: !secret wifi_password
  56.   reboot_timeout: 300s
  57.   power_save_mode: none
  58.   fast_connect: true
  59.   domain: .iot.r.local
  60.   use_address: 10.87.65.19
  61.   #use_address: 10.87.65.27
  62.  
  63.   ap:
  64.     ssid: "Fallback-AP-${hostname}"
  65.     password: ""
  66.     ap_timeout: 300s
  67.  
  68. captive_portal:
  69.  
  70. web_server:
  71.   version: 3
  72.   port: 80
  73.   ota: false
  74.   include_internal: false
  75.   local: true
  76.  
  77. time:
  78.   - platform: sntp
  79.     id: sntp_time1
  80.     servers:
  81.       - 10.87.65.1
  82.     timezone: Europe/Warsaw
  83.     on_time_sync:
  84.       then:
  85.         - logger.log: "Synchronized system clock"
  86.  
  87. uart:
  88.   - id: uart_sdm
  89.     tx_pin: GPIO17
  90.     rx_pin: GPIO16
  91.     baud_rate: 2400
  92.     stop_bits: 1
  93.     rx_buffer_size: 512
  94.   - id: uart_pzem
  95.     tx_pin: GPIO1
  96.     rx_pin: GPIO3
  97.     baud_rate: 9600
  98.  
  99. modbus:
  100.  
  101.   - id: mod_bus_sdm
  102.     send_wait_time: 500ms
  103.     uart_id: uart_sdm
  104.     disable_crc: true
  105.   - id: mod_bus_pzem
  106.     send_wait_time: 200ms
  107.     uart_id: uart_pzem
  108.     disable_crc: false
  109.  
  110. wmbus:
  111.   mosi_pin: GPIO23
  112.   clk_pin:  GPIO22
  113.   miso_pin: GPIO19
  114.   gdo0_pin: GPIO21
  115.   gdo2_pin: GPIO18
  116.   cs_pin:   GPIO5
  117.  
  118.   log_unknown: True
  119.  
  120.  
  121. modbus_controller:
  122.   - id: pzem
  123.     # The current device address.
  124.     address: 0x1
  125.     # The special address 0xF8 is a broadcast address accepted by any pzem device,
  126.     # so if you use this address, make sure there is only one pzem device connected
  127.     # to the uart bus.
  128.     # address: 0xF8
  129.     modbus_id: mod_bus_pzem
  130.     command_throttle: 0ms
  131.     setup_priority: -10
  132.  
  133.   - id: sdm
  134.     modbus_id: mod_bus_sdm
  135.     update_interval: ${update_interval}
  136.     address: 1
  137.     setup_priority: -10
  138.  
  139.  
  140. interval:
  141.   - interval: ${update_interval}
  142.     then:
  143.       - delay: 500ms
  144.       - lambda: "id(${pzem_entity_under}).update();"
  145.      
  146. sensor:
  147.  
  148.   ### PZEM ###
  149.   - platform: pzemac
  150.     id: ${pzem_entity_under}
  151.     modbus_id: mod_bus_pzem
  152.     current:
  153.       name: "${pzem_entity} Current"
  154.       filters:
  155.         - lambda: |-
  156.             float MAX_DIFFERENCE = 20.0;
  157.             static float last_value = NAN;
  158.             if (isnan(last_value) || std::abs(x - last_value) < MAX_DIFFERENCE)
  159.               return last_value = x;
  160.             else
  161.               return {};
  162.  
  163.     voltage:
  164.       name: "${pzem_entity} Voltage"
  165.       filters:
  166.         - lambda: |-
  167.             float MAX_DIFFERENCE = 300.0;
  168.             static float last_value = NAN;
  169.             if (isnan(last_value) || std::abs(x - last_value) < MAX_DIFFERENCE)
  170.               return last_value = x;
  171.             else
  172.               return {};
  173.     energy:
  174.       name: "${pzem_entity} Energy"
  175.       unit_of_measurement: "kWh"
  176.       filters:
  177.         - multiply: 0.001
  178.         - lambda: |-
  179.             float MAX_DIFFERENCE = 1.0;
  180.             static float last_value = NAN;
  181.             if (isnan(last_value) || std::abs(x - last_value) < MAX_DIFFERENCE)
  182.               return last_value = x;
  183.             else
  184.               return {};
  185.       accuracy_decimals: 3
  186.       id: "${pzem_entity_under}_energy"
  187.     power:
  188.       name: "${pzem_entity} Power"
  189.       filters:
  190.         - lambda: |-
  191.             float MAX_DIFFERENCE = 10000.0;
  192.             static float last_value = NAN;
  193.             if (isnan(last_value) || std::abs(x - last_value) < MAX_DIFFERENCE)
  194.               return last_value = x;
  195.             else
  196.               return {};
  197.     frequency:
  198.       name: "${pzem_entity} Frequency"
  199.       filters:
  200.         - lambda: |-
  201.             float MAX_DIFFERENCE = 2.0;
  202.             static float last_value = NAN;
  203.             if (isnan(last_value) || std::abs(x - last_value) < MAX_DIFFERENCE)
  204.               return last_value = x;
  205.             else
  206.               return {};
  207.     power_factor:
  208.       name: "${pzem_entity} Power Factor"
  209.       filters:
  210.         - lambda: |-
  211.             float MAX_DIFFERENCE = 2.0;
  212.             static float last_value = NAN;
  213.             if (isnan(last_value) || std::abs(x - last_value) < MAX_DIFFERENCE)
  214.               return last_value = x;
  215.             else
  216.               return {};
  217.   ### DHT-11 ###
  218.   - platform: dht
  219.     pin: GPIO13
  220.     temperature:
  221.       name: "Szafa temperature"
  222.     humidity:
  223.       name: "Szafa humidity"
  224.     update_interval: 30s
  225.     model: DHT11
  226.  
  227.   - platform: wmbus
  228.     meter_id: 0x03300600
  229.     type: apator162
  230.     key: "00000000000000000000000000000000"
  231.     add_prefix: False
  232.     lqi:
  233.       name: "Apator 03300600 lqi"
  234.     rssi:
  235.       name: "Apator 03300600 RSSI"
  236.     total_water_m3:
  237.       name: "Apator 03300600"
  238.  
  239.   - platform: wmbus
  240.     meter_id: 0x00340449
  241.     type: apator162
  242.     key: "00000000000000000000000000000000"
  243.     add_prefix: false
  244.     lqi:
  245.       name: "Apator 00340449 lqi"
  246.     rssi:
  247.       name: "Apator 00340449 RSSI"
  248.     total_water_m3:
  249.       name: "Apator 00340449"
  250.  
  251.   ### SDM120-M KLIMA ###
  252.  
  253.   - platform: modbus_controller
  254.     modbus_controller_id: sdm
  255.     id: sdm1_current
  256.     name: "${sdm1_entity} Current"
  257.     register_type: read
  258.     address: 0x0006
  259.     value_type: FP32
  260.     device_class: "current"
  261.     state_class: "measurement"
  262.     unit_of_measurement: A
  263.     accuracy_decimals: 3
  264.  
  265.   - platform: modbus_controller
  266.     modbus_controller_id: sdm
  267.     name: "${sdm1_entity} Voltage"
  268.     register_type: read
  269.     address: 0x0000
  270.     value_type: FP32
  271.     unit_of_measurement: V
  272.     device_class: "voltage"
  273.     state_class: "measurement"
  274.     accuracy_decimals: 2
  275.  
  276.   - platform: modbus_controller
  277.     modbus_controller_id: sdm
  278.     name: "${sdm1_entity} Power"
  279.     register_type: read
  280.     address: 0x000C
  281.     value_type: FP32
  282.     unit_of_measurement: W
  283.     device_class: "power"
  284.     state_class: "measurement"
  285.     accuracy_decimals: 2
  286.    
  287.   - platform: modbus_controller
  288.     modbus_controller_id: sdm
  289.     name: "${sdm1_entity} Power Factor"
  290.     register_type: read
  291.     address: 0x001E
  292.     value_type: FP32
  293.     device_class: "power_factor"
  294.     state_class: "measurement"
  295.     unit_of_measurement: ""
  296.     accuracy_decimals: 3
  297.  
  298.   - platform: modbus_controller
  299.     modbus_controller_id: sdm
  300.     name: "${sdm1_entity} Apparent Power"
  301.     register_type: read
  302.     address: 0x0012
  303.     value_type: FP32
  304.     device_class: ""
  305.     state_class: "measurement"
  306.     unit_of_measurement: VA
  307.     accuracy_decimals: 3
  308.  
  309.   - platform: modbus_controller
  310.     modbus_controller_id: sdm
  311.     name: "${sdm1_entity} Reactive Power"
  312.     register_type: read
  313.     address: 0x0018
  314.     value_type: FP32
  315.     device_class: ""
  316.     state_class: "measurement"
  317.     unit_of_measurement: var
  318.     accuracy_decimals: 2
  319.  
  320.   - platform: modbus_controller
  321.     modbus_controller_id: sdm
  322.     name: "${sdm1_entity} Frequency"
  323.     register_type: read
  324.     address: 0x0046
  325.     value_type: FP32
  326.     unit_of_measurement: Hz
  327.     state_class: "measurement"
  328.     accuracy_decimals: 2
  329.  
  330.   - platform: modbus_controller
  331.     modbus_controller_id: sdm
  332.     name: "${sdm1_entity} Import Active Energy"
  333.     register_type: read
  334.     address: 0x0048
  335.     value_type: FP32
  336.     unit_of_measurement: kWh
  337.     state_class: "total_increasing"
  338.     device_class: "energy"
  339.     accuracy_decimals: 3
  340.     id: "${sdm1_entity_under}_import_active_energy"
  341.  
  342.   - platform: modbus_controller
  343.     modbus_controller_id: sdm
  344.     name: "${sdm1_entity} Import Reactive Energy"
  345.     register_type: read
  346.     address: 0x004C
  347.     value_type: FP32
  348.     unit_of_measurement: kVArh
  349.     state_class: "total_increasing"
  350.     device_class: "energy"
  351.  
  352.  
  353.   ### OTHER ###
  354.   - platform: wifi_signal
  355.     id: esp_mcc_wifisignal
  356.     name: "${esp_entity} WiFi Signal"
  357.     update_interval: 60s
  358.  
  359.   - platform: uptime
  360.     id: esp_mcc_uptime
  361.     name: "${esp_entity} Uptime"
  362.     filters:
  363.       - lambda: return x / 60.0;
  364.     unit_of_measurement: minutes
  365.  
  366.   - platform: heapmon  
  367.     id: esp_mcc_heapspace  
  368.     name: "${esp_entity} Heapsize"
  369.     entity_category: diagnostic
  370.  
  371.   - platform: copy
  372.     source_id: esp_mcc_wifisignal
  373.     id: esp_mcc_wifisignal_hr
  374.     name: "${esp_entity} WiFi %"
  375.     filters:
  376.       - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
  377.     unit_of_measurement: "%"
  378.     icon: mdi:wifi
  379.     entity_category: "diagnostic"
  380.  
  381.   - platform: startup
  382.     name: ${esp_entity} Startup
  383.     entity_category: diagnostic
  384.  
  385. text_sensor:
  386.  
  387.   - platform: version
  388.     name: ${esp_entity} ESPHome Version
  389.     hide_timestamp: true
  390.  
  391.   - platform: wifi_info
  392.     ip_address:
  393.       name: ${esp_entity} IP Address
  394.       icon: mdi:ip-network
  395.  
  396. switch:
  397.   - platform: restart
  398.     name: "${esp_entity} Restart"
  399.   - platform: factory_reset
  400.     name: "${esp_entity} Factory reset"
  401.  
  402. backup:
  403.  

Reply to "Untitled"

Here you can reply to the paste above

captcha