Anrolosia / Shopping-List-with-Grocy

A Shopping list integration with Grocy for Home Assistant
MIT License
41 stars 1 forks source link

How to add integration in Devices? Name Error #2

Closed renarena closed 1 year ago

renarena commented 1 year ago

What exactly have i to put into the form fields? No matter what i fill in i get an error. I used real IP addresses (192.168...) for grocy + mqtt, api key and mqtt user There is a checkbox with no name. But the integration stays red .

Logger: custom_components.shopping_list_with_grocy
Source: custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py:323
Integration: Shopping List with Grocy (documentation, issues)
First occurred: 11:13:28 (157 occurrences)
Last logged: 14:49:55

Unexpected error fetching None data: [Errno -2] Name does not resolve
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/shopping_list_with_grocy/__init__.py", line 158, in _async_update_data
    return await self.api.retrieve_data()
  File "/config/custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py", line 420, in retrieve_data
    await self.update_refreshing_status("ON")
  File "/config/custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py", line 323, in update_refreshing_status
    self.client.connect(self.mqtt_server, self.mqtt_port)
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 914, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
  File "/usr/local/lib/python3.10/socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

Logger: homeassistant.config_entries
Source: config_entries.py:807
First occurred: 14:37:07 (4 occurrences)
Last logged: 14:48:40

Config entry 'ShoppingListWithGrocy' for shopping_list_with_grocy integration not ready yet: [Errno -2] Name does not resolve; Retrying in background
Config entry 'ShoppingListWithGrocy' for shopping_list_with_grocy integration not ready yet: 'ascii' codec can't encode character '\xe4' in position 29: ordinal not in range(128); Retrying in background
Config entry 'ShoppingListWithGrocy' for shopping_list_with_grocy integration not ready yet: Cannot connect to host 192.168.1.222:102 ssl:default [Connect call failed ('192.168.1.222', 102)]; Retrying in background```

'\xe4' means ä
Anrolosia commented 1 year ago

Hello @renarena As mentioned in the documentation, if you want to use an ip with a port, you have to put https://your-ip:your-port (so in your case https://192.168.1.222:102) and uncheck the verify SSL checkbox. If the checkbox as no name, try a force refresh (Ctrl + Shift + R), it should force your frontend to refresh translations.

renarena commented 1 year ago

The unnamed checkbox is below the mqtt fields shoppinglist

Found a typo in port number

Now i get a warning, integration still red.

Logger: homeassistant.config_entries
Source: config_entries.py:1113
First occurred: 16:10:52 (3 occurrences)
Last logged: 16:26:31
Config entry 'ShoppingListWithGrocy' for shopping_list_with_grocy integration not ready yet: 192.168.1.222:9192/api/system/db-changed-time; Retrying in background
Anrolosia commented 1 year ago

Hummm, I'll check for the empty checkbox, it shouldn't be there. For your Grocy url, like mentioned above, please add https:// in front of your ip address. It has to be an url. As for your MQTT IP address, I'm surprised you're not using default value 127.0.0.1, because of what I understand here, you're using the MQTT integration from Home Assistant.... So try with 127.0.0.1. Finaly, remove the port in MQTT - IP address field, the port is set right below this field

renarena commented 1 year ago

oh, sorry, had it there before. Now i again have the [Errno -2] Name does not resolve

Anrolosia commented 1 year ago

could you try to access in a browser https://192.168.1.222:9192 ? Also, don't forget to modify the MQTT ip address

renarena commented 1 year ago

i have no https and http://192.168.1.222:9192/ is working fine

Anrolosia commented 1 year ago

Yeah, I know, you CAN'T have valid https with just an ip, especialy with a local one (192.168.x.x) BUT, this is why there is the checkbox to skip certificate SSL validation. So please, try to go to https://192.168.1.222:9192/api I pushed an update for the missing translation BTW

Anrolosia commented 1 year ago

And also, the access with local IP address was introduced and confirmed working in issue https://github.com/Anrolosia/Shopping-List-with-Grocy/issues/1#issuecomment-1363227660

renarena commented 1 year ago

Do i have to check the unnamed box or not? Is it a HA restriction for integration config not being editable?

Anrolosia commented 1 year ago

Do i have to check the unnamed box or not?

You don't, it's just if you want the entire list of your products being in the main sensor as custom attribute.

Is it a HA restriction for integration config not being editable?

Yes, it requires us to implement another flow to edit config. Not all modules have that, if in my TODO list for a future update

renarena commented 1 year ago

could you try to access in a browser https://192.168.1.222:9192/ ?

SSL_ERROR_RX_RECORD_TOO_LONG

Logger: homeassistant.config_entries
Source: config_entries.py:807
First occurred: 16:10:16 (3 occurrences)
Last logged: 17:17:27

Config entry 'ShoppingListWithGrocy' for shopping_list_with_grocy integration not ready yet: 192.168.1.222:9192/api/system/db-changed-time; Retrying in background
Config entry 'ShoppingListWithGrocy' for shopping_list_with_grocy integration not ready yet: [Errno -2] Name does not resolve; Retrying in background
Config entry 'ShoppingListWithGrocy' for shopping_list_with_grocy integration not ready yet: Cannot connect to host 192.168.1.222:9192 ssl:default [[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)]; Retrying in background
renarena commented 1 year ago

http://192.168.1.222:9192/api#/System/get_system_db_changed_time does work, with https not.

Anrolosia commented 1 year ago

This is very strange... It's working fine on my side and as mentioned previously, it was working also for #1 for SSL_ERROR_RX_RECORD_TOO_LONG, it's related to Firefox of what I can see, maybe try with another browser? Is everything up to date on your HomeAssistant, including a good configuration with MQTT (try to use MQTT explorer on windows to connect to your MQTT server), and Grocy addon? I'll try to check later and comeback with a fix

renarena commented 1 year ago

Home Assistant 2022.12.8 Supervisor 2022.11.2 Operating System 9.4 Frontend 20221213.1 - latest

MQTT Explorer is working

Chromium says ERR_SSL_PROTOCOL_ERROR

i have no https configured or used anywhere related to HA (there is a self certified Cert for proxmox)

Anrolosia commented 1 year ago

Hey @renarena , I took some time to test with the same configuration as yourself, and it's working fine. To try to help you as much as I can, this is an example of the config I used: image As you can see, it works A+ : image In your grocy module configuration in Home Assistant, be sure to uncheck the ssl option: image

renarena commented 1 year ago

you told me to use https ;-) Using 127.0.0.1 for mqtt rather then http:192.168.1.222 seems to work better. But now i get

Logger: homeassistant.components.mqtt.discovery
Source: components/mqtt/discovery.py:110
Integration: MQTT (documentation, issues)
First occurred: 27. Dezember 2022 um 17:21:38 (5 occurrences)
Last logged: 10:03:13

Received message on illegal discovery topic 'homeassistant/sensor/shopping_list_with_grocy_currysoße_tute/state/config'. The topic contains not allowed characters. For more information see https://www.home-assistant.io/docs/mqtt/discovery/#discovery-topic

seems like ß is not replaced by ss
Anrolosia commented 1 year ago

you told me to use https ;-)

As I said, "I took some time to test with the same configuration as yourself", so I tested without https to be sure it was working as expected ^^

Ok, it's great, so the integration is now working! It's just an issue with specific characters :) I'll try to see if I can find a way to sanitize that, and one I'll push the update, you should have all your products

Anrolosia commented 1 year ago

@renarena I pushed a version 0.3.0 to deal with umlauts, it should fix your issue. I also implemented a config flow and updated the documentation. Now all your products should work as expected

renarena commented 1 year ago

Thank you very much, the ability to change config is very good :-)

But still red integration:
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.shopping_list_with_grocy Source: custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py:76 Integration: Shopping List with Grocy (documentation, issues) First occurred: 17:08:43 (11 occurrences) Last logged: 17:14:04

Unexpected error fetching None data: 'ascii' codec can't encode character '\xe4' in position 29: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/shopping_list_with_grocy/__init__.py", line 160, in _async_update_data
    return await self.api.retrieve_data()
  File "/config/custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py", line 451, in retrieve_data
    await self.parse_products(final_data)
  File "/config/custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py", line 184, in parse_products
    self.encode_base64(product_picture)
  File "/config/custom_components/shopping_list_with_grocy/apis/shopping_list_with_grocy.py", line 76, in encode_base64
    message_bytes = message.encode("ascii")
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 29: ordinal not in range(128)

Maybe add a yaml snipped to documentation for excluding all the sensors from recorder.

Anrolosia commented 1 year ago

I pushed an update (v.0.3.2) to try to fix your issue. Could you give it a try once it's available on your side please?

renarena commented 1 year ago

Finally its working!

Anrolosia commented 1 year ago

Yeah!! Thank you for your patience :) Have fun with that module! Have a great day!