[SOLVED] First value work, second value failed

I have a temperature sensor that send its value to a raspberry in HTTP. Raspberry send the value to homeassistant (install on the same raspberry) with a curl command. Then I can ask for the value with google assistant (like “ok google what is the temperature inside bedroom ?”)

Each time a curl command is made sensor value inside homeassistant update well. But google assistant command work well only for the first update of the value. In the second update, google assistant answer that it doesn’t find the sensor.

My configuration file :

template:
  - sensor:
      - name: "temperature bedroom"
        unique_id: "temperature_bedroom_uniq_id"
        unit_of_measurement: "°C"
        state: '{{ states("sensor.temperature_bedroom") }}'
        device_class: temperature
      - name: "humidity bedroom"
        unique_id: "humidity_bedroom_uniq_id"
        unit_of_measurement: "%"
        state: '{{ states("sensor.humidity_bedroom") }}'
        device_class: humidity

google_assistant:
  project_id: myproject-83459
  service_account: !include xxxxx.json
  report_state: true
  exposed_domains:
    - sensor
  entity_config:
    sensor.temperature_bedroom:
      expose: true
      room: "bedroom"
    sensor.humidity_bedroom:
      expose: true
      room: "bedroom"

The two curl commands with return :

pi@raspberrypi:~ $ curl -k -X POST -H "Authorization: Bearer xxxx[...]xxxx" -d '{"state": "154"}' https://xxxxx.duckdns.org/api/states/sensor.temperature_bedroom
{"entity_id": "sensor.temperature_bedroom", "state": "154", "attributes": {}, "last_changed": "2023-04-04T04:50:56.152643+00:00", "last_updated": "2023-04-04T04:50:56.152643+00:00", "context": {"id": "2bd9e7a5be420489fe4d715511c86d08", "parent_id": null, "user_id": "d4e34d3f36c74ea089afb3fe36576baf"}}
pi@raspberrypi:~ $ curl -k -X POST -H "Authorization: Bearer xxxx[...]xxxx" -d '{"state": "15"}' https://xxxxx.duckdns.org/api/states/sensor.temperature_bedroom
{"entity_id": "sensor.temperature_bedroom", "state": "15", "attributes": {}, "last_changed": "2023-04-04T04:51:10.069847+00:00", "last_updated": "2023-04-04T04:51:10.069847+00:00", "context": {"id": "2da659610498171cf7b7d1afe61c94a5", "parent_id": null, "user_id": "d4e34d3f36c74ea089afb3fe36576baf"}}

Is anybody have an idea why this happen please ? I see nothing inside homeassistant log. Can I find any log in google side ?

Add1 : in configuration.yaml file I try to declare “device_class: temperature” of all my sensor inside customize section like I read in some post, but it change nothing :

homeassistant
  name: Home
  unit_system: metric
  customize:
    sensor.temperature_bedroom:
      device_class: temperature

Add2 : I didn’t notice before, but my humidity sensor doesn’t have the same issue. I can send 2 or more value, google assistant return me the new value each time I ask it (like “ok google what is the humidity inside bedroom ?”)

I find the solution : curl command need to provide ALL attributes of the sensor at each call. My curl command look like this now :

instead of

-d '{"state": "154"}'

I use

-d '{"state": "154", "attributes": {"device_class": "temperature", "friendly_name": "temperature_bedroom"}

(I think as there is no friendly_name provide by sensor configuratrion, friendly_name is automatically provide by HA)

for a configuration file like

homeassistant:
  name: Home
  unit_system: metric
      
sensor: !include sensor.yaml

google_assistant:
  project_id: xxxx
  service_account: !include xxxx-xxxx.json
  report_state: true
  exposed_domains:
    - sensor
  entity_config:
    sensor.temperature_bedroom:
      expose: true
      room: "Bedroom"
      name: "temperature bedroom"

with sensor.yaml like

- platform: template
  sensors:
    temperature_bedroom:
      value_template: '{{ state_attr("sensor.temperature_bedroom") }}'
      device_class: temperature