Anyway of reading JSON from config directory in Core

Doh! I thought the command-line sensor executed in the context of the OS but I was wrong.

I’ve amended my previous post.

This seems to be the solution to my problems as well, @CentralCommand . However, I can’t get it to work (on HaOS).

In Terminal add-on, I get the following, indicating that the solution should work just fine.

[core-ssh ~]$ jq '.' /config/www/resurser/log.json
{
	"Body": {
		"I18N_COMMON_PV_DAYILY_ENERGY_GENERATION": "0.0", 
		"I18N_COMMON_PV_TOTAL_ENERGY_GENERATION": "316.8", 
		"I18N_COMMON_TOTAL_YIELD": "--", 
		"I18N_COMMON_DEVICE_STATUS": "Energy Dispatching Operation", 
		"I18N_COMMON_BUS_VOLTAGE": "634.0", 
		"I18N_COMMON_AIR_TEM_INSIDE_MACHINE": "24.1", 
		"I18N_COMMON_SQUARE_ARRAY_INSULATION_IMPEDANCE": "891", 
		"I18N_CONFIG_KEY_1001188": "100.0", 
		"I18N_COMMON_FEED_NETWORK_TOTAL_ACTIVE_POWER": "0.00", 
		"I18N_CONFIG_KEY_4060": "0.78", 
		"I18N_COMMON_DAILY_FEED_NETWORK_VOLUME": "0.0", 
		"I18N_COMMON_TOTAL_FEED_NETWORK_VOLUME": "192.8", 
		"I18N_COMMON_ENERGY_GET_FROM_GRID_DAILY": "63.7", 
		"I18N_COMMON_TOTAL_ELECTRIC_GRID_GET_POWER": "4713.0", 
		"I18N_COMMON_DAILY_FEED_NETWORK_PV": "0.0", 
		"I18N_COMMON_TOTAL_FEED_NETWORK_PV": "180.1", 
		"I18N_COMMON_LOAD_TOTAL_ACTIVE_POWER": "0.752", 
		"I18N_COMMON_DAILY_DIRECT_CONSUMPTION_ELECTRICITY_PV": "0.0", 
		"I18N_COMMON_TOTAL_DIRECT_POWER_CONSUMPTION_PV": "98.9", 
		"I18N_COMMON_TOTAL_DCPOWER": "0.00", 
		"I18N_COMMON_TOTAL_ACTIVE_POWER": "-0.02", 
		"I18N_COMMON_TOTAL_REACTIVE_POWER": "-0.01", 
		"I18N_COMMON_TOTAL_APPARENT_POWER": "0.02", 
		"I18N_COMMON_TOTAL_POWER_FACTOR": "0.937", 
		"I18N_COMMON_GRID_FREQUENCY": "50.02", 
		"I18N_COMMONUA": "235.3", 
		"I18N_COMMON_UB": "234.5", 
		"I18N_COMMON_UC": "233.1", 
		"I18N_COMMON_FRAGMENT_RUN_TYPE1": "0.4", 
		"I18N_COMMON_IB": "0.4", 
		"I18N_COMMON_IC": "0.4", 
		"I18N_COMMON_PHASE_A_BACKUP_CURRENT_QFKYGING": "0.1", 
		"I18N_COMMON_PHASE_B_BACKUP_CURRENT_ODXCTVMS": "0.1", 
		"I18N_COMMON_PHASE_C_BACKUP_CURRENT_PBSQLZIX": "0.4", 
		"I18N_COMMON_PHASE_A_BACKUP_VOLTAGE_PEIYFKXE": "--", 
		"I18N_COMMON_PHASE_B_BACKUP_VOLTAGE_MCDGYUJO": "--", 
		"I18N_COMMON_PHASE_C_BACKUP_VOLTAGE_SCJZFFCQ": "--", 
		"I18N_COMMON_BACKUP_FREQUENCY_MPPOWHDF": "--", 
		"I18N_COMMON_PHASE_A_BACKUP_POWER_BRBJDGVB": "0.000", 
		"I18N_COMMON_PHASE_B_BACKUP_POWER_OCDHLMZB": "0.000", 
		"I18N_COMMON_PHASE_C_BACKUP_POWER_HAMBBGNL": "0.000", 
		"I18N_COMMON_TOTAL_BACKUP_POWER_WLECIVPM": "0.000", 
		"I18N_COMMON_MAXIMUM_APPARENT_POWER_SIWHFGQY": "10.0", 
		"I18N_COMMON_METER_GRID_FREQ_AMMAKPKU": "50.02",
		"I18N_COMMON_REACTIVE_POWER_UPLOADED_BY_ME_KISYMRKR": 
		"-221", 
		"I18N_CONFIG_KEY_3907": "0.000", 
		"I18N_CONFIG_KEY_3921": "0.000", 
		"I18N_COMMON_BATTERY_VOLTAGE": "328.6", 
		"I18N_COMMON_BATTERY_CURRENT": "0.0", 
		"I18N_COMMON_BATTERY_TEMPERATURE": "16.5", 
		"I18N_COMMON_BATTERY_SOC": "60.0", 
		"I18N_COMMON_BATTARY_HEALTH": "100", 
		"I18N_COMMON_MAX_CHARGE_CURRENT_BMS": "30", 
		"I18N_COMMON_MAX_DISCHARGE_CURRENT_BMS": "30", 
		"I18N_COMMON_DAILY_BATTERY_CHARGE_PV": "0.0", 
		"I18N_COMMON_TOTAL_BATTERY_CHARGE_PV": "37.8", 
		"I18N_COMMON_DAILY_BATTERY_DISCHARGE": "0.0", 
		"I18N_COMMON_TOTAL_BATTRY_DISCHARGE": "45.2", 
		"I18N_COMMON_DAILY_BATTERY_CHARGE": "0.2", 
		"I18N_COMMON_TOTAL_BATTERY_CHARGE": "73.5", 
		"MPPT1": "0.0", 
		"MPPT2": "0.0", 
		"I18N_COMMON_GROUP_BUNCH_TITLE_AND%@1": "0.00", 
		"I18N_COMMON_GROUP_BUNCH_TITLE_AND%@2": "0.00", 
		"I18N_COMMON_REMAIN_BATTERY_POWER": "62.0", 
		"I18N_COMMON_TOTAL_BATTERY_DISCHARGE_BMS": "67.1",
		"I18N_COMMON_BATTERY_OPERATION_STATUS": "Run"
	}
}

In configuration.yaml I have the following code, which for some reason does not produce a sensor.

sensor:
  - platform: command_line
    name: sgjson
    scan_interval: 20
    command: 'jq ''.'' /config/www/resurser/log.json'
    value_template: "{{ value_json[0].Body }}"
    json_attributes:
      - I18N_COMMON_BATTERY_TEMPERATURE

Any ideas as to why the above does not work? I’ve tried inverting quotes: command: "jq '.' /config/www/resurser/log.json"

The following code solved the issue:

sensor:
  - platform: command_line
    name: sgjson
    scan_interval: 20
    command: 'jq ''.Body'' /config/www/resurser/log.json'
    value_template: "OK"
    json_attributes:
      - I18N_COMMON_BATTERY_TEMPERATURE