Funhouse wt Home Assistant

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
lubarb
 
Posts: 8
Joined: Wed Apr 04, 2018 8:54 pm

Re: Funhouse wt Home Assistant

Post by lubarb »

TWDM,

My code to set up the client is:

Code: Select all

mqtt_client = MQTT.MQTT(
    broker=secrets["mqtt_broker"],
    port=secrets["mqtt_port"],
    username=secrets["mqtt_username"],
    password=secrets["mqtt_password"],
    socket_pool=pool,
    ssl_context=ssl.create_default_context(),
)
I'm using 'MQTT.MQTT(' where you have just 'MQTT('.

I don't know if there's something else different in our earlier import/setup code, but this could be related to your problem.

User avatar
TWDM
 
Posts: 53
Joined: Sat Sep 05, 2015 9:07 am

Re: Funhouse wt Home Assistant

Post by TWDM »

Bingo!
Thanks

User avatar
rbihler
 
Posts: 13
Joined: Sat Jan 24, 2015 10:29 pm

Re: Funhouse wt Home Assistant

Post by rbihler »

Procedure problems.

I had fun house reporting to HA without an issue. As I wanted a more accurate temp I started to add in the TMP235 module as suggested.
I had the test code working just file and reporting temps.
The only change I made on the system was replacing the Code.py file.

I renamed the working Code.py file I had for HA so it would run off this again and I was not able to get back to where I was before. It would start the file and then do a soft reboot. Over and over again. No changes to the file.
Thinking I corrupted the files system I deleted all files from FH and copied them back over from a backup on the PC. Still same issue and now it would just soft reboot didnt look to even load. Using MU showed nothing other the soft reboot message. Removed the TMP as well thinking maybe too much load. No joy or change.

I even want back and copied the original HA zip files back onto the FH keeping my secrets file and nothing better. It would not even try the code.

At this point all I could figure to do is reflash with the current Bin code. This responded just fine, so I load the UF2 file on FH. So far so good. Originally I used the factory BIN code that with FH last month (adabox).

Tried to copy the HA files onto the system and again, now I get a new error at least it is trying.

code.py output:
Warning: Glyph clipped, exceeds descent property: "p"
Warning: Glyph clipped, exceeds descent property: "p"
Warning: Glyph clipped, exceeds descent property: "y"
Warning: Glyph clipped, exceeds descent property: "y"
Connecting to AP Netgear07
Attempting to connect to 192.168.1.21
Traceback (most recent call last):
File "code.py", line 143, in <module>
File "adafruit_funhouse/network.py", line 143, in mqtt_connect
File "adafruit_minimqtt/adafruit_minimqtt.py", line 441, in connect
File "adafruit_minimqtt/adafruit_minimqtt.py", line 227, in _get_connect_socket
RuntimeError: Port must be an integer

Code done running.


The only file from the previous working system was my secrets file and this didn't change.
secrets = {
'ssid' : 'Netgear07',
'password' : '***',
'openweather_token' : '****',
'aio_username' : '****',
'aio_key' : '****',
'latitude' : '39.6082389',
'longitude' : '-104.7457797',
'mqtt_broker': '192.168.1.21',
'mqtt_port': '1883',
'mqtt_username': '****',
'mqtt_password': '****',
}

I like CircuitPy but I must be doing something in my process to mess it up. It seems when I make more than a handful of changes from MU I run into issues. Win10 machine, could it be doing something to the file structure.

What should me next steps be? Should I update the libraries with the current python libs as I redid the BIN file? It ran before right from the Zip file?

Any suggestion would be helpful, Other projects I have done in Py tend to have similair issues over time and I end up reloading everything. MagTag was as frustrating but I did get that running.

Lastly I don't normally have these type of issues in Arduino code, Can all this be done in Arduino? This just seems so easy to code and run.

Ron

User avatar
rbihler
 
Posts: 13
Joined: Sat Jan 24, 2015 10:29 pm

Re: Funhouse wt Home Assistant

Post by rbihler »

I just updated all the libaries on the FH with the current release and am still getting this problem.

What is the right way to reset this to properly try again.
I am using the sample code and my secrets file that was working just fine before.

Ron

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: Funhouse wt Home Assistant

Post by jerryn »

get rid of the quotes around the port number

Code: Select all

'mqtt_port': '1883',
just use

Code: Select all

'mqtt_port': 1883,
same for the lat/lon
they are numbers, not strings

User avatar
rbihler
 
Posts: 13
Joined: Sat Jan 24, 2015 10:29 pm

Re: Funhouse wt Home Assistant

Post by rbihler »

That was it, I had figured this out once before but when I reloaded I defaulted back to the old Secrets file. I guess in my frustration that was forgotten as I had saved the files.
Fixing that now.
Thank you.

Bigger question, somehow the system was corrupted making a few changes to the code in MU. Should I not copy files manual on the driver or anything else that I am doing to corrupt the files?
It would not give an error just restart over and over. This is not the first time I have messed the system up and had to reload. I just figure Win10 is doing something or I am not knowingly.

Ron

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: Funhouse wt Home Assistant

Post by jerryn »

I am not a Windows or Mu user so it's hard for me to comment -- Hopefully others will have suggestions.

In general, file system corruption occurs if the Has )S has not full written the files to the board before it gets Reset.
I try to be very patient on resetting the board after copying file san on a linux system I issue a "sync" command manually after copying anything to the board. When copying code.py to the boards, it automatically resets and sometime I have had problems with errors. Usually another RESET seems to help.
The bottom line for me is -- don't ever assume the board will reboot without corrupting the file system -- keep a backup on your host system and be patient when copying files.

That's just my experience, not official support ;-)

User avatar
rbihler
 
Posts: 13
Joined: Sat Jan 24, 2015 10:29 pm

Re: Funhouse wt Home Assistant

Post by rbihler »

Thanks,
This is good information, I will be very careful on saves and make sure they are done.

I had it working great. Saved this working version, added in a TMP235 all was great. HA is getting the new data it's looking up. Not even an hour later it is again failing,

code.py output:
Warning: Glyph clipped, exceeds descent property: "p"
Warning: Glyph clipped, exceeds descent property: "p"
Warning: Glyph clipped, exceeds descent property: "y"
Warning: Glyph clipped, exceeds descent property: "y"
Connecting to AP Netgear07

Code stopped by auto-reload.
soft reboot

I though the TMP235 was an issue so I disconnected and reloaded the proven working version. Let it save and turned the unit off/on. Uggh still a soft reboot.

As I am not getting a fail message I am not sure of a process to troubleshoot. This happened without saving or anything else that I did unless Win did something. I did leave it plugged in.

Tomorrow I will reload python and the working code and see what happens. Assuming it runs again.

Ron

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: Funhouse wt Home Assistant

Post by jerryn »

Try disconnecting from Windows. There will be a soft reboot anytime the Windows computer accesses the CIRCUITPY drive. I f I recall correctly, some Widows anti-virus or similar software can cause issues like this.
Good luck!

User avatar
rbihler
 
Posts: 13
Joined: Sat Jan 24, 2015 10:29 pm

Re: Funhouse wt Home Assistant

Post by rbihler »

That was it, I will let it run for awhile and see.
Now to look into the antivirus and how to disable.

Alternately, I will looking to a Linux system for using this.

Thank you
Ron

User avatar
rbihler
 
Posts: 13
Joined: Sat Jan 24, 2015 10:29 pm

Re: Funhouse wt Home Assistant

Post by rbihler »

Now that the system seems to work, Thank again removing from the PC made all the difference.

I am reading a TMP235 temp sensor.
This is not accurate, one pass it will read 3-4 deg higher and then the second pass it will go back to what I would expect. I am using this device as the onboard temp sensor is not correct. This is closer but not reliable at all.

I found a discussion using this sensor with Circuit Python. My question does the boarded version of the sensor have the cap and resistor already included? I went this way thinking it would be plug and play.

https://learn.adafruit.com/tmp36-temper ... cuitpython in regards to the raw TMP36.
Note: The simple circuit below has been found to give incorrect readings with CircuitPython because of the speed at which CircuitPython reads the analog value. To fix this problem, add a 0.01uF or 0.1uF capacitor and a 47k resistor across the output and ground pins of the TMP36. We will revise the diagram later.

Otherwise I am not sure why the reading bounce to much.

Thanks
Ron

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: Funhouse wt Home Assistant

Post by jerryn »

FYI - I connected a tmp235 to my funhouse and I get some fluctuation , but not nearly as much as you describe
```
Adafruit CircuitPython 7.0.0-alpha.2-584-g25a44cb77 on 2021-05-16; Adafruit FunHouse with ESP32S2
>>>
>>> import funhouse_tmp235

Code: Select all

tmp235 24.4987
tmp235 24.4987
tmp235 24.398
tmp235 23.6981
tmp235 23.9952
tmp235 24.7958
tmp235 24.6951
tmp235 24.1966
tmp235 24.5944
tmp235 24.6951
tmp235 24.6951
tmp235 24.5944
tmp235 24.9972
tmp235 23.9952
tmp235 24.9972
tmp235 25.0979
tmp235 24.6951
tmp235 24.2973
tmp235 24.4987
tmp235 25.0979

This is my modified version of the demo to read the Anlog inputs and to convert the A1 input from the tmp235

Code: Select all

# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) 2021 Melissa LeBlanc-Williams for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
import board
from digitalio import DigitalInOut, Direction, Pull
from adafruit_funhouse import FunHouse
import analogio

funhouse = FunHouse(
    default_bg=0x0F0F00,
    scale=2,
)

funhouse.peripherals.set_dotstars(0x800000, 0x808000, 0x008000, 0x000080, 0x800080)

# sensor setup
sensors = []
for p in (board.A0, board.A1, board.A2):
    sensor = analogio.AnalogIn(p)
    sensors.append(sensor)


def set_label_color(conditional, index, on_color):
    if conditional:
        funhouse.set_text_color(on_color, index)
    else:
        funhouse.set_text_color(0x606060, index)


# Create the labels
funhouse.display.show(None)
slider_label = funhouse.add_text(
    text="Slider:", text_position=(50, 30), text_color=0x606060
)
capright_label = funhouse.add_text(
    text="Touch", text_position=(85, 10), text_color=0x606060
)
pir_label = funhouse.add_text(text="PIR", text_position=(60, 10), text_color=0x606060)
capleft_label = funhouse.add_text(
    text="Touch", text_position=(25, 10), text_color=0x606060
)
onoff_label = funhouse.add_text(text="OFF", text_position=(10, 25), text_color=0x606060)
up_label = funhouse.add_text(text="UP", text_position=(10, 10), text_color=0x606060)
sel_label = funhouse.add_text(text="SEL", text_position=(10, 60), text_color=0x606060)
down_label = funhouse.add_text(
    text="DOWN", text_position=(10, 100), text_color=0x606060
)
jst1_label = funhouse.add_text(
    text="SENSOR 1", text_position=(40, 80), text_color=0x606060
)
jst2_label = funhouse.add_text(
    text="SENSOR 2", text_position=(40, 95), text_color=0x606060
)
jst3_label = funhouse.add_text(
    text="SENSOR 3", text_position=(40, 110), text_color=0x606060
)
temp_label = funhouse.add_text(
    text="Temp:", text_position=(50, 45), text_color=0xFF00FF
)
pres_label = funhouse.add_text(
    text="Pres:", text_position=(50, 60), text_color=0xFF00FF
)
funhouse.display.show(funhouse.splash)

while True:
    funhouse.set_text("Temp %0.1F" % funhouse.peripherals.temperature, temp_label)
    funhouse.set_text("Pres %d" % funhouse.peripherals.pressure, pres_label)

    #print(funhouse.peripherals.temperature, funhouse.peripherals.relative_humidity)
    set_label_color(funhouse.peripherals.captouch6, onoff_label, 0x00FF00)
    set_label_color(funhouse.peripherals.captouch7, capleft_label, 0x00FF00)
    set_label_color(funhouse.peripherals.captouch8, capright_label, 0x00FF00)

    slider = funhouse.peripherals.slider
    if slider is not None:
        funhouse.peripherals.dotstars.brightness = slider
        funhouse.set_text("Slider: %1.1f" % slider, slider_label)
    set_label_color(slider is not None, slider_label, 0xFFFF00)

    set_label_color(funhouse.peripherals.button_up, up_label, 0xFF0000)
    set_label_color(funhouse.peripherals.button_sel, sel_label, 0xFFFF00)
    set_label_color(funhouse.peripherals.button_down, down_label, 0x00FF00)

    set_label_color(funhouse.peripherals.pir_sensor, pir_label, 0xFF0000)
    atemp = (((sensors[1].value * 3.3 * 1000) / 65536) - 500.) /10.
    print("tmp235", atemp)
    funhouse.set_text("tmp235 %0.1f" % atemp, jst2_label)
    set_label_color(sensors[0].value, jst1_label, 0xFFFFFF)
    set_label_color(sensors[1].value, jst2_label, 0xFFFFFF)
    set_label_color(sensors[2].value, jst3_label, 0xFFFFFF)


User avatar
rbihler
 
Posts: 13
Joined: Sat Jan 24, 2015 10:29 pm

Re: Funhouse wt Home Assistant

Post by rbihler »

Thanks,
I took some of your code just to confirm and I am getting pretty close to your variation. You are bouncing a little over 1.2 deg C, I am displaying in F so for me to see 2 to 3 deg change would not be out of the question.

Is there an I2c temp sensor that is more consistent? I am replacing an Arduino system using a DHT and monitoring freeze conditions in a detached garage. I can build in several degree's of historisis to keep it from constantly notifying me of a freeze. But that seems a little counter intuitive as the purpose was to notify me if condition go below 30 Deg F.
It must be in the Analog port routines in python causing the issues as the TMP235 should be more accurate than a DHT. The DHT only bounce about .2 deg F at most.

On the other issue of soft reboot, thank you for directing me to a windows issue after researching further it seems to be Acronis backup per other discussions.

I just turned off auto restart and the system is working great. It would have been nice is this issue was set as a sticky in the forum. When I looked for acronis i found more details, but under soft reboot the information was much less helpful and where I had started. I wasted so much time with this issue and figured it had to be a system thing.

Thank you everyone on the forum, My fun house is getting very close.

Ron

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: Funhouse wt Home Assistant

Post by jerryn »

I have used several of the I2C temperature sensors and have not seen any similar fluctuation like the analog sensor is producing.
Here is an example with a PCT2075 - vary stable.
```


Adafruit CircuitPython 7.0.0-alpha.2-621-gb14d57365 on 2021-05-21; Adafruit FunHouse with ESP32S2
>>> import pct2075_simpletest
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
Temperature: 22.63 C
```

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: Funhouse wt Home Assistant

Post by jerryn »

There are many other I2C (with stemma connectors that will plug into the Funhouse)
here are some examples searching for "temperature sensor stemma"
https://www.adafruit.com/?q=temperature ... =BestMatch

Locked
Please be positive and constructive with your questions and comments.

Return to “AdaBox! Show us what you made!”