Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin Reuse not longer allowed in HomeAssistant ESPHome #2

Closed
Herbi-1966 opened this issue Dec 21, 2023 · 5 comments
Closed

Pin Reuse not longer allowed in HomeAssistant ESPHome #2

Herbi-1966 opened this issue Dec 21, 2023 · 5 comments

Comments

@Herbi-1966
Copy link

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
Copy link
Author

Herbi-1966 commented Dec 22, 2023

affected lines in yaml code:

esphome:
name: "esp32-ggreg20-v3"
#...
#...
binary_sensor:

  • platform: gpio
    name: "Pulse input state"
    id: my_pulse_input
    pin:
    number: 23
    inverted: True
    mode:
    input: True
    #...
    #...
    sensor:
  • platform: pulse_counter
    pin: GPIO23
    unit_of_measurement: 'CPM'
    name: 'Ionizing Radiation Power CPM'
    count_mode:
    rising_edge: DISABLE
    #...
    #...
  • platform: pulse_counter
    pin: GPIO23
    unit_of_measurement: 'uSv/Hour'
    name: 'Ionizing Radiation Power'
    count_mode:
    rising_edge: DISABLE
    falling_edge: INCREMENT
    #...
    #...

@iotdevicesdev
Copy link
Owner

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 added a commit that referenced this issue Dec 22, 2023
Bugfix to take into account the new ESPHome requirements for reusing the same pin within a project's YAML configuration.
See issue: #2
@iotdevicesdev
Copy link
Owner

yaml-file and documentation -> updated

@Herbi-1966
Copy link
Author

Herbi-1966 commented Dec 22, 2023 via email

@iotdevicesdev
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants