Thing needs re-adding after every reset

Hi,

I’ve made a temperature sensor with a Wemos D1 Mini & Arduino IDE but any time I cut the power to the Wemos board (e.g. to reposition it it in my house) or even if I just momentarily push the reset button my Things Gateway loses the connection with the temperature sensor Thing so I have to remove the old & greyed-out Thing from the gateway and repeat the ‘Add Thing’ process from scratch. This is the case even though the device comes back up within seconds on the same IP address and with the same IDs, properties, etc. showing in the json that can be seen when navigating to the device’s IP address in a browser. Is there a better way to keep track of this Thing and it’s associated recent log data without having to manually re-add it each time anything might cause it to go offline for a moment?

Thanks,
Martin

When you first add the device to your gateway, is it auto-discovered or are you adding it by its IP address? If you’re using the auto-discovery mechanism (which uses mDNS), you might want to try manually setting the URL in the Web Thing add-on config (Settings -> Add-ons, then click Configure on Web Thing), e.g. “http://192.168.1.50:8080/”.

I’m trying to reproduce this, but with webthing-node, webthing-python, webthing-java, and webthing-rust, it always come back instantly.

I’ve tried both manual and auto-discovery. Sometimes auto-discovery is nearly instant but on other occasions it seems to take a long time and after, I guess, about 20-30 seconds of non-discovery it I have manually added it by address. When I’ve done this I’ve given it a URL which includes the device id, i.e. “http://192.168.1.149/things/AnalogSensorDevice” (as this it what my device shows via the serial monitor, as per the LevelSensor.ino example on GitHub, upon which I based my project). Either via auto-discovery or manual adding the Thing starts to work straight away and reports temperatures accurately, but in either case stops after resetting.

The most recent working setup was one where I had added the Thing manually and when I browsed to Settings -> Add-ons -> Configure Web Thing, as suggested it was showing the longer URL quoted above. I truncated this at the forward-slash after the IP address as per your example (I omitted the :8080 as the Thing is apparently running okay a default port), but after pressing the reset button on the Arduino board no further temperature updates were logged - despite seeing new temperature records via the Arduino’s serial monitor. So I removed the Thing from the gateway, pressed ‘Add Thing’, and this time it immediately auto-discovered it and when I pressed ‘save’ it started showing real-time temperature data straight away.

A quick update: The issue with auto-discovery seeming intermittent was due to me only calling adapter->update() when the temperature changed. I have now amended this and auto-discovery is working much better. However the issue still persists where I need to remove and re-add the WebThing at the gateway after a device reset.

I have uploaded the arduino code here: https://pastebin.com/p4XRkmaD and a video demonstrating the behaviour here: https://www.youtube.com/watch?v=9El8-CnLuqM

I’d appreciate any advice on making this work as intended.
Thanks.

As it turns out, the websocket was getting in a weird state where it never detected that it was closed.

There will be a fix later today in the 0.4.0 version of the Web Thing add-on.

I can confirm that after updating the Web Thing add-on to 0.4.0 it’s all working just fine. Thank you!

Good to hear! Please let us know if you encounter any other issues.