OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › Does anyone have a working I2C LCD working? › Reply To: Does anyone have a working I2C LCD working?
RonRN18
I have finished my enclosure that includes the LCD, https://www.thingiverse.com/thing:6632131, so now I’m trying to focus on getting the display to actually work. I see that “Sirkus7” made a correction in the MQTT version of his Python code, which is line #75, which reads:
data = data.replace("\"pass\":", "\"password\":") # Replace protected keyword "pass" with acceptable term "password"
I have inserted this in between lines #45 & #46. If you were to export your OpenSprinkler settings to file, you will see that it is a JSON file and in that file, there are the MQTT server username and password. Instead of using the word “password”, it is shortened to “pass”, which is a protected word. In line 45 of “ospiLCD.py”, it basically loads that JSON into a variable called “data”. This line does a “find & replace” of the word “pass:” with the word “password:” so that it does not create the ValueError. Unfortunately, inserting that line doesn’t solve everything. I now get at TypeError.
TypeError: a bytes-like object is required, not 'str'
Despite changing the word “pass:” to “password:” something within the JSON appears as a string when it should be a “byte-like object”. I am currently at a loss as to how to fix this.