Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default device setting without using MQTT? #451

Closed
tripflex opened this issue Dec 19, 2017 · 14 comments
Closed

Set default device setting without using MQTT? #451

tripflex opened this issue Dec 19, 2017 · 14 comments
Assignees
Milestone

Comments

@tripflex
Copy link
Contributor

tripflex commented Dec 19, 2017

Is there a way to set default device property, specifically $stats/interval in setup code? can’t find anything online that details it and would like to change it to 5 minutes by default for all devices instead of just 1 minute

so I found const uint32_t STATS_SEND_INTERVAL = 1 * 60 * 1000; in Constants.hpp but still can’t seem to figure out the correct way to set this without modifying the lib code

@timpur
Copy link
Contributor

timpur commented Dec 19, 2017

Nope (that I know of) will add in my next release.

@timpur timpur self-assigned this Dec 19, 2017
@tripflex
Copy link
Contributor Author

Awesome thank you, just the ability to configure or override any default settings would be perfect 👍 thanks!!

@tripflex
Copy link
Contributor Author

@timpur now that i'm looking at this ... is it even possible to set interval via MQTT? I can't seem to figure out any way to change the interval value used ... which maybe I don't understand the purpose of it, but my understanding is that interval would be something settable so you can change it as needed ... but now it looks like it's just a static value?

@timpur
Copy link
Contributor

timpur commented Dec 20, 2017

The interval is used to send info like signal and up time

It would be nice to be able to configure this. Thinking of doing this through the config, thus you can also update over mqtt via incremental json

@luebbe
Copy link
Collaborator

luebbe commented Dec 20, 2017

But isn't it also important for the MQTT server to receive this kind of "ping" message in a not "too long" interval? Kind of keepalive. Otherwise he will consider the device offline?!?
I don't know enough about MQTT (whether and how it is possible to connect and tell the server at the same time how often you will ping it). I only remember having problems with one (non C) MQTT library where I couldn't set a keepalive interval and had to make sure to ping the server once every minute.

@timpur
Copy link
Contributor

timpur commented Dec 20, 2017

The keep alive period is handled by the mqtt lib and has nothing to do with homie. By protocol (my understanding) when the client connects it tells the broker the keep alive period and if that period is broken then the broker considers the connection broken....

Nothing to do with this stats interval with homie.

@tripflex
Copy link
Contributor Author

@timpur yeah i'll probably start working on this and submit a PR if you haven't already ... did you have any specific ideas in mind of how to set it up? I can probably work on the code if you wanted it done in a specific way, but I will need this for my current project.

Reason being ... use case scenario would be outputting data on a dashboard ... so when the user is viewing dashboard for a device, we would want to update the interval to say, every 15 seconds to give a better UI experience, whereas, when just storing stats, we would only want it set to every 300 seconds (5 minutes) instead

@timpur
Copy link
Contributor

timpur commented Dec 21, 2017

Okay well that's not a big change let me do this tonight.

@timpur
Copy link
Contributor

timpur commented Dec 21, 2017

Closed by #455

You can now add the interval in seconds in the config file, which means you can also use incremental json to change this via mqtt if you like. Node not yet set this in the web UI configurator

@timpur timpur closed this as completed Dec 21, 2017
@tripflex
Copy link
Contributor Author

tripflex commented Dec 21, 2017

Awesome, thank you!! Yeah I doubt it would need to be set in the web UI, just as long as it's configurable in the main source files and via mqtt, is perfect for me, thanks!!

@tripflex
Copy link
Contributor Author

Any possibility of adding a function similar to Homie_setFirmware for the interval, say, Homie_setStatsInterval to allows configuring initial interval in the setup function?

I did see you added the ability in the config file, just wasn't sure if Homie would read incremental config.json from spiff or not ... as I do still want to use the Web UI setup (interval not necessary to set in web UI)

Also posted this in #454

@timpur
Copy link
Contributor

timpur commented Dec 21, 2017

Kinda lost with your last comment (@tripflex), you can upload the config file via spiffs, which would also have your interval in it ? or update this value via incremental json from mqtt??

@tripflex
Copy link
Contributor Author

@timpur yeah understandable, but I meant that I would like to be able to set the default value configured for the device even before it's setup and ready to go.

Mainly to set default to around 5 minutes, and then I can adjust via MQTT once it's connected to the broker via incremental json. I guess for now I can just immediately send an incremental json to the device once it connects to the broker and change it from 1 minute to 5 minutes ... which just be much cleaner to be able to set the default value in the setup function, just like we would with a normal HomieSetting

@timpur
Copy link
Contributor

timpur commented Dec 22, 2017

i think you miss understand, you can upload the config file from your computer with the 5min value with out the need of mqtt. See http://marvinroger.github.io/homie-esp8266/docs/develop/configuration/json-configuration-file/ .You also dont need to use configurator if you wait to just upload the config file via your computer. Uploading files to file system

also see https://github.com/marvinroger/homie-esp8266/tree/develop/data/homie

@timpur timpur modified the milestone: v2.1.0 Dec 30, 2017
jesserockz pushed a commit to jesserockz/homie-esp8266 that referenced this issue Mar 12, 2018
euphi added a commit to euphi/homie-esp8266 that referenced this issue Mar 31, 2018
* 🔥 Remove hardcoded keepalive - fix homieiot#301 (homieiot#314)

Remove hardcoded KeepAlive for MQTT connection.
Default value of 15sec is already present in AsyncMQTT library

* 🐎 Improve uptime accuracy (homieiot#315)

improve uptime accuracy by storing milliseconds and only rounding when
publishing value
drawback: less time before rollover, but still long enough

* 🐛 Fix truncated IP (homieiot#318)

published IP is truncated.

* 🎨 Fix warning with parenthesis

* 🐛 Fix pio library.json bad dependency name

* ✨ Add support for static IP and BSSID/MAC, channel of AP (homieiot#327)

* Support for static IP and BSSID/MAC, Channel of AP

- added parameters to config.json which allow to define static ip, mask,
gateway, dns
- added parameters to config.json which allow to define BSSID and
channel of AP

To run device with defined static IP you have to define ip, mask and
gateway together.

To point device to connect to specific BSSID and channel you haveto
define bssid and channel together.

```
{

	"name": "The kitchen light",
	"device_id": "kitchen-light",
	"wifi": {
		"ssid": "Network_1",
		"password": "I'm a Wi-Fi password!",
		"bssid":
		"DE:AD:BE:EF:BA:BE",
		"channel": 1,
		"ip": "192.168.1.5",
		"mask": "255.255.255.0",
		"gw": "192.168.1.1"
	},
	"mqtt": {
		"host": "192.168.1.10",
		"port": 1883,
		"base_topic": "devices/",
		"auth": true,
		"username": "user",
		"password": "pass" i
	},
	"ota": {
		"enabled": true
	},
	"settings": {
		"param1": 55,
		"param2": "abcdefghijklm",
		"param3": true,
		"param4": false,
		"param5": 2147483647,
		"param6": -2147483647,
		"param7": 55,
		"param8": "abcdefghijklm",
		"param9": true,
		"param10": false
	}
}
```

* Addjustments for travis

* Another addjustments for travis

* Fix problem with prepareToSleep

* 🐎 Pass all callbacks by reference
Still store it by value

* 🐎 Make isActive const

* 🎨 Add custom settings value to initial log

* ✨ Abort if default setting value does not pass validator function
Fix homieiot#324

* 📝 Clarify ISSUE_TEMPLATE docs location for homieiot#331

* 📝 Implement new versioned Git docs (homieiot#341)

* ✨ Add versionned in-repo docs

* 🐛 Attempt to fix encrypted key

* 🐛 Fix permission issue on python exec

* 🐛 Add mission import

* 🐛 Fix relative path

* 🐛 Add missing commit

* ✨ Add index

* 🎨 Change index design

* 📝 Update all URLs to new docs

* 🎨 Fix broken doc link in README

* 📝 Add edit link to docs

* 📝 Move firmware_parser.py to scripts folder

* 🐛 Fix out of limits abort message not showing

* 👕 Be less strict on whitespace in comments

* 📝 Add dummy OTA updater script (TODO)

* 🎨 🐎 Use CircleCi instead of Travis CI (homieiot#348)

* ✨ Add Circle CI build

* 🐛 Add working_directory

* 🐛 Attempt to fix perm issue

* ✨ Generate docs from CircleCI

* 🐛 Fix path

* 🐛 Fix chmod permission

* 🐛 Try to run sudo

* 🐛 Attempt to use remote docker

* 🐛 Change bad directories

* 🐛 Remove dependency on Docker

* 🐛 Fix perm problem

* 🐛 Chamge tmp folder

* 🐎 Use CircleCI instead of Travis CI

* 🎨 Add SonoffDualShutters example

* 🐛 Install current lib to platformio

* 🐛 Actually ignore gh-pages in CI

* 🐛 Add missing SonoffDual dep

* 🐛 Fix ArduinoJSON 5.11.0 (homieiot#363)

* ⬆️ Update pio dependencies

* 🎨 Cleanup code a bit

* 🐛 Make sure every announcements packet are sent - closes homieiot#345

* 🎨 Refactor code and implement new OTA system
Closes homieiot#346

* 👕 Fix lint

* ✅ Use new workflow feature from Circle

* ✅ Ignore gh-pages at workflow level

* ✨ Add OTA_PROGRESS event

* 📝 Update docs for new OTA system

* ⬆️ Upgrade AsyncMqttClient dependency to 0.8.0

* 🐛 IHomieSetting::settings first, HomieNode-settings second! (homieiot#335)

*  IHomieSetting::settings first, HomieNode-settings second!

Set initialization priority of IHomieSetting::settings to value of highest allowed priority (101).

This allows other static variables to be of type HomieSetting<T>.

See https://github.com/euphi/HomieNodeCollection/blob/master/src/RGBWNode.cpp for example.

Note: As shown in the example it makes sense to have a static HomieSetting member, if you have a class that may be instantiated multiple times. (e.g. two LED Strips connected to the same ESP8266, as shown in https://github.com/euphi/ESP-LEDCtrl).

* Removed extra whitespaces

* Removed another whitespace

* 🐛 Fix not returning a value in setConfigurationApPassword (homieiot#378)

`HomieClass& HomieClass::setConfigurationApPassword(const char* password)` did not returned a reference to the Homie instance. This PR fixes this.

* 🐛 Fix crash when starting up without any defined node (homieiot#379)

* Fix crash when starting up without any defined node

Skip node publication if HomieNode::nodes.size() == 0

* Update BootNormal.cpp

* 🐛 Fix topic check for OTA upload (homieiot#375)

* Change topic check for OTA upload

* Change firmware topics to remove the 's'

* 🐛 Rename last OTA topic instance

* ✨ Add OTA updater script (homieiot#384)

* 🐍Add python ota updater script

* 💼 Update documentation of ota update script

* 😑 Add comments to ota updater script

* 🔮 Use 127.0.0.1:1883 as default broker setting

For the ota updater script

* 📝 Add details on how to interact with range property (homieiot#393)

Add hint to help people figure out how to interact with
range properties. Especially document the `_` separator.

* 📝 Add warning to input-handlers.md about concurrency (homieiot#400)

* 🐛 Interpret firmware file as an bytearray (homieiot#403)

Fix homieiot#397

* 📝 Update input-handlers.md (homieiot#401)

* Update input-handlers.md

Sorry, it seems that I used the `!!! warning` block in a wrong way.

* Update input-handlers.md

* Update input-handlers.md

* ✨ Use AsyncWebServer + Refactoring (homieiot#425)

* Initial AsyncWebServer

* Fixed Proccessing Body Requests (JSON)

* Doc Fixes + typo

* Added Missing Method in Timer.cpp

* Lots of Refactoring + Moved Reset Button to its own helper class for boots to use

* 🎨 Update BootNormal.cpp (homieiot#426)

Solve "else" errors from https://circleci.com/gh/marvinroger/homie-esp8266/136#tests/containers/0

* ⬆️ Update dependency to "ESP Async WebServer" (homieiot#434)

* 📝 Add instruction for @platformio (homieiot#435)

* Instruction for @platformio

* Explain how to used tagged version with @platformio

* Explain how to use tagged version with @platformio

* 🐛 Use v2.0.0-beta.2 as a working tagged example for @platformio (homieiot#437)

* 🎨 Simplify CI with @platformio (homieiot#438)

* 🐛 Install library via @platformio with all dependencies (homieiot#439)

* 💚 CI: Install staging version of Arduino Core for ESP8266 & @platformio (homieiot#440)

* 🐛 Pin Shutters dep version

* 🔥 Don't fail on CI docs step when testing a fork

* 🎨 More Refactoring + Deep Sleep + Prevent WiFi Reconnect when reboot (homieiot#432)

* Initial AsyncWebServer

* Fixed Proccessing Body Requests (JSON)

* Doc Fixes + typo

* Added Missing Method in Timer.cpp

* Lots of Refactoring + Moved Reset Button to its own helper class for boots to use

* Lots of Refactoring.

* Refactored ResetHandler + More Refactoring + Testing

* Added deep sleep function + Prevent Wifi reconnect before reboot (homieiot#380)[homieiot#380]

* Small typo fixes

* Small Rearange of code in BootConfig + Minor Refactor of function names

* Minior Commit to Triger a Github Action

* circleci build fix

* 🎨 First pass to fix linting

* 🎨 Second pass of lint

* 🎨 Final lint fix

* 📝 Update docs deps

* 📝 🎨 Update docs manifest

* 📝 🎨 Adjust HTTP JSON API doc

* 📝 Add configurators on website

* 📝 Update links to configurator

* Fix links under Features (homieiot#452)

* Set Device Stats Interval (homieiot#451) (homieiot#455)

* Add last step to uibundle README (homieiot#460)

* Add last step to uibundle README

* Added Arduino Support for doc

* Update updater script addressing quirks (homieiot#461)

* Update API for /wifi/connect from GET to PUT (homieiot#468)

Docs show `/wifi/connect` as `GET` when it should actually be `PUT`

* Proposal to optionally run HomieNode::loop() also in disconnected state

* Show Homie version

* Fix homieiot#446 homieiot#477 (homieiot#501)

* Fix homieiot#446 CORS Issue

* Fix for homieiot#477

* Fix Lint

* Fix Safari not displaying the config bundle HTML page (Fix homieiot#476) (homieiot#502)

* Fix Safari not displaying the config bundle HTML page

Safari cannot deal with gzip files that have a "*.gz" file extension.
Simply faking the filename solves the problem though.

* Update Readme Homie Version

* Fix Warnings (homieiot#503)

* Update Readme - Homie Convention

* Update to Homie Convention v2.0.1 (homieiot#507)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants