Without ending the dialogue, could i ask furher things without the wakeword?
E.g. add some more to my shopping list?
Yes, but that requires quite some programming. Using continueSession and such.
ok. Is there a tutorial regarding this?
Have you an idea for my grocy sensor problem?
Can i use node red + homeassistant together for intent handling?
No, but you can ask around here:
Or read the docs
I do not use grocy, but I see in you grocyConsume that you use {{ product }} in your text part,
I think that should be {{ item }} , the loop over attributes looks ok.
Be aware that this: {%- if product.name == item %} does not work when item = milch, because the product.name = Milch. You can use lower for that (assuming both are strings):
{%- if product.name | lower == item | lower %}
Sure, I donât see why not
Its working now, thank you very much!!!
Now i can remove things from grocy stock by speech, which is an huge improvement instead of looking for a phone/tablet/pc and clicking-and-writing/scanning or to forget-to-subtract-it.
I forgot to change product to item in the speech line (which not caused the error).
product comes from here:
{% for product in state_attr('sensor.grocy_stock', 'products') -%}
So my errors have been (in case someone stumbles over the same ones)
- using the same name product for rhasspy slot and loop var
- using {{product}} inside {% %}.
- accessing product from outside the for loop (inserted during testing).
The case is no problem. Seems like using Milch in the item slot sends Milch, not milch. The plan is to get the products from grocy with a slot program.
Now i have to find out how to do this.
No matter what i try my variables: are always empty using them in speech or services templates. What i am doing wrong there?
The message only contains "Message: "
test:
variables:
message: "Hello World"
action:
service: notify.notify
data:
message: "{{'Message: '}}{{ message }}"
Your message is no json. Where have you put test: and what is it? How do you call it?
Below is valid data message, notice the { and } surrounding the whole message.
data:
{message: "Message: {{ message }}" }
wrong read - i corrected my text:
its in my intent_script.yaml , called via rhasspy
This doesnt work either. I tried to use a fix value for simplicity.
test:
variables:
message: "Hello World"
action:
service: notify.notify
data:
message: "Message: {{ message }}"
Plan was to calculate some values and texts for use in action: but i always get Template variable warning: 'message' is undefined when rendering 'Message: {{ message }}'
and the message contains "Message: " only.
I am not sure about syntax / indentation / needed or not allowed "- " before keys.
In hass docs i only find basic examples without variables:
variables are not supported in intent script:
So that is why the warning "warning: âmessageâ is undefined when rendering " is shown.
This
variables:
message: "Hello World"
will not work, what are you trying to achieve? What should this variable be in your goal?
I want to calculate things there to prevent doing this 3 times and simplifying templates (speech, message, service). How much i want to consume versus how much is available and how much to remove actually. Tell me, if item is out of stock nowâŚ
Maybe i actually should switch to automations (intents sounds like the ârightâ way to do this) .
Or should i use node red i have no idea how its working?
Ah ok.
So, assuming you have still this intent:
grocyConsume:
speech:
text: '{{ count }} {{ unit }} {{ product }} wird ausgetragen'
action:
service: notify.notify
data:
message: >
{% for product in state_attr('sensor.grocy_stock', 'products') -%}
{%- if product.name == item %}
{{product.id | int}}
{% endif -%}
{%- endfor %}" - {{count | int}} {{product.name}} verbraucht"
You can add an input_number helper in HA (letâs call it consume_count) and as a first action call the input_number.setvalue and use {{ count }} as value
This set the value to the amount.
For which product, you can add a text helper and fill it by using the loop in you current message part.
What you have after that is
- a helper with the amount
- a helper with the product name
The states of those helpers can be used in your notify service (and all other services/automations)
So something like:
grocyConsume:
speech:
text: '{{ count }} {{ unit }} {{ product }} wird ausgetragen'
action:
- service: input_number.set_value
target:
entity_id: input_number.consume_count
data:
value: '{{ count | int }}'
- service: notify.notify
data:
message: >
{"{{ states('input_number.consume_count') } } verbraucht" }
try to implement something like this
product:>
{%- set product = state_attr('sensor.grocy_stock', 'products')|selectattr('name','eq',item)|list|first -%}
{{- product if product is defined else false -}}
available:>
{%- if not product -%}
{{ false }}
{%- else -%}
{{ count if count|int <= product.available_amount else product.available_amount -}}
{%- endif -%}
rest:>
{% if (available and (available - count|int) > 0) %}
{{ (available - count|int)|string }}
{% else %}
{{'alle'}}
{% endif %}
message:>
{%- if product -%}
{{ count }} {{'mal'}} {{ product.name }} {{ 'wurde' ~ '' if count|int < 2 else 'n' }} {{'entsorgt' if spoiled == 'true' else 'entfernt'}}
{%- if count|int <= product.available_amount -%}
{{ product.name }} {{'ist jetzt alle' }}
{%- endif -%}
{% else %}
{{ item }} {{'ist laut grohsie alle' }}
{%- endif -%}
Will it help to rather call an script? Else i try with the helpers
Also possible, but that is up to you. There are so many wayâs to archieve thing
I did not notice that, however I am running this for longer than a year and had to make a decision back then. And I will not start recreaging everything I have in Node Red in HA now
No one suggested you change anything.
The point is Home Assistant has supported iteration (âreal loopsâ) since July 2020, about year (and 13 versions) before you stated it doesnât in July 2021.
Your assertion was incorrect and I was curious to know why. I now know itâs because your familiarity with Home Assistantâs scripting features is at least one year out of date probably because you use Node-Red instead of automations.
Yeah thats what I said, I didnt notice it.
And therefore thank you for making me aware!
Didnt feel like you wanted to tell me to change it, that was more from my head like âshould I consider to give it a try again?â But I have some really complex automations in Node Red.
Maybe I will test it again with some smaller future automations.