elric91 / homeassistant_zigate

Custom components for Home Assistant
MIT License
22 stars 5 forks source link

Setup issue on Home-assistant 0.73 #29

Closed ChoOo7 closed 5 years ago

ChoOo7 commented 6 years ago

2018-07-11 12:26:10 ERROR (MainThread) [homeassistant.setup] Error during setup of component zigate Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/setup.py", line 143, in _async_setup_component hass, processed_config) File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro res = func(*args, **kw) File "/config/custom_components/zigate/init.py", line 65, in async_setup if platform_config['platform'] == DOMAIN: TypeError: string indices must be integers

Home Assistant version 0.73.0b3

Running on docker with command : sudo docker run -d --name="home-assistant" -v /home/pi/home-assistant/config:/config -v /etc/localtime:/etc/localtime:ro --net=host --device=/dev/ttyUSB0:/dev/ttyUSB0 homeassistant/raspberrypi3-homeassistant

# Go through config and find all addresses of zigate devices
_LOGGER.debug('ZIGATE : Finding zigate addresses')
for domain_config in config.keys():
    if domain_config in COMPONENT_TYPES:
        for platform_config in config[domain_config]:
            **if platform_config['platform'] == DOMAIN:**
                if 'address' in platform_config.keys():
                    zigate.add_known_device(str(platform_config['address'])[:6])
_LOGGER.debug('ZIGATE : All known addresses added')

Configuration file ; cat config/configuration.yaml

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 0
  longitude: 0
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 0
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: UTC
  # Customization file
  customize: !include customize.yaml

# Show links to resources in log and frontend
#introduction:

# Enable ZiGate
zigate:

# Enables the frontend
frontend:

# Enables configuration UI
config:

http:
  # Secrets are defined in the file secrets.yaml
  # api_password: !secret http_password
  # Uncomment this if you are using SSL/TLS, running in Docker container, etc.
  # base_url: example.duckdns.org:8123

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  # include_used_components: true

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Weather prediction
sensor:
  - platform: yr

# Text to speech
tts:
  - platform: google

# Cloud
cloud:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

switch:
  platform: command_line
  switches:
    manon_arest_pin_four:
      command_on: "curl 'http://192.168.0.201/dashboard.php?action=ventiloOff'"
      command_off: "curl 'http://192.168.0.201/dashboard.php?action=ventiloOff'"
      command_state: "curl 'http://192.168.0.201/dashboard.php?action=ventiloGet'"
      value_template: '{{ value == "On" }}'
      friendly_name: Manon Switch

shell_command:
  shell_manon_switch_on: "curl 'http://192.168.0.201/dashboard.php?action=ventiloOn'"
  shell_manon_switch_off: "curl 'http://192.168.0.201/dashboard.php?action=ventiloOff'"

Thanks for your help

ChoOo7 commented 6 years ago

I have added the following debug :

# Go through config and find all addresses of zigate devices
_LOGGER.debug('ZIGATE : Finding zigate addresses')
for domain_config in config.keys():
    if domain_config in COMPONENT_TYPES:
        for platform_config in config[domain_config]:
            _LOGGER.debug('mon debug')
            _LOGGER.debug(platform_config)
            if platform_config['platform'] == DOMAIN:
                if 'address' in platform_config.keys():
                    zigate.add_known_device(str(platform_config['address'])[:6])
_LOGGER.debug('ZIGATE : All known addresses added')

2018-07-11 12:50:16 DEBUG (MainThread) [custom_components.zigate] mon debug 2018-07-11 12:50:16 DEBUG (MainThread) [custom_components.zigate] OrderedDict([('platform', 'yr')]) 2018-07-11 12:50:16 DEBUG (MainThread) [custom_components.zigate] mon debug 2018-07-11 12:50:16 DEBUG (MainThread) [custom_components.zigate] platform 2018-07-11 12:50:16 ERROR (MainThread) [homeassistant.setup] Error during setup of component zigate Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/setup.py", line 143, in _async_setup_component hass, processed_config) File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro res = func(*args, **kw) File "/config/custom_components/zigate/init.py", line 67, in async_setup if platform_config['platform'] == DOMAIN: TypeError: string indices must be integers

ChoOo7 commented 6 years ago

A possible fix : if ( not isinstance(platform_config, str) ) and platform_config['platform'] == DOMAIN: