# Sensor Graph OK, but Sensor Data field empty

**URL:** <https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993>\
**Category:** Using farmOS\
**Created:** [December 1, 2021, 7:40am UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993 "2021-12-01T07:40:00Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [December 1, 2021, 7:40am UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/1 "2021-12-01T07:40:00Z")

</div>

Hi, I’m new to farmOS and have a quick question regarding sensors.

I setup farmOS on a Raspberry Pi3 and I also have Home Assistant running on a seperate Raspberry Pi4, I’ve deployed sensors around the farm using Arduino’s and Raspberry Pi Zeros using WiFi, LoRa and 4G. The sensors all communicate with Home Assistant and I’d like to send some of the sensor data to FarmOS. I setup one of the sensors to use the farmOS API in the Node-Red addon for Home Assistant and in farmOS it plots the graph perfectly but the Sensor Data Field is empty and says “No data found for this sensor”. Is this expected behaviour?

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/1X/7854bd2e0bd6342dd48ccbb56dafdea23ab69bb3.png)

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [December 1, 2021, 6:47pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/2 "2021-12-01T18:47:15Z")

</div>

Hi @Farmer-Ed - welcome to the farmOS community! 🙂

Hmm - what “Filters” are applied to the “Sensor Data” View below the graph? I wonder if maybe the date range ended up different from the graph or something?

I forget how some of that 1.x code works, to be honest. We’ve been making a lot of improvements to sensors in 2.x (although graphs are still TBD: [Add graphs of data stream data [#3203015] | Drupal.org](https://www.drupal.org/project/farm/issues/3203015)).

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [December 1, 2021, 7:36pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/3 "2021-12-01T19:36:04Z")

</div>

Hi @mstenta and thank you.  
There is no filters applied as far as I can tell, also no date range options showing for sensor data.

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/1X/aac7797103fe4ce3c3ee6e61069824422eeb2085.png)

Perhaps a more fundamental issue with my build? Its running on docker on 32 bit Pi OS using SQLite if that has any bearing.

How soon are we likely to see a stable release of farmOS 2.0?  
I like what I’ve seen so far in 1.x, the sensor issue is not critical as Home Assistant is providing plenty of information and handles notifications and graphs as it is, but I suppose it would nice to have everything farm related visible from farmOS. I look forward to trying out 2.0

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [December 2, 2021, 1:07am UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/4 "2021-12-02T01:07:32Z")

</div>

Huh. That is very strange @Farmer-Ed - I’m not sure what’s wrong. I wouldn’t think your build/environment would affect this at all.

If you want to dig in and debug, you can enable the Views UI module, enable “Show the SQL query” in `/admin/structure/views/settings`, then go to `/admin/structure/views` and edit the “Farm Sensor Data” View (“Views” are basically SQL queries you can build via the Drupal UI). Scroll down to “Preview with contextual filters” and enter the asset ID of your sensor asset then click “Update preview”. The SQL query will be displayed. You can then try running that query directly against your database (outside of the context of farmOS/Drupal) and maybe that will shed some light on the issue.

That’s the quick “advanced debugging” tutorial for this - hope it helps! 🙂

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [December 2, 2021, 8:01am UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/5 "2021-12-02T08:01:29Z")

</div>

@mstenta, I have to admit SQL is not exactly one of my strong points, but thank you very much for the tips.

This is the query generated.

```auto
SELECT farm_sensor_data.timestamp AS farm_sensor_data_timestamp, farm_sensor_data.name AS farm_sensor_data_name, farm_sensor_data.value_numerator AS farm_sensor_data_value_numerator, farm_sensor_data.value_denominator AS farm_sensor_data_value_denominator
FROM 
{farm_asset} farm_asset
LEFT JOIN {farm_sensor_data} farm_sensor_data ON farm_asset.id = farm_sensor_data.id
WHERE (( (farm_asset.id = '73' ) )AND(( (farm_asset.type IN ('sensor')) AND (LENGTH(farm_sensor_data.name) > '0') )))
ORDER BY farm_sensor_data_timestamp DESC
LIMIT 50 OFFSET 0

```

I tried running the query in DB Browser for SQLite and it didn’t like the curly brackets. (I also tried without the brackets and it ran without error but didn’t return anything, I realise that was grasping at straws to start with)

```auto
Execution finished with errors.
Result: unrecognized token: "{"
At line 1:
SELECT farm_sensor_data.timestamp AS farm_sensor_data_timestamp, farm_sensor_data.name AS farm_sensor_data_name, farm_sensor_data.value_numerator AS farm_sensor_data_value_numerator, farm_sensor_data.value_denominator AS farm_sensor_data_value_denominator
FROM

```

I also used the GUI to check the database and to me it looks OK, timestamps are from the expected times as I deleted the sensor and created 2 new ones yesterday afternoon.

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/1X/c7fbfe86f1952554aba443ec2225f3b2cc09bad1.png)

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [December 2, 2021, 10:19am UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/6 "2021-12-02T10:19:57Z")

</div>

Are you having the same problem with other sensors? Or just this one?

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [December 2, 2021, 10:51am UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/7 "2021-12-02T10:51:42Z")

</div>

@mstenta  
It was all sensors, but I’ve not tried many yet.  
Anyway I seem to have a solution now.

I changed one of the filter criteria from in /admin/structure/views Farm Sensor Data View

[Sensor data: Sensor reading name (longer than 0)]  
to  
[Sensor data: Sensor reading name (has word )]

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/1X/2436e9651c158988397c1838956db174d13d13a5.png)

Sensor value is not changing as the pump it is monitoring is switched off, So I’ll have to go and physically test that but looks good for now.

Thanks very much for your help on this.

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [December 2, 2021, 11:18am UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/8 "2021-12-02T11:18:43Z")

</div>

> [@Farmer-Ed](#):
>
> I changed one of the filter criteria from in /admin/structure/views Farm Sensor Data View
> 
> [Sensor data: Sensor reading name (longer than 0)]  
> to  
> [Sensor data: Sensor reading name (has word )]

Oh interesting! I wonder if this is an SQLite compatibility issue. Maybe SQLite3 doesn’t like this query condition:

> [@Farmer-Ed](#):
>
> `LENGTH(farm_sensor_data.name) > '0'`

Might be worth opening a bug report for this so we can fix it. I haven’t used sensor data in SQLite3 personally, so it may have just gone unnoticed until now. We should also check to see if 2.x is affected (cc @paul121).

---

<div class="post-metadata">

**Author:** ![mikefarms](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mikefarms/32/477_2.png) [@mikefarms](https://farmos.discourse.group/u/mikefarms)\
**Post date:** [December 6, 2021, 2:47pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/9 "2021-12-06T14:47:25Z")

</div>

@Farmer-Ed, just seeing this now. Out of curiosity, are you planning on having all of your sensor data housed in FarmOS on 15 minute intervals?  
I haven’t started yet, but I’m looking at different architectures for having FarmOS and Home Assistant coexist more formally, probably with an integration in HA.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [December 6, 2021, 3:23pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/10 "2021-12-06T15:23:28Z")

</div>

No probably not in the long run.  
Most of my sensors are battery/solar powered Arduinos and sleep for an hour or longer after passing sensor data to HA. So hourly or longer more likely depending on the sensor.

Are you talking about creating a version of farmOS as a HA addon?  
I initially tried getting HA and farmOS to co exist on a single Raspberry Pi 4, not as an addon though simply another docker container with both running on Pi OS but performance was horrible for farmOS with regular timeouts. I think my issue was the configuration of NGINX to handle SSL for both so I gave up and now run farmOS on a separate Pi 3 with SSD, they now both run their own NGINX proxies but HA handles the SSL certs.

---

<div class="post-metadata">

**Author:** ![mikefarms](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mikefarms/32/477_2.png) [@mikefarms](https://farmos.discourse.group/u/mikefarms)\
**Post date:** [December 6, 2021, 3:37pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/11 "2021-12-06T15:37:35Z")

</div>

Actually, I should have clarified that yes, ultimately I would love a FarmOS add-on for HA built using their approach to add-ons and running on Home Assistant OS. As you mentioned, there’s a bit of a problem with NGINX proxies and an official HA add-on would alleviate that because (I believe) the FarmOS UI can be displayed as a window in HA. I haven’t tested any of that, and I’m sure there are technical hang-ups, but it would be a great goal.

There is also utility to having an integration that pulls data from FarmOS back into Home Assistant, which can be done using a remote FarmOS node like your setup or a FarmOS node as a HA add-in.

It’s nice to connect with someone who is trying some of the same things. I’ll be tackling a lot of the above early next year (I’m currently working on an OpenThread/Matter add-on for home assistant as a learning exercise). I’m very interested in the 1+1=3 nature of integrating HA and FarmOS for mutual benefit.

---

<div class="post-metadata">

**Author:** ![mikefarms](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mikefarms/32/477_2.png) [@mikefarms](https://farmos.discourse.group/u/mikefarms)\
**Post date:** [December 6, 2021, 3:41pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/12 "2021-12-06T15:41:17Z")

</div>

> [@Farmer-Ed](#):
>
> but HA handles the SSL certs

This piqued my interest. Can you elaborate how you have HA handling SSL certs for FarmOS? That’s a particular sticking point that I’d love more flexibility on for my setup which is similar hardware as yours. Thanks.

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [December 6, 2021, 5:25pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/13 "2021-12-06T17:25:52Z")

</div>

@mikefarms I’d also be interested to see any development in integrations between HA and farmOS and I’m sure others would too. I’d imagine with beta release of farmOS 2.0 due soon it may be a better starting point.

Nginx and Duckdns Addons already handle SSL certs for HA and save them to a folder shared by the Samba Addon, so I mounted this Samba share on my farmOS Pi and added it as a volume using docker compose.

I’m currently documenting all of my farm IOT/IT projects on my website, my farmOS install is here:

> **[FarmOS Raspberry Pi Docker Install with SSL.](https://farmer-eds-shed.com/farmos-raspberry-pi-docker-install-with-ssl/)**
>
> “FarmOS is a web-based application for farm management, planning, and record keeping. It is developed by a community of farmers, developers, researchers, and organizations with the aim of pro…

I plan on adding My HA -Node-Red-farmOS setup shortly also. Not sure I’m great at documentation but have a look and see for yourself.

@mstenta I hope linking my site is OK, if not I can remove it promptly?

---

<div class="post-metadata">

**Author:** ![mikefarms](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mikefarms/32/477_2.png) [@mikefarms](https://farmos.discourse.group/u/mikefarms)\
**Post date:** [December 6, 2021, 6:04pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/14 "2021-12-06T18:04:31Z")

</div>

> [@Farmer-Ed](#):
>
> I’d imagine with beta release of farmOS 2.0 due soon it may be a better starting point.

Yes definitely targeting farmOS 2.0. I’ve personally never even run farmOS 1.x!

> [@Farmer-Ed](#):
>
> Not sure I’m great at documentation but have a look and see for yourself.

I looked at this. I haven’t gone through your procedure, but I will and I’ll let you know if there are any undocumented sticking points. It looks like you _do_ have a knack for documentation, FWIW.

That kind of procedure is perfect for the concept we talked about on the FarmOS dev call - namely community-provided walkthroughs on various specific topics. Basically, we tag what version of FarmOS it’s been tested for and then create a GitHub pull request for a Markdown version with pictures so it shows up on the FarmOS website. The walkthroughs wouldn’t be a part of the official documentation (and also wouldn’t have an expectation of being maintained as development continues), but could provide help for common tasks beyond the official documentation scope.

---

<div class="post-metadata">

**Author:** ![mikefarms](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mikefarms/32/477_2.png) [@mikefarms](https://farmos.discourse.group/u/mikefarms)\
**Post date:** [December 6, 2021, 6:07pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/15 "2021-12-06T18:07:22Z")

</div>

[Here](https://farmos.discourse.group/t/farmos-blog-tutorials/976) is the thread where @jgaehring and I were talking about implementation.

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [December 6, 2021, 6:35pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/16 "2021-12-06T18:35:43Z")

</div>

OK cool,  
It is 1.x that I am currently running.

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [December 7, 2021, 1:13pm UTC](https://farmos.discourse.group/t/sensor-graph-ok-but-sensor-data-field-empty/993/17 "2021-12-07T13:13:20Z")

</div>

@mikefarms, I have published my HA/Node-red/farmOS how-to, I’d be happy to add both of them to the community-provided walkthrough repo when @jgaehring has it ready.

> **[farmOS sensors with Home Assistant and Node-Red.](https://farmer-eds-shed.com/farmos-sensors-with-home-assistant-and-node-red/)**
>
> farmOS provides an API to import sensor data and since I’m already building a farm wide sensor network this looks like a feature I’d like to implement. The farmOS guide says: “The…
