YAML-parser recognizes a string without " " as an array

Hi, I can’t get any further when evaluating a json_string.

mosquitto_pub -t homeassistant/payload -m '{"value":"-0.6,0.6,-0.6,3,-0.1,3,-0.1,0.6"}'

The value is not in [ ].

yaml:

action:
  - service: xiaomi_miot.set_miot_property
    data:
      entity_id: vacuum.viomi_v18_a534_robot_cleaner
      siid: 6
      piid: 2
      value: '{{trigger.payload_json.value}}'

trigger.payload_json.value is properly recognized/defined as a sting object.

result:

service: set_miot_property
service_data:
  entity_id: vacuum.viomi_v18_a534_robot_cleaner
  siid: 6
  piid: 2
  value:
    - -0.6
    - 0.6
    - -0.6
    - 3
    - -0.1
    - 3
    - -0.1
    - 0.6

If value: -0.6,0.6,-0.6,3,-0.1,3,-0.1,0.6 is entered in the yaml by hand, everything is ok.
Can this be bypassed? Greetings, Jens


value": \"-0.6,0.6,-0.6,3,-0.1,3,-0.1,0.6\" 

Try with the slashes to make it a literal.

It is the commas ,not the " " that are probably the issue though.

Many Thanks. Unfortunately that wasn’t the solution either.
I was able to narrow down the problem in the Xiaomi MIoT.

/config/custom_components/xiaomi_miot/__init__.py
    'set_miot_property': {
        'method': 'async_set_miot_property',
        'schema': XIAOMI_MIIO_SERVICE_SCHEMA.extend(
            {
                vol.Optional('did'): cv.string,
                vol.Required('siid'): int,
                vol.Required('piid'): int,
                vol.Required('value'): cv.match_all,
                vol.Optional('throw', default=False): cv.boolean,
            },
        ),
    },

cv.match_all replaced with cv.string and it works.
Greetings, Jens.

1 Like