I suggest that a json_attribute_templates:
is added that can be used the following way
- platform: mqtt
name: "Peter train from work"
state_topic: "trafikverket/peter_train_from_work"
value_template: "{{ value_json.state }}"
payload_available: "online"
payload_not_available: "offline"
json_template_attributes:
id: "{{ value_json.id }}"
canceled: "{{ value_json.canceled | bool }}"
advertised_time_at_location: "{{ value_json.advertisedTimeAtLocation | datetime }}"
estimated_time_at_location: "{{ value_json.estimatedTimeAtLocation | datetime }}"
time_at_location: "{{ value_json.timeAtLocation | datetime }}"
other_information: "{{ value_json.otherInformation }}"
deviations: "{{ value_json.deviations }}"
modified_time: "{{ value_json.modifiedTime | datetime }}"
This way you can change the field names to use the snake_case
used in Home assistant even if the mqtt json uses javascripts camelCase
standard, also fields can be converted to the right type!