Rhasspy can tell you the weather

I never had any problem with that but I also don’t use rhasspy outside of testing right now. It might be because the sentences are to similar and it can’t differentiate between them. I myself use kaldi so far so it might work better for you, or it might not.

I will do so the next time I work on the script. Right now I am solving basic linux issues and docker stuff because hassio broke my rhasspy and I always find 3 things to solve for everything that works again.

Basically the way I set it up it needs to be called from outside the project, so that is basically intended. What you can write is a parser file that is basically a function wich takes everything as a parameter that you call from your console script and puts it into a WeatherRequest. But since there is not that much parsing for console that might not be needed.

This is the first thing on github that is actually my work and not some fork of other stuff that someone wants to actually use so I have not even thought about a license but it is intended to be copied, used and so on so yes, you can assume an permissive licence.

A very initial version of my command line parser using rhasspy_weather is up and working here:

not sure that I did understand everything right in adapting my parser, so feedback is appreciated.

Also parts of the answer are still in German, so I need to see, what still needs to be translated and forwarded upstream to @Deanara

Okay, I thought I got everything but I know where the German is coming from. I take the weather description from openweathermap and I thought I got everything but the language setting is part of the URL and I missed that. I thought my test was a mix of English and German because they get the language from the country code but it is an extra setting. Will be fixed.

The only German that should still happen if everything is working like I intend it to is when detail is set to true because I did not translate that part because I plan to rewrite it completely anyway.

EDIT: I put out a quick fix for the language issue. It is not tested because I am not home but it should work for now. country_code needs to be set to something in this list. And you need to put something in the zipcode setting because otherwise it will not set the country_code. I will move that into the lang file as soon as I get to my pc.

Switching to issues on github. at least one mini pull-request for you is waiting.

My parser is already working, I have integrated it into node-red using my --json '<json-string>' option. You have though to remember to send the json enclosed in single quotation marks (via JSONata "'" & json_message & "'") to the exec node running cli_weather --json

The repo also has some English language files (sentences and slots), you can use (as well as Deanara’s supplied English language file) to run Deanara’s software in English.

Thanks @Daenara, there are still some small bugs to catch and features to implement, but it’s already a lot of fun to use! Thanks for sharing.

I was thinking about a universal connection between intentHandlers and Rhasspy without Hassio.
her you can see my Idea
Connecting command line parser to mqtt

Maybee it’s usefull

My project also focuses on this area. My solution takes a different approach from yours though.

Forum topic: A generic HTTP server for handling Intents (not completely up to date).

Github page, with latest documentation: https://github.com/Wil-Peters/HomeAutomation

Continuing the discussion from Rhasspy can tell you the weather (at least if you speak German):

I would be happy with a way to just call a script for a specific intent instead of having to call one script for everything and filter out what I want to use a script for. I can handle mqtt output, if I want that, myself and I already found a python script that uses mqtt for something else where I can copy how it is done.

… and Apple buys darksky - so all these services will stop working soon.

(This doesn’t impact @Daenara’s module, but the idea to use darksky from node-red directly as mentioned by @jrb5665.)

@Daenara

Are you interested in a dutch translation?

Also, if you want I can have a look whether I can add some test coverage to your code. That’s what I usually do during the day :wink:

A dutch translation sounds great but it needs to wait for a bit because I still need to finish one rewrite. I can maintain the german and english translation if I change anything or add to it but since I can’t speak dutch that translation would break when I do the rewrite.

Test coverage would be nice and I might even learn how to do that in more than the most basic theory. I study computer science but we didn’t learn such practical skills at all. We only learned they existed and did an example on 10 lines of python code in the very first semester and that does not help with anything.

I am having major issues with the imports in your project. When I clone the repo, by default none of the imports in rhasspy_intent.py work:

afbeelding

When I remove the rhasspy_weather from all these lines, the errors disappear, however I’m not sure it actually works.

I have similar issues when I’m trying to add a test file. I’ve added a file in the parser called test_rhasspy_intent.py.

I’m using PyCharm to do development. Any idea what’s going on here?

Not the imports again… I hate imports.

Basically the script only works if it is called from specific places. Calling it from within does not work. The part that is on github actually is the module rhasspy_weather so starting the script from inside the folder always results in that module not being found. I would fix it but so far every time I tried I either broke it or made a worse but still working chaos.

As for the parser part. There is a reason everything is imported via from … Import. For some reason just import never seems to work. I have no idea why and as far as I understand it should work but it just doesn’t. Import as sometimes works, even when import doesn’t.

There is a reason I started out with I hate imports. Nothing seems to work like I would expect.

Feel free to check out https://github.com/ulno/cli_weather it uses a fork from @Daenara as dependency - however, I pulled the newest changes from upstream and after all the changes things are completely broken now - however, maybe it can still serve as a reference how to use rhasspy_weather from outside.

The thing that most likely broke stuff was the new loading system for the config. I removed the globals file in favor of using get_config from config.py.

The only other change that could have broken stuff in your script would be pathing issues. I had to change how I get the config folder because it only worked if called a specific way and I needed to read the config from somewhere else. It worked way better than before for me so that one should not break stuff.

I did some more work today and added slot programs for most slots (location still missing, I have hope something like that will be added by rhasspy in 2.5 eventually) and I did quite a bit of work on the readme.

There now is a section detailing the project structure, what is included in the git and what not as well as a “what not to do” section that basically documents the weird behavior this script has. Both can be found under development.

I also rewrote the setup instructions and would love it if someone that has no idea how to set this up tries it and gives feedback.

Also there is a basic English translation for the sentences.ini but ulno’s is most likely better.
@ulno can I have permission to adapt yours to the new changes and include it in my readme?

Please feel free to use anything from my code/repo that you want (maybe give some credit :wink: )

I also updated my repo with the command line interpreter to work with the latest version from @Daenara. However, I am currently investigating mycroft’s weather skill and building a bridge to mycroft from rhasspy. It will use a mycroft instance that doesn’t need to be connected to the net.

Hi there, your custom weather seems awesome.
Is there any update on how to install this with Rhasspy 2.5?

I tried just following the 2.4 guide, but Im stuck because there are no more custom slot programs in the github. Are these no longer required?

I have reworked quite a bit of the project and the setup instructions are a bit out of date. I added a setup console script that generates the slot programs and automatically creates the symlinks needed. Make sure to edit the setup script because it defaults to a German profile at the moment if you want to use it. You can also just execute generate_slots.py. To get the slot programs, you need to add a ‘-x’ flag to it, otherwise it will create a slot file.

If you don’t plan on changing the contents of the language file you use on a regular basis you can just generate regular slot lists and copy them in the correct folder in your profile. That in combination with the usage of rhasspy hermes app negates the need to install rhasspy_weather inside the docker (if you use that, if you just have both installed on your system you don’t have that problem).

I also would suggest you try out the testing branch which started out as exactly what it is named but ended up being a, almost complete, rewrite. I still have some tiding up to do and, as you noticed, I need to update the documentation, but it should be feature complete by now.

There is also no need for a custom command script anymore, since 2.5 supports mqtt. Here is my current test setup for the rhasspy hermes app:

import logging
from datetime import datetime

from rhasspyhermes.nlu import NluIntent

from rhasspyhermes_app import EndSession, HermesApp

from rhasspy_weather import weather

_LOGGER = logging.getLogger("SkillListener")

app = HermesApp("SkillListener", host="redacted", port=1883, username="redacted", password="redacted")

@app.on_intent("GetWeatherForecast")
@app.on_intent("GetWeatherForecastTemperature")
@app.on_intent("GetWeatherForecastCondition")
@app.on_intent("GetWeatherForecastItem")
async def get_weather(intent: NluIntent):
    """Get weather"""
    forecast = weather.get_weather_forecast(intent, config_path="../rhasspy_weather_config.ini")
    return EndSession(forecast)

app.run()

To use the weather script with the hermesApp you need to set the output to rhasspy_tts because unlike with the command script rhasspy won’t read the text on its own.

1 Like

Hallo,
vielen Dank für das Bereitstellen. Da ich aber noch ein blutiger Anfänger bin, brauche ich doch dringend Hilfe, wie ich genau vorgehen muss.
Ich habe nun pip3 install rhasspy-hermes-app installiert. Aber jetzt fangen die Probleme an: wo und wie muss ich das hier hinkopieren:
@app.on_intent(“GetWeatherForecast”)
@app.on_intent(“GetWeatherForecastTemperature”)
@app.on_intent(“GetWeatherForecastCondition”)
@app.on_intent(“GetWeatherForecastItem”)
async def get_weather(intent: NluIntent):
“”“Get weather”""
forecast = weather.get_weather_forecast(intent, config_path=PATH_TO_RHASSPY_WEATHER_CONFIG)
return EndSession(forecast)

Ich hoffe, du kannst einem Anfänger auf die Sprünge helfen. Vielen Dank!