homeassistant-ssh icon indicating copy to clipboard operation
homeassistant-ssh copied to clipboard

Invalid JSON output

Open teymur1988 opened this issue 10 months ago • 2 comments

Hi there,

Thanks for the integration. I'm facing the following issue where the output from the script run on a remote server provides invalid JSON output:

alias: Test service response parsing
sequence:
  - service: ssh.execute_command
    metadata: {}
    data:
      command: /jffs/scripts/update-trustedwanips.sh
    response_variable: output
    target:
      device_id: 5ed148cba9197da009f9966b31d06d31
    enabled: true
  - service: persistent_notification.create
    metadata: {}
    data:
      message: "{{ output }}"
mode: single

The output provided:

{'results': [{'device_id': '5ed148cba9197da009f9966b31d06d31', 'device_name': 'RT-AC3200', 'success': True, 'command': '/jffs/scripts/update-trustedwanips.sh', 'stdout': ['Name: trustedwanips', 'Type: hash:net', 'Revision: 6', 'Header: family inet hashsize 32768 maxelem 65536', 'Size in memory: 372', 'References: 4', 'Number of entries: 1', 'Members:', '182.173.67.29'], 'stderr': ['update-trustedwanips.sh: Getting latest list from Home Assistant', 'update-trustedwanips.sh: Checking the difference between the two', 'update-trustedwanips.sh: Difference found!', 'update-trustedwanips.sh: Flushing the trustedwanips ipset!', 'update-trustedwanips.sh: Added IP 182.173.67.29', 'update-trustedwanips.sh: Saving trustedwanips ipset file!'], 'code': 0}]}

As you can see Github marks it as invalid.

{'results': [{'device_id': '5ed148cba9197da009f9966b31d06d31', 'device_name': 'RT-AC3200', 'success': True, 'command': '/jffs/scripts/update-trustedwanips.sh', 'stdout': ['Name: trustedwanips', 'Type: hash:net', 'Revision: 6', 'Header: family inet hashsize 32768 maxelem 65536', 'Size in memory: 372', 'References: 4', 'Number of entries: 1', 'Members:', '182.173.67.29'], 'stderr': ['update-trustedwanips.sh: Getting latest list from Home Assistant', 'update-trustedwanips.sh: Checking the difference between the two', 'update-trustedwanips.sh: Difference found!', 'update-trustedwanips.sh: Flushing the trustedwanips ipset!', 'update-trustedwanips.sh: Added IP 182.173.67.29', 'update-trustedwanips.sh: Saving trustedwanips ipset file!'], 'code': 0}]}

Could you please advise how to solve this?

teymur1988 avatar Apr 05 '24 16:04 teymur1988