Browse Source

Minor changes and possibly useless components

master
Niko Hakala 5 years ago
parent
commit
552686fc3b
5 changed files with 56 additions and 2 deletions
  1. +2
    -2
      README.md
  2. +12
    -0
      public/tinyforest.log.json
  3. +29
    -0
      src/Components/LogParser.js
  4. +2
    -0
      src/Components/Plants.js
  5. +11
    -0
      src/Components/Sysinfo.js

+ 2
- 2
README.md View File

@ -1,7 +1,7 @@
## TODO ## TODO
Plant page layout, what goes where and what info do we actually need in the frontend.<br />
How to pull sysinfo, Only usefull info core temp etc.<br />
Sysinfo layout<br />
<br />
## React stuff ## React stuff


+ 12
- 0
public/tinyforest.log.json View File

@ -0,0 +1,12 @@
{
"0" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 22 }, "loglevel": "INFO", "host": "alarmpi", "file": "system.py", "func": "init_file", "msg": {"info": "file created", "file": "/var/log/tinyforest/tinyforest.log.json"} },
"1" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 22 }, "loglevel": "INFO", "host": "alarmpi", "file": "system.py", "func": "init_file", "msg": {"info": "file opened", "file": "/var/log/tinyforest/tinyforest.log.json"} },
"2" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 23 }, "loglevel": "INFO", "host": "alarmpi", "file": "jsonreader.py", "func": "__init__", "msg": {"json_common": {"target": "/etc/tinyforest/json/profile_plant1_v01.json", "name": "Moisture sensor (1)", "description": "Moisture sensor (1): loaded JSON configuration"}} },
"3" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 23 }, "loglevel": "DEBUG", "host": "alarmpi", "file": "jsonreader.py", "func": "__init__", "msg": {"json_common": {"target": "/etc/tinyforest/json/profile_plant1_v01.json", "name": "Moisture sensor (1)", "description": "Moisture sensor (1): {'enabled': True, 'sensor_type': 'common', 'gpio_pin': 24, 'gpio_pin_initialstate': 'LOW', 'gpio_pin_upstate': 'HIGH', 'sensor_friendly_name': 'Moisture sensor (1)', 'trigger_data_type': 'dummy_on_off', 'trigger_min': 1.0, 'trigger_max': 0.0, 'time': {'use_time': True, 'months': {'1': True, '2': True, '3': True, '4': True, '5': True, '6': True, '7': True, '8': True, '9': True, '10': True, '11': True, '12': True}, 'weeks': {'1': True, '2': True, '3': True, '4': True}, 'days': {'mon': {'enabled': True, 'interval': ['12.00', '18.00']}, 'tue': {'enabled': True, 'interval': ['8.00', '16.00']}, 'wed': {'enabled': True, 'interval': ['13.00', '20.00']}, 'thu': {'enabled': True, 'interval': ['4.00', '12.00']}, 'fri': {'enabled': True, 'interval': ['12.00', '18.00']}, 'sat': {'enabled': True, 'interval': ['6.00', '14.00']}, 'sun': {'enabled': True, 'interval': ['15.00', '23.59']}}}, 'devices_out': {'common': {'use_devices_out': True, 'check_interval': 0.25, 'keepalivetime_max': 5.0}, 'devices_out_spec': [{'enabled': True, 'gpio_pin': 14, 'gpio_pin_initialstate': 'LOW', 'gpio_pin_upstate': 'HIGH', 'operation_type': 'irrigation', 'name': 'pump_1', 'friendly_name': 'Water pump (1)'}, {'enabled': False, 'gpio_pin': 15, 'gpio_pin_initialstate': 'LOW', 'gpio_pin_upstate': 'HIGH', 'operation_type': 'irrigation', 'name': 'pump_2', 'friendly_name': 'Water pump (2)'}]}}"}} },
"4" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 23 }, "loglevel": "WARNING", "host": "alarmpi", "file": "jsonreader.py", "func": "check_devices_out", "msg": {"json_common": {"target": "/etc/tinyforest/json/profile_plant1_v01.json", "name": "Light sensor (1)", "description": "Light sensor (1): output device UV lamp (1) disabled"}} },
"5" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 23 }, "loglevel": "WARNING", "host": "alarmpi", "file": "jsonreader.py", "func": "__init__", "msg": {"json_common": {"target": "/etc/tinyforest/json/profile_plant1_v01.json", "name": "light", "description": "light: disabled"}} },
"6" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 23 }, "loglevel": "WARNING", "host": "alarmpi", "file": "jsonreader.py", "func": "__init__", "msg": {"json_common": {"target": "/etc/tinyforest/json/profile_plant1_v01.json", "name": "temperature", "description": "temperature: disabled"}} },
"7" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 23 }, "loglevel": "WARNING", "host": "alarmpi", "file": "jsonreader.py", "func": "check_devices_out", "msg": {"json_common": {"target": "/etc/tinyforest/json/profile_plant1_v01.json", "name": "pH sensor (1)", "description": "pH sensor (1): output device Fertilizer pump (1) disabled"}} },
"8" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 23 }, "loglevel": "WARNING", "host": "alarmpi", "file": "jsonreader.py", "func": "__init__", "msg": {"json_common": {"target": "/etc/tinyforest/json/profile_plant1_v01.json", "name": "acidity", "description": "acidity: disabled"}} },
"9" :{ "time": { "day": 30, "month": 10, "year": 2019, "hour": 11, "minute": 3, "second": 23 }, "loglevel": "INFO", "host": "alarmpi", "file": "jsonreader.py", "func": "__init__", "msg": {"json_common": {"target": "/etc/tinyforest/json/profile_plant1_v01.json", "name": "Moisture sensor (1)", "description": "Moisture sensor (1): started sensor process"}} }
}

+ 29
- 0
src/Components/LogParser.js View File

@ -0,0 +1,29 @@
import React, { useState, useEffect } from 'react';
const LogParser = () => {
const [logs, setLogs] = useState([]);
useEffect(() => {
fetchLogs();
}, [])
const fetchLogs = () => {
fetch('../tinyforest.log.json')
.then((res) => res.json())
.then(data => setLogs(data))
.catch(err => console.error(err))
}
console.log(log)
return (
<div>
</div>
);
};
export default LogParser;

+ 2
- 0
src/Components/Plants.js View File

@ -20,6 +20,8 @@ const Plants = () => {
.catch(err => console.error(err)) .catch(err => console.error(err))
} }
//console.log(plant.imagefile) //console.log(plant.imagefile)
return ( return (


+ 11
- 0
src/Components/Sysinfo.js View File

@ -5,11 +5,13 @@ const Sysinfo = () => {
const [moisture, setMoisture] = useState([]); const [moisture, setMoisture] = useState([]);
const [light, setLight] = useState([]); const [light, setLight] = useState([]);
const [temperature, setTemperature] = useState([]); const [temperature, setTemperature] = useState([]);
const [logs, setLogs] = useState([]);
useEffect(() => { useEffect(() => {
fetchMoisture(); fetchMoisture();
fetchLight(); fetchLight();
fetchTemperature(); fetchTemperature();
fetchLogs();
}, []) }, [])
const fetchMoisture = () => { const fetchMoisture = () => {
@ -33,6 +35,15 @@ const Sysinfo = () => {
.catch(err => console.error(err)) .catch(err => console.error(err))
} }
const fetchLogs = () => {
fetch('../tinyforest.log.json')
.then((res) => res.json())
.then(data => setLogs(data))
.catch(err => console.error(err))
}
console.log(logs)
console.log(moisture.sensor_friendly_name) console.log(moisture.sensor_friendly_name)
console.log(light.sensor_friendly_name) console.log(light.sensor_friendly_name)
console.log(temperature.sensor_friendly_name) console.log(temperature.sensor_friendly_name)


Loading…
Cancel
Save