Open Mauricewillemstein opened 2 weeks ago
I don't want to change the core system to allow this, however I will be happy to help you freeing up those pins with customizations. Please give me some time and I will share some proposed code when I get home.
Thx that will be great and maybe usefull for other people
So, adding this to your panel's yaml should be able to free-up the relay pins:
switch:
- id: !extend relay_1
platform: template # Change the platform to free-up the GPIO
pin: !remove
optimistic: True
- id: !extend relay_2
platform: template # Change the platform to free-up the GPIO
pin: !remove
optimistic: True
This is not removing the code related to the relays, as that would make it a bit more complex and will require lots of tests. With this change, the relays are still exposed to Home Assistant, however those are only virtual (dummy) and won't have any relation to the physical relays.
Thx i will try it when i get at home.
Hope you enjoy the icecream :)
The code will upload without problems. All i have to do now is wire up everything and test it. Keep you informed
Hi, Got it sort of working now. I cut the traces in the power supply and solderd 4 wires for connecting the rfid reader. Only thing is that sometimes it says not found on the bus. I think that i have to modify the code a bit to add a wait before scanning the i2c bus.
Here is my code:
esphome:
name: woonkamer
friendly_name: Woonkamer
substitutions:
# Settings - Editable values
device_name: "woonkamer"
friendly_name: "Woonkamer"
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
# nextion_update_url: "http://homeassistant.local:8123/local/nspanel_eu.tft" # Optional
# Add-on configuration (if needed)
# heater_relay: "1" # Possible values: "1" or "2"
# Customization area
##### My customization - Start #####
##### My customization - End #####
# Core and optional configurations
packages:
remote_package:
url: https://github.com/Blackymas/NSPanel_HA_Blueprint
ref: main #dev
refresh: 300s
files:
- nspanel_esphome.yaml # Basic package
# Optional advanced and add-on configurations
- esphome/nspanel_esphome_advanced.yaml
# - esphome/nspanel_esphome_addon_ble_tracker.yaml
# - esphome/nspanel_esphome_addon_bluetooth_proxy.yaml
# - esphome/nspanel_esphome_addon_climate_cool.yaml
# - esphome/nspanel_esphome_addon_climate_heat.yaml
# - esphome/nspanel_esphome_addon_climate_dual.yaml
# - esphome/nspanel_esphome_addon_cover.yaml
switch:
- id: !extend relay_1
platform: template # Change the platform to free-up the GPIO
pin: !remove
optimistic: True
- id: !extend relay_2
platform: template # Change the platform to free-up the GPIO
pin: !remove
optimistic: True
i2c:
sda: GPIO19
scl: GPIO23
#frequency: 50kHz
scan: True
pn532_i2c:
address: 0x48
update_interval: 1s
on_tag:
then:
#- rtttl.play: 'two_short:d=4,o=5,b=100:16e6,16e6'
#- rtttl.play: 'long:d=1,o=5,b=100:e6'
- rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e'
#- rtttl.play: 'scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b'
#- rtttl.play: 'star_wars:d=16,o=5,b=100:4e,4e,4e,8c,p,g,4e,8c,p,g,4e,4p,4b,4b,4b,8c6,p,g,4d#,8c,p,g,4e,8p'
- text_sensor.template.publish:
id: rfid_tag
state: !lambda 'return x;'
text_sensor:
- platform: template
name: "RFID Tag"
id: rfid_tag
You probably can set scan
to false
on boot and then start it after boot. Something like this (not tested):
substitutions:
# Settings - Editable values
device_name: woonkamer
friendly_name: Woonkamer
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
# Core and optional configurations
packages:
remote_package:
url: https://github.com/Blackymas/NSPanel_HA_Blueprint
ref: main #dev
refresh: 300s
files:
- nspanel_esphome.yaml # Basic package
- esphome/nspanel_esphome_advanced.yaml
# Customization area
##### My customization - Start #####
switch:
- id: !extend relay_1
platform: template # Change the platform to free-up the GPIO
pin: !remove
optimistic: True
- id: !extend relay_2
platform: template # Change the platform to free-up the GPIO
pin: !remove
optimistic: True
i2c:
id: i2c_bus
sda: GPIO19
scl: GPIO23
#frequency: 50kHz
scan: false
esphome:
on_boot:
- priority: -100.0 # Almost everything should have started at this point
then:
- delay: 5s
- lambda: i2c_bus->set_scan(true);
pn532_i2c:
address: 0x48
update_interval: 1s
on_tag:
then:
#- rtttl.play: 'two_short:d=4,o=5,b=100:16e6,16e6'
#- rtttl.play: 'long:d=1,o=5,b=100:e6'
- rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e'
#- rtttl.play: 'scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b'
#- rtttl.play: 'star_wars:d=16,o=5,b=100:4e,4e,4e,8c,p,g,4e,8c,p,g,4e,4p,4b,4b,4b,8c6,p,g,4d#,8c,p,g,4e,8p'
- text_sensor.template.publish:
id: rfid_tag
state: !lambda 'return x;'
text_sensor:
- platform: template
name: "RFID Tag"
id: rfid_tag
##### My customization - End #####
Sorry for the late responce. Been from home. But want to let you know that it works fine.
Thx alot for your help
Enhancement Summary
Use pins from relais for other purpose
Detailed Description
I wonder if it will be possible to use the pins from the 2 relais to use for other purpose? I like to use the two gpio pins number 19 and 22 for i2c. I have spare room next to one of my nspanels and i want to connect a rfid reader, pn532, to it to automate some other things.
Additional Context
No response