Sensor attributes update service

Is there a service to update sensor attributes

I have the shopping list (shopping_list) integration with Bring! installed, so far so good

Values are transferred to the app as soon as I enter them in the shopping list

Values from the APP are transferred to HA and the “list is displayed correctly”

only the associated “shoppiung_list” sensor does not get these attributes values, this only happens after I add one in HA in the shopping list.

configuration.yaml

  - platform: command_line
    scan_interval: 10
    name: Shopping List
    unique_id: sensor.shopping_list
    command: python3 /config/python_scripts/shopping_list_json.py
    json_attributes:
      - not_complete
      - content
    value_template: "{{ value_json.state }}"

Associated py script , located under → config\python_scripts\shopping_list_json.py

#!/usr/local/bin/python

# coding: utf8
import json
with open('/config/.shopping_list.json') as data_file:
   shoppingListData = json.load(data_file)
class shoppingList:
    content = u""
    not_complete = 0
    state = u""
myList = shoppingList()
myList.not_complete = 0
myList.state = ""
myList.content = ""
for entry in shoppingListData:
    if not entry['complete']:
        myList.content += u"- %s\n" % entry['name']
        myList.not_complete += 1
if myList.not_complete == 0:
    myList.state = u"empty"
else:
    myList.state = u"not_empty"
print(json.dumps(myList.__dict__))

This is what the list looks like when I transfer from the app to HA

this is what the attributes of the sensor look like after the transmission

I now add a value under HA shopping list

the sensor is completely updated and displayed correctly

does anyone have any ideas for me how to handle this.

Edit: as well if I restart home assistant, sensor will updated.

I also trey to add … init.py but nothing changed

        await self.hass.async_add_executor_job(self.save)
        self.items = await self.hass.async_add_executor_job(load)
        for itm in self.items:
            self.map_items[itm["id"]] = self.ha_to_shopping_item(itm)
        await self.sync_bring()
        await self.hass.async_add_executor_job(self.save)

    def save(self):
        """Save the items."""
        save_json(self.hass.config.path(PERSISTENCE), self.items)

seems like I’m the only one with this kind of problem, on one any idea for me