iotdevicesdev / GGreg20_V3-ESP32-HomeAssistant-ESPHome

IoT-devices GGreg20_V3 ionizing radiation Geiger counter module for generic ESP32 under Home Assistant with ESPHome setup example
https://iot-devices.com.ua/en/product/ggreg20_v3-ionizing-radiation-detector-with-geiger-tube-sbm-20/
Apache License 2.0
10 stars 2 forks source link

Pin Reuse not longer allowed in HomeAssistant ESPHome #2

Closed Herbi-1966 closed 9 months ago

Herbi-1966 commented 9 months ago

Since update to ESPHome 2023.12.0 (HomeAssistant) the multiple use of one Pin for several duties is no longer allowed. So esp32-ggreg20-v3.yaml is no longer valid. Could you please so kind and have a look on it? For the while I stay on ESPHome 2023.11.6

Thank you very much! Regards Herbi

Herbi-1966 commented 9 months ago

affected lines in yaml code:

esphome: name: "esp32-ggreg20-v3"

...

...

binary_sensor:

iotdevicesdev commented 9 months ago

The problem is very easy to solve with the help of special methods available in ESPHome. But it will take me some time to make and test the appropriate changes to this file.

While I'm doing that, you can make the changes yourself in the following way:

When you need to reuse a pin, use https://esphome.io/components/copy.html For sensor entities: https://esphome.io/components/copy.html#copy-sensor For binary sensor entities: https://esphome.io/components/copy.html#copy-binary-sensor

Thus, you should get something like this:

- platform: pulse_counter
  pin: GPIO23
  unit_of_measurement: 'CPM'
  name: 'Ionizing Radiation Power CPM'
  count_mode: 
    'rising_edge': DISABLE
    falling_edge: INCREMENT # GGreg20_V3 uses Active-Low logic
# It seems that only one instance of pulse counter internal filters can be set
# So here no any debounce filters for CPM value 
# use_pcnt: False
# internal_filter: 190us
  update_interval: 60s
  accuracy_decimals: 0
  id: my_cpm_meter

- platform: copy
  source_id: my_cpm_meter
  unit_of_measurement: 'CPM'
  name: 'Ionizing Radiation Power CPM MA5'
  accuracy_decimals: 0
  id: my_cpm_meter_ma5
  filters:
    - # sliding_window_moving_average: # 5-minute moving average (MA5) here
        window_size: 5
        send_every: 1      

- platform: copy
  source_id: my_cpm_meter
  unit_of_measurement: 'uSv/Hour'
  name: 'Ionizing Radiation Power'
  accuracy_decimals: 3
  id: my_dose_meter
  filters:
# - sliding_window_moving_average: # 5-minute moving average (MA5) here
# window_size: 5
# send_every: 1      
    - multiply: 0.0057 # or 0.00332 for J305 by IoT-devices tube conversion factor of pulses into uSv/Hour 

- platform: integration
  name: "Total Ionizing Radiation Dose"
  unit_of_measurement: "uSv"
  sensor: my_dose_meter # link entity id to the pulse_counter values above
  icon: "mdi:radioactive"
  accuracy_decimals: 5
  time_unit: min # integrate values every next minute
  filters:
    # received dose. Converting from uSv/hour to uSv/minute: [uSv/h / 60] OR [uSv/h * 0.0166666667]. 
    # if my_dose_meter is in CPM, then [0.0057 / 60 minutes] = 0.000095; so CPM * 0.000095 = dose every next minute, uSv.
    - multiply: 0.0166666667

I hope that after these changes, which I have given in the example, everything will work for you. I wish you success, Oleksii

iotdevicesdev commented 9 months ago

yaml-file and documentation -> updated

Herbi-1966 commented 9 months ago

Hi,

thank you yery much for your quick reaction and help!

I wish you all the best ☺️

Kind regards Herbert

Am 22. Dez. 2023, 18:17, um 18:17, IoT-devices LLC @.***> schrieb:

Closed #2 as completed.

-- Reply to this email directly or view it on GitHub: https://github.com/iotdevicesdev/GGreg20_V3-ESP32-HomeAssistant-ESPHome/issues/2#event-11328320045 You are receiving this because you authored the thread.

Message ID: @.***>

iotdevicesdev commented 9 months ago

You are welcome! Also you can see the ESPHome Pin Schemma document: https://esphome.io/guides/configuration-types#config-pin-schema config key: "allow_other_uses" You can use this key to override pin reuses in special situations. BR, Oleksii