robmarkcole / HASS-plate-recognizer

Read number plates with https://platerecognizer.com/
128 stars 25 forks source link

build sensor last found plate (attributes not working?) #67

Open koburg opened 2 years ago

koburg commented 2 years ago

I want to make an sensor where I can se the last plate found NOT known.

here is what I have been trying.

in developer tools:

{{ state_attr('image_processing.platerecognizer_garage_2' , 'vehicles') }}

output

[{'plate': 'nkeXXXX', 'confidence': 0.683, 'region_code': 'pl', 'vehicle_type': 'Big Truck', 'box_y_centre': 116.0, 'box_x_centre': 1563.0}]

so I want to show attribute 'plate'

{{ state_attr('image_processing.platerecognizer_garage_2' , 'vehicles').plate }}

output

none

expected output

nkeXXXX

is there something I am missing ?

reesion commented 1 year ago

Hi,

I am having the same issue too. Have tried the following but not working. value_template: "{{ state_attr('image_processing.platerecognizer_front_driveway_cam', 'vehicles')['plate'] }}"
value_template: "{{ state_attr('image_processing.platerecognizer_front_driveway_cam', 'vehicles').plate }}" value_template: '{{ states.image_processing.platerecognizer_front_driveway_cam.attributes.vehicles_plate }}'

Any input is appreciated.

goedh452 commented 1 year ago

This is because the vehicles is an array. I solved it this way: {%- for i in range(0, (state_attr('image_processing.platerecognizer_camera', 'vehicles') |count) )%} {{- state_attr('image_processing.platerecognizer_camera', 'vehicles')[i].plate | upper}} {% endfor %}