Your template is designed to report the value of value_json.REG_INVERTER_HOME_R_VOLTAGE_L1if it exists. In other words, if the received payload is in JSON format and contains a key named REG_INVERTER_HOME_R_VOLTAGE_L1.
If it does not exist (not defined), it will report the error message you have received.
So it’s working exactly the way you have configured it to work. The key you specified in the template wasn’t found in the received payload.
Confirm the received payload contains data in the format you expect.
What the automation does is receive payloads from alpha2mqtt/state/hour/one. If the payload contains the desired key (REG_INVERTER_HOME_R_VOLTAGE_L1) it passes it on to the MQTT sensor via alpha/one.
If the payload does not contain the key, the automation does nothing. This “filtering” technique has proven to be very robust and ensures the MQTT Sensor only receives valid information.
FWIW, there’s another method I have suggested, that doesn’t use an automation, but users who tried it have had mixed results.
EDIT 2
Correction. The automation’s MQTT Trigger creates trigger.payload_json not value_json.
Based on that error message, it appears that sometimes the received payload doesn’t even contain data in JSON format.
Rather than ask you to post several examples of the received payloads, let’s simply make the automation’s Template Condition more stringent.
alias: mqtt filter
triggers:
- trigger: mqtt
topic: alpha2mqtt/state/hour/one
conditions:
- condition: template
value_template: >
{{ trigger is defined and
trigger.payload_json is defined and
trigger.payload_json.REG_INVERTER_HOME_R_VOLTAGE_L1 is defined }}"
actions:
- action: mqtt.publish
data:
topic: alpha/one
payload: "{{ trigger.payload_json.REG_INVERTER_HOME_R_VOLTAGE_L1 }}"
If that fails to eliminate the error message then I will need to see an example of the payload that caused the error (it will be displayed in the automation’s trace).