KeyError: 'openHAB' - cannot create sensor #99
Replies: 2 comments 1 reply
-
There should be a log line just before the error that starts with "Creating device for ". What's that line say? Did the openHAB Connection get created before this error? The error indicates it didn't but you didn't post the full logs. I can't imagine where the "Sensor2" part is coming from. Are you sure that the .ini file doesn't have a section? The code that creates the sensors just loops through all the sections that start with "Sensor". It doesn't one up the numbers or anything like that. So if you had a
|
Beta Was this translation helpful? Give feedback.
-
Hi Richard:
Thanks for responding, appreciate it. The openHAB Connection did not
get created. I agree that it felt like the config file was not being
correct read, but it was clearly being saved as I could go back to it
after closing the editor.
I finally gave up on openHAB (not just because of the sensor package,
but for other reasons), so I cannot go back and grab the full logs. I
have been playing wiht Home Assistant which seems more roubust although
it too is not without issues.
What I really wonder is how long it will take for either application to
adopt matter over thread? Seems like this will go a long way to
improving hub performance and simplicity, and covering more devices.
thx - Elliot
…On 8/1/2022 2:29 PM, Richard Koshak wrote:
There should be a log line just before the error that starts with
"Creating device for ". What's that line say?
Did the openHAB Connection get created before this error? The error
indicates it didn't but you didn't post the full logs.
I can't imagine where the "Sensor2" part is coming from. Are you sure
that the .ini file doesn't have a section? The code that creates the
sensors just loops through all the sections that start with "Sensor".
It doesn't one up the numbers or anything like that. So if you had a
|Sensor99| section in there, it would appear in the logs as
|Sensor99|, so it has to be seeing a |Sensor2| section somewhere which
implies:
* this isn't the .ini file actually being loaded
* you removed the section but didn't save
* there's something wrong with your SD card and changes are not
being saved.
—
Reply to this email directly, view it on GitHub
<#99 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOS4QFXHAPRTEDFFTKWPT4TVXAJSLANCNFSM543PQFIA>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Trying to run a test for reading Hi/Low on raspberry GPIO pins by using one of the examples configuration files, sensor_reporter.py is throwing the error below. Note that openHAB is running and that RPI.GPIO has been loaded. I also don't understand why the error says " Error creating device Sensor2:" when only Sensor1 is defined in the ini file. (There was a Sensor2 defined in an earlier config file.) Appreciate any/all help.
openhabian python3[5738]: 2022-07-27 20:23:20,658 ERROR - [sensor_reporter] Error creating device Sensor2: Traceback (most recent call last):
openhabian python3[]: File "/opt/sensor_reporter/sensor_reporter.py", line 168, in create_device
openhabian python3[]: dev_conns = [connections[c] for c in params("Connection").split(",")]
openhabian python3[]: File "/opt/sensor_reporter/sensor_reporter.py", line 168, in
openhabian python3[]: dev_conns = [connections[c] for c in params("Connection").split(",")]
openhabian python3[]: KeyError: 'openHAB'
openhabian python3[]: 2022-07-27 20:23:20,659 DEBUG - [sensor_reporter] 0 sensors created
openhabian python3[]: 2022-07-27 20:23:20,660 DEBUG - [sensor_reporter] Creating polling manager
openhabian python3[]: 2022-07-27 20:23:20,662 DEBUG - [sensor_reporter] Created, returning polling manager
openhabian python3[]: 2022-07-27 20:23:20,663 INFO - [ PollManager] Starting polling loopopenhabian python3[]:
2022-07-27 17:49:38,739 DEBUG - [sensor_reporter] Created, returning polling manager
openhabian python3[]: 2022-07-27 17:49:38,741 INFO - [ PollManager] Starting polling loop
the sensor_reporter.ini file is:
`[Connection1]
Class = openhab_rest.rest_conn.OpenhabREST
Name = openHAB
URL = http://localhost:8080
RefreshItem = Test_Refresh
[Sensor1]
Class = gpio.rpi_gpio.RpiGpioSensor
Connection = openHAB
Pin = 17
PUD = UP
EventDetection = BOTH
Destination = back_door
Short_Press-Dest = back_door_short
Long_Press-Dest = back_door_long
Long_Press-Threshold = 1.2
[Logging]
File = /var/log/sensor_reporter/sensor_reporter.log
MaxSize = 67108864
NumFiles = 10
Syslog = NO
Level = DEBUG`
the section of code that is failing is
159 try:
160 logger.info("Creating device for {}".format(section))
161 class_ = config.get(section, "Class")
162 module_name, class_name = class_.rsplit(".", 1)
163 device = getattr(importlib.import_module(module_name), class_name)
164 params = lambda key: config.get(section, key)
165
166 dev_conns = []
167 try:
168 dev_conns = [connections[c] for c in params("Connection").split(",")]
Beta Was this translation helpful? Give feedback.
All reactions