hello!
I'm currently trying to do this in HA but it does not seem to support this (short of an integration).
Here's what I like to do. I have another machine that does AI including image generation based on prompts. It works via curl request. I originally had it set up as a rest sensor in Home Asissistant (see below), that sends the request to the LocalAI machine, and returns a value for the sensor, being where the image URL is located. I then point an image card to that sensor and it shows the picture on my HA dashboard BUT I later learned that it was not actually passing through the template sensor values. For example, below in the "prompt" field, there are few sensors that show this template {{ states('sensor.humidex_perception') }}
, which is basically a string value for the sensor state. This should become part of the prompt as a string when it reaches the LocalAI machine
#LocalAI Image Generations
- platform: rest
name: "Image URL Sensor"
unique_id: [id]
resource: http://192.168.1.195:8080/v1/images/generations
method: POST
scan_interval: 43200
timeout: 120
headers:
Content-Type: application/json
payload: >
{
"prompt": "magnificent scenery, wide landscape, sharp and crisp background, very beautiful landscape, fantasy, birdview, best quality, masterpiece, ultra high res, dark blue light, photo, photorealistic, wide view, kkw-ph1, professional shot of house, {{ state_attr('weather.forecast_home', 'forecast')[0].condition }} day, humidity perception is {{ states('sensor.humidex_perception') }}, thermal perception is {{ states('sensor.thermalperception') }}, extreme low-angle shot, realistic photography, ultra detailedmagnificent scenery, wide landscape, sharp and crisp background, very beautiful landscape, old ruins buildings, fantasy, birdview, best quality, masterpiece, ultra high res, dark blue light, cloudy, photo, photorealistic, wide viewl",
"size": "512x512",
"model": "landscape-photoreal"
}
value_template: "{{ value_json.data[0].url }}"
it was passing all those template sensors as templates.
Is this something that I can solve in NodeRed?
thank you!