Closed PandaKing185 closed 3 months ago
I cant figure out the rhyme or reason for when it saves. Previously I was having issues with it reverting after updating the restart condition for MMM-Config to "use PM2," but I just tried it and it did properly save. Trying to save just the Weather module (thinking it might be related to the Tesla module somehow) it still reverts the changes.
Actually I just realized it's deleting the entry for "units" and "tempUnits", along with many others, instead of changing the value. Compare instance 1 of the weather module (the one changed):
{
module: "weather",
position: "top_right",
label: "instance 1",
order: "2",
index: 0,
config: {
weatherProvider: "weathergov",
apiBase: "https://api.weather.gov/points/",
weatherEndpoint: "/forecast",
lat: 28.026182,
lon: -81.967439,
windUnits: "mph",
timeFormat: 24,
useBeaufort: true,
degreeLabel: "false",
useKmh: false,
showHumidity: false
},
disabled: false
}
with instance 2 (not touched since it's correct):
{
module: "weather",
position: "top_right",
label: "instance 2",
order: "3",
index: 1,
config: {
weatherProvider: "weathergov",
apiBase: "https://cors-anywhere.herokuapp.com/https://api.darksky.net",
weatherEndpoint: "/forecast",
lat: 28.026182,
lon: -81.967439,
units: "imperial",
tempUnits: "imperial",
windUnits: "mph",
updateInterval: 600000,
animationSpeed: 1000,
timeFormat: 24,
showPeriod: true,
showWindDirection: true,
useBeaufort: true,
lang: "en",
showSun: true,
degreeLabel: "false",
decimalSymbol: ".",
maxNumberOfDays: 5,
maxEntries: 5,
fade: true,
fadePoint: 0.25,
initialLoadDelay: 0,
appendLocationNameToHeader: true,
calendarClass: "calendar",
tableClass: "small",
showFeelsLike: true,
roundTemp: false,
useKmh: false,
showPeriodUpper: false,
showWindDirectionAsArrow: false,
showHumidity: false,
showIndoorTemperature: false,
showIndoorHumidity: false,
onlyTemp: false,
showPrecipitationAmount: false,
colored: false
},
disabled: false
}
Some/many time you have to hit refresh AFTER restarting mm. I only build the form at startup
The same thing occurs with refreshing after restart. I also tried just opening it in a private window after restarting in case there was some sort of cache or something in the browser that kept it from updating with no luck.
What are the defaults for units and tempUnits?
The form should have everything, if the value is the same as default, then I don’t save it in config, as the default will be used by the module. This is the mm design.
default in weather.js appears to be "config.units," which I assume is the units setting in config.js, which is set to "imperial," and the form reflects this:
So that makes sense that it wouldnt be saved in config.js, but then I'm not sure why it's loading as "metric" in the form after restart.
Can you look in defaults.js in my module folder, it’s the collection of the module defaults
Also config.units:
weather_defaults: {
weatherProvider: "openweathermap",
roundTemp: false,
type: "current", // current, forecast, daily (equivalent to forecast), hourly (only with OpenWeatherMap /onecall endpoint)
lang: config.language,
units: config.units,
tempUnits: config.units,
windUnits: config.units,
timeFormat: config.timeFormat,
updateInterval: 10 * 60 * 1000, // every 10 minutes
animationSpeed: 1000,
showFeelsLike: true,
showHumidity: "none", // this is now a string; see current.njk
showIndoorHumidity: false,
showIndoorTemperature: false,
allowOverrideNotification: false,
showPeriod: true,
showPeriodUpper: false,
showPrecipitationAmount: false,
showPrecipitationProbability: false,
showUVIndex: false,
showSun: true,
showWindDirection: true,
showWindDirectionAsArrow: false,
degreeLabel: false,
decimalSymbol: ".",
maxNumberOfDays: 5,
maxEntries: 5,
ignoreToday: false,
fade: true,
fadePoint: 0.25, // Start on 1/4th of the list.
initialLoadDelay: 0, // 0 seconds delay
appendLocationNameToHeader: true,
calendarClass: "calendar",
tableClass: "small",
onlyTemp: false,
colored: false,
absoluteDates: false,
hourlyForecastIncrements: 1
}
Ok, at the bottom of schema3.json is the collection of values that will populate the form
“value”:{
Yup. That shows metric:
"weather": [
{
"disabled": false,
"module": "weather",
"position": "top_right",
"order": "2",
"inconfig": "1",
"config": {
"weatherProvider": "weathergov",
"roundTemp": false,
"type": "current",
"units": "metric",
"useKmh": false,
"tempUnits": "metric",
"windUnits": "mph",
"updateInterval": 600000,
"animationSpeed": 1000,
"timeFormat": 24,
"showPeriod": true,
"showPeriodUpper": false,
"showWindDirection": true,
"showWindDirectionAsArrow": false,
"useBeaufort": true,
"lang": "en",
"showHumidity": false,
"showSun": true,
"degreeLabel": "false",
"decimalSymbol": ".",
"showIndoorTemperature": false,
"showIndoorHumidity": false,
"maxNumberOfDays": 5,
"maxEntries": 5,
"ignoreToday": false,
"fade": true,
"fadePoint": 0.25,
"initialLoadDelay": 0,
"appendLocationNameToHeader": true,
"calendarClass": "calendar",
"tableClass": "small",
"onlyTemp": false,
"showPrecipitationAmount": false,
"colored": false,
"showFeelsLike": true,
"apiBase": "https://api.weather.gov/points/",
"weatherEndpoint": "/forecast",
"lat": *******,
"lon": ******
},
"label": "instance 1",
"index": 0
},
And that is after manually setting it to imperial in config.js and restarting MM:
{
module: "weather",
position: "top_right",
label: "instance 1",
order: "2",
index: 0,
config: {
weatherProvider: "weathergov",
apiBase: "https://api.weather.gov/points/",
weatherEndpoint: "/forecast",
lat: 28.026182,
lon: -81.967439,
windUnits: "mph",
timeFormat: 24,
useBeaufort: true,
degreeLabel: "false",
useKmh: false,
showHumidity: false,
units: "imperial",
tempUnits: "imperial"
},
disabled: false
}
Ok, the design is mm starts, build new form of ‘now’
You edit and save AND RESTART to load the new config, AND create a new form
So on open of the form, it apparently removes the manual entries I have for imperial, which makes sense because like you said it doesnt keep it if it's the default, but then for some reason it auto populates it with metric even though that is not the default. Here is the config after a reboot right before I open the form:
{
module: "weather",
position: "top_right",
label: "instance 1",
order: "2",
index: 0,
config: {
weatherProvider: "weathergov",
apiBase: "https://api.weather.gov/points/",
weatherEndpoint: "/forecast",
lat: *******,
lon: ******,
windUnits: "mph",
timeFormat: 24,
useBeaufort: true,
degreeLabel: "false",
useKmh: false,
showHumidity: false,
units: "imperial",
tempUnits: "imperial"
},
disabled: false
}
Then I open the form and this is the config.js
{
module: "weather",
position: "top_right",
label: "instance 1",
order: "2",
index: 0,
config: {
weatherProvider: "weathergov",
lat: *******,
lon: ******,
windUnits: "mph",
apiBase: "https://api.weather.gov/points/",
weatherEndpoint: "/forecast",
timeFormat: 24,
useBeaufort: true,
degreeLabel: "false",
useKmh: false,
showHumidity: false
},
disabled: false
}
And here is the schema3.json after opening the form:
"weather": [
{
"disabled": false,
"module": "weather",
"position": "top_right",
"order": "2",
"inconfig": "1",
"config": {
"weatherProvider": "weathergov",
"roundTemp": false,
"type": "forecast",
"units": "metric",
"useKmh": false,
"tempUnits": "metric",
"windUnits": "mph",
"updateInterval": 600000,
"animationSpeed": 1000,
"timeFormat": 24,
"showPeriod": true,
"showPeriodUpper": false,
"showWindDirection": true,
"showWindDirectionAsArrow": false,
"useBeaufort": true,
"lang": "en",
"showHumidity": false,
"showSun": true,
"degreeLabel": "false",
"decimalSymbol": ".",
"showIndoorTemperature": false,
"showIndoorHumidity": false,
"maxNumberOfDays": 5,
"maxEntries": 5,
"ignoreToday": false,
"fade": true,
"fadePoint": 0.25,
"initialLoadDelay": 0,
"appendLocationNameToHeader": true,
"calendarClass": "calendar",
"tableClass": "small",
"onlyTemp": false,
"showPrecipitationAmount": false,
"colored": false,
"showFeelsLike": true,
"lat": *******,
"lon": *******,
"apiBase": "https://api.weather.gov/points/",
"weatherEndpoint": "/forecast"
},
"label": "instance 1",
"index": 0
}
Schema3 has the base values too at the time mm starts.
What is the units at the top of config.js Before the modules:[] list
var config = {
address: "0.0.0.0",
port: 8080,
basePath: "/",
language: "en",
locale: "en-US",
logLevel: [
"INFO",
"LOG",
"WARN",
"ERROR"
],
timeFormat: 12,
units: "imperial",
zoom: 1,
useHttps: false,
ipWhitelist: [],
modules: [
I found the problem, I made a custom form for weather, it copied the defaults as of then… oops. Working on a fix
ok, I think I have solved this.. give it a try, git pull to refresh the module code
if you change the default (units:....lang:...) then you have to restart MM to get that as the new default value in the form, just like for the modules that use them
Yup now it's working! Thanks a bunch
Thank you! I never saw that
Starting config.js of relevant modules (censored sensitive info):
Steps to reproduce (and taken in somefile.txt):
Restarting MM will load the correct configuration onto the mirror, but the web form will still show the old configuration, despite the config.js still showing the correct configuration. This only applies to changes in the "Modules" section. Changes in the "Base" and "Module Positions" sections do properly save and update in the form.