acon96 / home-llm

A Home Assistant integration & Model to control your smart home using a Local LLM
483 stars 56 forks source link

Area Context for AI #134

Open Portagoras opened 2 months ago

Portagoras commented 2 months ago

Please describe what you are trying to do with the component
It would be great for the AI to have a context of where entities are. For that there are several things in HomeAssistant.

Describe the solution you'd like
A good start would be to just provide the Area property of entities to the AI.

Additional context
https://www.home-assistant.io/docs/organizing/areas/

ther3zz commented 1 month ago

I agree the integration should pass that information over to the model. I figured this would have been passed by the special {{ devices }} variable used by the integration

acon96 commented 3 weeks ago

v0.3.1 has basic support for exposing area information about devices. It is passed as the area_id property in the devices property now.

ther3zz commented 3 weeks ago

@acon96 it seems that the default prompt is not properly listing an entity in the appropriate area if that entity is part of a device and you have the "Use device area" setting enabled.

For example: image

That being said, if you manually configure the area for the entity to the same area as the device manually, then it works properly. Example: image

acon96 commented 2 weeks ago

In v0.3.3 it should be pulling the device's area first and then the entity's area as a fallback

ther3zz commented 1 week ago

In v0.3.3 it should be pulling the device's area first and then the entity's area as a fallback

Just a heads up, it looks like this is still not the case on 0.3.3 As an example: image

Here is what was passed (removed some things so it's not a crazy long list):

"You are 'Al', a helpful AI Assistant that controls the devices in a house. Complete the following task as instructed with the information provided only.
Your responses will be limited to 3 sentences maximum.
Tools: [{"type":"function","function":{"name":"HassTurnOn","description":"Turns on/opens a device or entity","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""}},"required":[]}}},{"type":"function","function":{"name":"HassTurnOff","description":"Turns off/closes a device or entity","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""}},"required":[]}}},{"type":"function","function":{"name":"HassLightSet","description":"Sets the brightness or color of a light","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""},"color":{"type":"string","description":""},"temperature":{"type":"integer","description":""},"brightness":{"type":"integer","description":""}},"required":[]}}},{"type":"function","function":{"name":"MassPlayMediaOnMediaPlayer","description":"Execute Home Assistant MassPlayMediaOnMediaPlayer intent","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"query":{"type":"string","description":""},"artist":{"type":"string","description":""},"track":{"type":"string","description":""},"album":{"type":"string","description":""}},"required":[]}}},{"type":"function","function":{"name":"HassMediaUnpause","description":"Resumes a media player","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""}},"required":[]}}},{"type":"function","function":{"name":"HassMediaPause","description":"Pauses a media player","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""}},"required":[]}}},{"type":"function","function":{"name":"HassMediaNext","description":"Skips a media player to the next item","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""}},"required":[]}}},{"type":"function","function":{"name":"HassSetVolume","description":"Sets the volume of a media player","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""},"volume_level":{"type":"integer","description":""}},"required":["volume_level"]}}},{"type":"function","function":{"name":"HassHumidifierSetpoint","description":"Set desired humidity level","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"humidity":{"type":"integer","description":""}},"required":["name","humidity"]}}},{"type":"function","function":{"name":"HassHumidifierMode","description":"Set humidifier mode","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"mode":{"type":"string","description":""}},"required":["name","mode"]}}},{"type":"function","function":{"name":"HassVacuumStart","description":"Starts a vacuum","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""}},"required":[]}}},{"type":"function","function":{"name":"HassVacuumReturnToBase","description":"Returns a vacuum to base","parameters":{"type":"object","properties":{"name":{"type":"string","description":""},"area":{"type":"string","description":""},"floor":{"type":"string","description":""},"domain":{"type":"string","description":""},"device_class":{"type":"string","description":""}},"required":[]}}}]
Devices:

sensor.time_2 'Current Time' = 17:36

sensor.date_2 'Current Date' = 2024-06-26

media_player.office_onju_2a44d8 'Office Onju 2a44d8 ' = unavailable

media_player.bathroom_speaker_2 'Bathroom Speaker' = unavailable

climate.thermostat 'Thermostat' = cool;74F;on

sensor.office_temperature 'Office Sensor Temperature' = 78.9 °F

sensor.master_temperature 'Master Bedroom Sensor Temperature' = 72.9 °F

sensor.kids_room_temperature 'Isabelle's Temp Sensor Temperature' = 73.9 °F

sensor.thermostat_temperature 'Thermostat Temperature' = 72.8 °F

sensor.thermostat_humidity 'Thermostat Humidity' = 54 %

sensor.living_room_temperature 'Living Room Sensor Temperature' = 72.9 °F

light.office_ztrip_1 'Office Ztrip 1' = on;100%

light.ofcz 'Office Ztrip 2' = on;100%

weather.home 'Forecast Home' = rainy;87F;66%;8.08

switch.3d_printer_air_filtration '3D Printer Air Filtration' = off

switch.3d_printer_prusamk3s_bear '3D Printer - PrusaMK3S Bear' = off

switch.3d_printer_raspberry_pi 'OctoPrint' = off

switch.kitchen_light 'Front Patio Light' = off

switch.garage_fridge 'Garage Fridge' = on

switch.dining_room 'Driveway Lights' = off

binary_sensor.front_door 'Front Door' = off

binary_sensor.sliding_glass_door_1 'Sliding Glass Door 1' = off

binary_sensor.sliding_glass_door_2 'Sliding Glass Door 2' = off

binary_sensor.laundry_room_window 'Laundry Room Window' = off

binary_sensor.front_window_1 'Front Window 1' = off

light.living_room_tv_backlights 'Living Room TV Backlights' = off

light.lanai_string_lights 'Lanai String Lights' = off

switch.backyard 'Backyard' = off

switch.front_yard 'Front Yard' = off

switch.rain_bird_sprinkler_4 'Rain Bird Sprinkler 4' = off

fan.dehumidifier_fan 'Dehumidifier Fan' = off

humidifier.dehumidifier 'Dehumidifier' = off;50%

sensor.dehumidifier_humidity 'Dehumidifier Humidity' = 59 %

sensor.dehumidifier_temperature 'Dehumidifier Temperature' = 73.4 °F

switch.dehumidifier_beep 'Dehumidifier Beep' = off

light.on_air_sign 'On Air Sign' = unavailable

switch.office_onju_2a44d8_use_wake_word 'Office Onju 2a44d8 Use Wake Word' = on

sensor.particulate_matter_2_5um_concentration_3 'Particulate Matter 2.5µm Concentration' = 14 µg/m³

sensor.ccs811_eco2_value_2 'CCS811 eCO2 Value' = 749 ppm

sensor.ccs811_total_volatile_organic_compound_2 'CCS811 Total Volatile Organic Compound' = 53 ppb

sensor.office_multisensor_air_temperature 'Office Multisensor Air temperature' = 75.8 °F

sensor.office_multisensor_humidity 'Office Multisensor Humidity' = 57.0 %

sensor.ac_leak_sensor_air_temperature 'AC Leak Sensor Air temperature' = 72.75 °F

script.turn_on_office_lights 'Turn on office lights' = off

light.kitchen_fixture 'Kitchen Fixture' = on;100%

sensor.3d_printing_enclosure_temperature '3D Printing Enclosure Temperature' = 76.78 °F;24C;50.18%

sensor.3d_printing_enclosure_humidity '3D Printing Enclosure Humidity' = 50.18 %;24C;50.18%

sensor.weather_station_uv 'Weather Station-uv' = 7 UV Index

vacuum.valetudo_similarredleopard 'Valetudo L10S Ultra SimilarRedLeopard Robot' = docked

switch.consuelo_enable_schedule 'Consuelo Enable schedule' = unavailable

switch.arcade_machine 'Arcade Machine' = unavailable

switch.bear_mk3s 'None' = unavailable

switch.kid_christmas_tree 'Kid Christmas Tree' = unavailable

switch.pc 'PC' = unavailable

sensor.particulate_matter_2_5um_concentration 'Particulate Matter 2.5µm Concentration' = unavailable µg/m³

sensor.particulate_matter_2_5um_concentration_2 'Particulate Matter 2.5µm Concentration' = unavailable µg/m³

sensor.ccs811_eco2_value_3 'CCS811 eCO2 Value' = unavailable ppm

sensor.ccs811_total_volatile_organic_compound_3 'CCS811 Total Volatile Organic Compound' = unavailable ppb

climate.office_ac 'Office AC' = unavailable

switch.office_ac_beep 'Office AC Beep' = unavailable

sensor.office_ac_outdoor_temperature 'Office AC Outdoor Temperature' = unavailable °F

switch.office_dry_mode 'Office Dry Mode' = unavailable

switch.adult_christmas_tree 'Adult Christmas Tree' = unavailable

switch.server_rack 'None' = unavailable

climate.dehumidifier 'Dehumidifier' = unavailable

sensor.dehumidifier_outdoor_temperature 'Dehumidifier Outdoor Temperature' = unavailable °F

media_player.shield_3 'None' = unavailable

media_player.living_room_shield_2 'None' = unavailable

## Area: Backyard

sensor.weather_station_wind_mph 'Wind Speed Miles per Hour' = 1.1 mph;

sensor.weather_station_gust_mph 'Wind Gust MPH' = 1.6 mph;

sensor.wind_dir_abbrev 'Wind Direction' = East-Northeast;

sensor.rainfall_in_daily 'Rainfall Today Inches' = 0.17 in;

sensor.weather_station_h 'Weather Station-Humidity' = 93.0 %;

sensor.weather_station_t 'Weather Station-Temperature' = 78.1 °F;

## Area: Office

light.nanoleaf 'Nanoleaf Light Panels 59:da:6b' = off;

Turn off the fan.dehumidifier_fan
Switching off the fan as requested.
<functioncall> {"name":"HassTurnOff","arguments":{"name":"fan.dehumidifier_fan"}}

Start the vacuum called vacuum.valetudo_similarredleopard
Starting the vacuum now.
<functioncall> {"name":"HassVacuumStart","arguments":{"name":"vacuum.valetudo_similarredleopard"}}"

light.office_ztrip_1 should be listed in the Office area but it is not listed there. The nano leaf device currently shown there I had to manually set the area and the device area was not used.