blob: bdc97518a055b59b6dd1ae44517cf4acf5cf88f7 [file] [log] [blame]
import api from '../../api';
const PowerConsumptionStore = {
namespaced: true,
state: {
powerConsumption: false
},
getters: {
powerConsumption: state => state.powerConsumption
},
mutations: {
setPowerConsumption: (state, powerConsumption) =>
(state.powerConsumption = powerConsumption)
},
actions: {
getPowerData({ commit }) {
api
.get('/xyz/openbmc_project/sensors/power/total_power')
.then(response => {
const powerData = response.data.data;
let powerConsumption =
powerData.Value * Math.pow(10, powerData.Scale);
commit('setPowerConsumption', powerConsumption);
})
.catch(error => {
console.log('Power Consumption', error);
});
}
}
};
export default PowerConsumptionStore;