The wiegand component doesn’t create any entities, it reads a tag or keypad and decodes it. If you want sensors or entities then you need to create them. For mine, I assigned a name to each code and tag. On a code or tag scan if it matches a user, a sensor is “last user” sensor is updated. If it doesn’t match then it’s an invalid user. There’s a ton of stuff you can do here, it depends on what you want and your willingness to read the documentation.
switch:
platform: template
id: OvrHead
optimistic: true
on_turn_on:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.overhead_door_barn_overhead
button:
- platform: restart
name: "Keypad Restart"
- platform: safe_mode
name: "Keypad (Safe Mode)"
binary_sensor:
- platform: status
id: keypad_status
name: Barn Keypad Status
text_sensor:
- platform: template
name: Uptime Wg26
id: uptime_human_wg26
icon: mdi:clock-start
- platform: wifi_info
ip_address:
name: Keypad IP Address
ssid:
name: Keypad Connected SSID
scan_results:
name: Keypad Latest Scan Results
- platform: template
name: Last User
id: last_user
icon: mdi:clock-start
sensor:
- platform: template
name: Keypad Code
id: keyCode
on_value:
- if:
condition:
- lambda: 'return id(keyCode).state == 6722842;'
then:
- switch.toggle: OvrHead
- text_sensor.template.publish:
id: last_user
state: "Mike's Tag"
- if:
condition:
- lambda: 'return id(keyCode).state == 1050;'
then:
- switch.toggle: OvrHead
- text_sensor.template.publish:
id: last_user
state: "Justin's Code"
- if:
condition:
- lambda: 'return id(keyCode).state == 6422842;'
then:
- switch.toggle: OvrHead
- text_sensor.template.publish:
id: last_user
state: "Paula's Tag"
- if:
condition:
- lambda: 'return id(keyCode).state == 1955;'
then:
- switch.toggle: OvrHead
- text_sensor.template.publish:
id: last_user
state: "Paula's Code"
- if:
condition:
- lambda: 'return id(keyCode).state == 5553549;'
then:
- switch.toggle: OvrHead
- text_sensor.template.publish:
id: last_user
state: "Golf Cart Tag"
- if:
condition:
- lambda: 'return id(keyCode).state == 6491970;'
then:
- switch.toggle: OvrHead
- text_sensor.template.publish:
id: last_user
state: "Mike's Tag"
- if:
condition:
- lambda: 'return id(keyCode).state != 5553549;'
- lambda: 'return id(keyCode).state != 6422842;'
- lambda: 'return id(keyCode).state != 6722842;'
- lambda: 'return id(keyCode).state != 6491970;'
- lambda: 'return id(keyCode).state != 6753957;'
- lambda: 'return id(keyCode).state != 1050;'
- lambda: 'return id(keyCode).state != 1955;'
then:
- text_sensor.template.publish:
id: last_user
state: "Invalid User Access"
- platform: wifi_signal
id: wifi_signal_db
update_interval: 300s
entity_category: "diagnostic"
- platform: copy
source_id: wifi_signal_db
name: "WiFi Signal Keypad"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "Signal %"
entity_category: "diagnostic"
id: wifiSignalWG26
- platform: uptime #Uptime in Seconds
name: Barn Keypad Uptime
id: uptime_sensor_wiegand
update_interval: 240s
internal: True
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human_wg26
state: !lambda |-
int seconds = round(id(uptime_sensor_wiegand).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
wiegand:
- id: mykeypad
d0: D7
d1: D6
on_key:
- lambda: ESP_LOGI("KEY", "received key %d", x);
on_tag:
- lambda: ESP_LOGI("TAG", "received tag %s", x.c_str());
- sensor.template.publish:
id: keyCode
state: !lambda "return parse_number<float>(x).value();"
on_raw:
- lambda: ESP_LOGI("RAW", "received raw %d bits, value %llx", bits, value);
key_collector:
- id: pincode_reader
source_id: mykeypad
min_length: 4
max_length: 5
end_keys: "#"
end_key_required: true
clear_keys: "*"
allowed_keys: "0123456789"
timeout: 5s
on_progress:
- logger.log:
format: "input progress: '%s', started by '%c'"
args: [ 'x.c_str()', "(start == 0 ? '~' : start)" ]
on_result:
then:
- sensor.template.publish:
id: keyCode
state: !lambda "return parse_number<float>(x).value();"
on_timeout:
- logger.log:
format: "input timeout: '%s', started by '%c'"
args: [ 'x.c_str()', "(start == 0 ? '~' : start)" ]
This guy made a whole program to add users or codes from the HA font end, he also made it so you can reset codes from the keypad itself. It’s kind of overkill IMO and takes some time to understand the program flow but, you might find it useful or find inspiration by looking through his code.
