ChristianKuehnel / plantgateway

Bluetooth to mqtt gateway for Xiaomi Mi plant sensors
Apache License 2.0
271 stars 43 forks source link

YAML error #24

Closed freekeys closed 5 years ago

freekeys commented 6 years ago

Hi,

I’ve set this up on a RPi3 but am getting this error when I run it from terminal, even when my .plantgw.yaml file is just the template from the original repo.

Any thoughts? Thank you!

Traceback (most recent call last):
  File "/usr/local/bin/plantgateway", line 37, in <module>
    main()
  File "/usr/local/bin/plantgateway", line 24, in main
    pg = PlantGateway()
  File "/usr/local/lib/python2.7/dist-packages/plantgw/__init__.py",
line 125, in __init__
    self.config = Configuration(config_file_path)
  File "/usr/local/lib/python2.7/dist-packages/plantgw/__init__.py",
line 30, in __init__
    config = yaml.load(config_file)
  File "/usr/local/lib/python2.7/dist-packages/yaml/__init__.py", line
71, in load
    return loader.get_single_data()
  File "/usr/local/lib/python2.7/dist-packages/yaml/constructor.py",
line 37, in get_single_data
    node = self.get_single_node()
  File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line
36, in get_single_node
    document = self.compose_document()
  File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line
55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line
84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line
133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line
64, in compose_node
    if self.check_event(AliasEvent):
  File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line
98, in check_event
    self.current_event = self.state()
  File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line
449, in parse_block_mapping_value
    if not self.check_token(KeyToken, ValueToken, BlockEndToken):
  File "/usr/local/lib/python2.7/dist-packages/yaml/scanner.py", line
115, in check_token
    while self.need_more_tokens():
  File "/usr/local/lib/python2.7/dist-packages/yaml/scanner.py", line
149, in need_more_tokens
    self.stale_possible_simple_keys()
  File "/usr/local/lib/python2.7/dist-packages/yaml/scanner.py", line
289, in stale_possible_simple_keys
    "could not find expected ':'", self.get_mark())
yaml.scanner.ScannerError: while scanning a simple key
  in "/home/pi/.plantgw.yaml", line 10, column 1
could not find expected ':'
  in "/home/pi/.plantgw.yaml", line 12, column 1
ChristianKuehnel commented 5 years ago

This error message tells you, that you're missing a ":" in line 12 of your config file.

Can you please check if this really is a valid yaml file? Or post it here so that we can have a look?

ChristianKuehnel commented 5 years ago

@freekeys looking at the template, I just notices there was one ":" too much in the example MAC address. But that should not have triggered the error message above...

freekeys commented 5 years ago

Hello, thanks for the reply. I’m using exactly the template (with that MAC address typo fixed) and still getting the error... any idea what it is?

Would you mind sharing your config for me to try?

freekeys commented 5 years ago

Hello, I’ve sorted this now, it was something to do with the way the text was copying over from GitHub..

Now that I have it set up I’m getting this error, could this just be that the sensors are out of range?

could not read data from xx:xx:xx:xx:xx:xx (PlantA) with reason:
Error from Bluetooth stack (comerr)
Could not get data from 2sensor(s): PlantA, PlantB.
ChristianKuehnel commented 5 years ago

commerr looks weird, I haven't seen that issue.

Does your bluetooth dongle work properly? Do you see your sensors when you do a sudo hcitool -i hci0 lescan? It should return something like this:

LE Scan ...
C4:7C:8D:xx:xx:xx Flower mate
C4:7C:8D:yy:yy:yy Flower care

Is and other application using your Bluetooth dongle?

freekeys commented 5 years ago

Hi Christian, I’m using a Pi Zero so using the built in Bluetooth... nothing else is using it yet - am I missing some sort of setup for that do you think? I thought that would work out of the box..

freekeys commented 5 years ago

Does this help? https://github.com/IanHarvey/bluepy/issues/22

ChristianKuehnel commented 5 years ago

@freekeys hmm, that seems to be an old bug ticket from a few years ago. I'm not sure what's causing this. I also have a Pi Zero W running plantgateway, there it's working fine.

Did you try the hcitool (see my last comment)?

ChristianKuehnel commented 5 years ago

closing old ticket...