twam / fritzbox2mqtt

Fritz!Box to MQTT gateway
13 stars 6 forks source link

Getting an error with example configuration #2

Closed Wallmeier closed 5 years ago

Wallmeier commented 5 years ago

Hello,

if I try to execute fritzbox2mqtt.py with the example configuration, I'm getting the following error:

 python3 fritzbox2mqtt.py -c config.yaml -v
2018-12-27 09:45:19,089 [MainThread     ] INFO   Connecting to MQTT server localhost:1883 ...
Traceback (most recent call last):
  File "fritzbox2mqtt.py", line 119, in <module>
2018-12-27 09:45:19,097 [mqttLoop       ] INFO   Connected to MQTT server localhost:1883.
    main()
  File "fritzbox2mqtt.py", line 26, in main
    run(args)
  File "fritzbox2mqtt.py", line 88, in run
    f = fritzbox.Fritzbox(config)
  File "/home/pi/fritzbox2mqtt/fritzbox.py", line 38, in __init__
    self._parseServiceConfig(fritzboxConfig.get("services", []))
  File "/home/pi/fritzbox2mqtt/fritzbox.py", line 66, in _parseServiceConfig
    if matches['id'] == None:
TypeError: '_sre.SRE_Match' object is not subscriptable

Is the example configuration not valid?

Kind regards, Nico

twam commented 5 years ago

Hi,

I'm currently not at home and can't have a look. My real configuration is

mqtt:
  address: localhost
  port: 1883
  prefix: home/flur/fritzbox

fritzbox:
  address: fritz.box
  defaultPeriod: 5
  password: top-secret

  services:
    WANCommonInterfaceConfig:
      prefix: wan
      actions:
        GetTotalBytesSent:
          values:
            NewTotalBytesSent:
              topic: totalBytesSent
              type: int
        GetTotalBytesReceived:
          values:
            NewTotalBytesReceived:
              topic: totalBytesReceived
              type: int
    WLANConfiguration:[1-3]:
      prefix: wifi{id}
      actions:
        GetTotalAssociations:
          period: 30
          values:
            NewTotalAssociations:
              topic: totalAssociations
              type: int

Maybe that already helps, otherwise I can check after #35c3 :)

Wallmeier commented 5 years ago

Hi,

even with your posted configuration I'm still getting the same error as above... Could it be possible, that the file fritzbox.py is not up to date in the repository?

Thanks for your help! Nico

twam commented 5 years ago

Which version of python you're using? I guess this might need >= 3.6

Wallmeier commented 5 years ago

After installing python 3.7 the error message disappeared :)