Sellect sharp edges addon (problem)

Hi!
I’ve been working on my addon for several weeks.
One of the functions of my addon is to automatically select sharp edges. To understand it better, I will describe it using the “similar” function (shift + G).
If I have three sharp edges marked on the grid (blue color), then by clicking on one sharp edge and selecting the “similar” function, all three sharp edges will light up for me.
At this point my addon marks all sharp edge n all over the object active (blue) and inactive.
I have been trying to solve this problem for several days:
How to write code so that ONLY the active (blue) sharp edge is marked.

The “simmilar” option has one drawback. For it to work, I must first select (click) one of the sharp edge.
I want addon to automatically mark active sharp edges.
Someone can help me?



I’ve got an idea. The solution would be to indicate edgy by color (cyan blue).
Can someone help me write a code such that the cyan blue edge (hex 00FFFF) is marked.

The attribute of an edge that defines whether it is sharp or not is called “smooth” which makes it hard to find in the documentation since it’s called “sharp” in the UI:
https://docs.blender.org/api/current/bmesh.types.html#bmesh.types.BMEdge.smooth

import bpy
import bmesh

ctx = bpy.context
me = ctx.object.data
bm = bmesh.from_edit_mesh(me)

# Deselect everything first so we'll only have sharp edges when done
bpy.ops.mesh.select_all(action="DESELECT")

for e in bm.edges:
    if not e.smooth:  # If it's not smooth, it's sharp
        e.select = True

bmesh.update_edit_mesh(me)  # Refresh the mesh to show new selection