jcgoette / baby_buddy_homeassistant

This custom integration provides sensors for Baby Buddy API endpoints.
MIT License
59 stars 28 forks source link

Unable to record temperature #62

Closed jampez77 closed 2 years ago

jampez77 commented 2 years ago

I keep getting this error when trying to record a temperature:

local variable 'date_time' referenced before assignment

YAML Service call:

service: babybuddy.add_temperature
data:
  temperature: 38.6
target:
  entity_id: sensor.baby_jampez77

System Info:

BB version: 2.4.1 HA Info:

Version core-2022.5.4
Installation Type Home Assistant OS
Development false
Supervisor true
Docker true
User root
Virtual Environment false
Python Version 3.9.9
Operating System Family Linux
Operating System Version 5.15.38
CPU Architecture aarch64
Timezone Europe/London
Host Operating System Home Assistant OS 8.0
Update Channel stable
Supervisor Version supervisor-2022.05.2
Docker Version 20.10.14
Disk Total 113.9 GB
Disk Used 32.9 GB
Healthy true
Supported true
Board odroid-n2
Supervisor API ok
Version API ok

Here is the full error log:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 189, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1627, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1664, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 697, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 677, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 964, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 714, in _handle_entity_call
    await result
  File "/config/custom_components/babybuddy/sensor.py", line 332, in async_add_temperature
    ATTR_TIME: date_time,
UnboundLocalError: local variable 'date_time' referenced before assignment
jcgoette commented 2 years ago

Fixed by https://github.com/jcgoette/baby_buddy_homeassistant/commit/36aab09a9632b907e27072b7fe9ecbfde2d81607. Thanks for reporting!