|
|
@@ -45,7 +45,7 @@ func WeatherReq() (string, float64, string, float64, float64, string) {
|
|
|
client := &http.Client{
|
|
|
Timeout: 20 * time.Second,
|
|
|
}
|
|
|
- lin := "https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=metric&appid=" + api
|
|
|
+ lin := "https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=metric&appid=" + api + "&lang=ru"
|
|
|
url := strings.ReplaceAll(lin, " ", "%20")
|
|
|
req, err := http.NewRequest("GET", url, nil)
|
|
|
if err != nil {
|
|
|
@@ -69,9 +69,9 @@ func WeatherReq() (string, float64, string, float64, float64, string) {
|
|
|
|
|
|
func Send(client mqtt.Client, topic string) {
|
|
|
city, temp, main, speed, feel, description := WeatherReq()
|
|
|
- payload := fmt.Sprintf("City: %s, Temperature: %.2f°C, Feel like %.2f°C\nWeather: %s, %s, Wind %.2fm/s", city, temp, feel, main, description, speed)
|
|
|
+ payload := fmt.Sprintf("Город: %s, Температура: %.2f°C, Ощущается %.2f°C\nПогода: %s, %s, Ветер %.2fm/s", city, temp, feel, main, description, speed)
|
|
|
|
|
|
- token := client.Publish(topic, 1, false, payload)
|
|
|
+ token := client.Publish(topic, 2, false, payload)
|
|
|
token.Wait()
|
|
|
if err := token.Error(); err != nil {
|
|
|
log.Fatalf("%v\n", token.Error())
|