Wire it up in a setter.
Touched on this in answer to How to Update NodeSocketString Value inside a node group in a attribute node using python
As noted in question self.id_data is the node tree, not the node, and self is the property group. Even without being defined a property group has a name property.
Will use this to, when trying to set a value, look over the node tree first and assign any emmission shader's name to its "myaddon" pointer property name, then use this to look up what the node is.
Sounds confusing? have added a simple example and tested in py console.
import bpy
def wire_up(node_tree, nodetype):
nodes = (n for n in node_tree.nodes if n.type == nodetype)
for n in nodes:
n.myaddon.name = n.name
def update_color(self, context):
print("Updating Value")
def get_node(self):
print("Getting Value")
return self.get("color", (1.0,1.0,1.0,1.0))
def set_node(self, value):
print("Setting Value")
wire_up(self.id_data, 'EMISSION')
self['color'] = value
node = self.id_data.nodes.get(self.name)
if node:
print(node)
else:
print("Node not found")
class MyEmissionSettings(bpy.types.PropertyGroup):
color: bpy.props.FloatVectorProperty(
subtype='COLOR',
min=0.0, max=1.0, size=4,
default=(1.0,1.0,1.0,1.0),
#update=update_color,
get=get_node,
set=set_node,
)
bpy.utils.register_class(MyEmissionSettings)
bpy.types.ShaderNodeEmission.myaddon = bpy.props.PointerProperty(type=MyEmissionSettings)
Test Run
>>> mat = bpy.data.materials.new("Test")
>>> mat.use_nodes = True
>>> mat.node_tree.nodes.new("ShaderNodeEmission")
bpy.data.materials['Test'].node_tree.nodes["Emission"]
>>> mat.node_tree.nodes.new("ShaderNodeEmission")
bpy.data.materials['Test'].node_tree.nodes["Emission.001"]
>>> en1 = mat.node_tree.nodes['Emission']
>>> en2 = mat.node_tree.nodes['Emission.001']
>>> en1.myaddon.color[:]
Getting Value
(1.0, 1.0, 1.0, 1.0)
>>> en1.myaddon.color = (1, 0, 0, 1)
Setting Value
<bpy_struct, ShaderNodeEmission("Emission") at 0x7fa0bddf8c08>
>>> en1.myaddon.color[:]
Getting Value
(1.0, 0.0, 0.0, 1.0)
>>> en2.myaddon.color = (0, 0, 1, 1)
Setting Value
<bpy_struct, ShaderNodeEmission("Emission.001") at 0x7fa096f38e08>