diff --git a/lib/Settings/Settings.h b/lib/Settings/Settings.h index b7dbf4c0..cafdde84 100644 --- a/lib/Settings/Settings.h +++ b/lib/Settings/Settings.h @@ -58,14 +58,14 @@ enum RadioInterfaceType { LT8900 = 1, }; -static const GroupStateField DEFAULT_GROUP_STATE_FIELDS[] = { +static const std::vector DEFAULT_GROUP_STATE_FIELDS({ GroupStateField::STATE, GroupStateField::BRIGHTNESS, GroupStateField::COMPUTED_COLOR, GroupStateField::MODE, GroupStateField::COLOR_TEMP, GroupStateField::BULB_MODE -}; +}); struct GatewayConfig { GatewayConfig(uint16_t deviceId, uint16_t port, uint8_t protocolVersion); @@ -105,6 +105,7 @@ class Settings { hostname("milight-hub"), rf24PowerLevel(RF24PowerLevelHelpers::defaultValue()), rf24Channels(RF24ChannelHelpers::allValues()), + groupStateFields(DEFAULT_GROUP_STATE_FIELDS), rf24ListenChannel(RF24Channel::RF24_LOW), _autoRestartPeriod(0) { } diff --git a/test/remote/spec/settings_spec.rb b/test/remote/spec/settings_spec.rb index 281dcdbc..b39363e6 100644 --- a/test/remote/spec/settings_spec.rb +++ b/test/remote/spec/settings_spec.rb @@ -165,4 +165,27 @@ expect(ping_test.ping?).to be(true) end end + + context 'defaults' do + before(:all) do + # Clobber all settings + file = Tempfile.new('espmh-settings.json') + file.close + + @client.upload_json('/settings', file.path) + end + + it 'should have some group state fields defined' do + settings = @client.get('/settings') + + expect(settings['group_state_fields']).to_not be_empty + end + + it 'should allow for empty group state fields if set' do + @client.patch_settings(group_state_fields: []) + settings = @client.get('/settings') + + expect(settings['group_state_fields']).to eq([]) + end + end end \ No newline at end of file