# View Home-assistant in FarmOS

**URL:** <https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287>\
**Category:** Using farmOS\
**Tags:** feature-request\
**Created:** [July 21, 2022, 12:42pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287 "2022-07-21T12:42:29Z")\
**Posts on this page:** 20\
**Page:** 2

<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:** [July 26, 2022, 2:15pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/21 "2022-07-26T14:15:19Z")

</div>

👍  
Absolutely.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [July 26, 2022, 3:43pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/22 "2022-07-26T15:43:06Z")

</div>

@mstenta

> [@Farmer-Ed](#):
>
> I suppose the real question from @pat is what would it take to get an iframes module approved for Farmier?

Yep. That would be nice to have the Node-Red dashboard within FarmOS.  
I don’t know if Farmier hosted NodeRed would provide some extra features. I find Node-Red quite easy to self-host. I’m more conserned about selfhosting FarmOS.

---

<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:** [July 27, 2022, 11:00am UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/23 "2022-07-27T11:00:24Z")

</div>

> [@SirSundays](#):
>
> I think it would be easy to modify the module so you can have a custom iframe accessible from the sidebar. The only thing that would need to change is to make the title customizable. Otherwise, I think it is basically ready to use.

Not so sure now, a dynamic menu name does not look as straight forward as I would have thought, but there are plenty of dynamic route examples. Although the functionality of the module is unaffected by the title so your module may well do the way it is, or perhaps with a more generic title such as “iframe” or “IOT” ?

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

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [July 27, 2022, 1:50pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/24 "2022-07-27T13:50:15Z")

</div>

“IOT” could work fine, but it may be used for completely other stuff too.  
For example NodeRed dashboard to interact with FarmOS logs. No IOT in that use.

Is it possible to add several iframes this way? Or is it “one module, one iframe”?

---

<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:** [July 27, 2022, 2:10pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/25 "2022-07-27T14:10:33Z")

</div>

I’m sure its possible to make the name editable, just I don’t know how and can’t currently find an example. Someone else may well come along and say oh it’s easy you just do …

I agree IOT wouldn’t be perfect for everything, but it’s hard to see a static title that sounds good though, simply “iframe” may make most sense but doesn’t really have any bearing on the intended content either.

Several iframes for one module should be possible, but how many does everyone need and what are they called? Would be nice for a module to be able to dynamically add iframes as well as menu names.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [July 27, 2022, 2:18pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/26 "2022-07-27T14:18:03Z")

</div>

> [@Farmer-Ed](#):
>
> Someone else may well come along and say oh it’s easy you just do …

Of course. (At least that’s my experience 🙂 )

iFrame is also very technical.

> [@Farmer-Ed](#):
>
> Several iframes for one model should be possible, but how many does everyone need and what are they called? Would be nice for a module to be able to dynamically add iframes as well as menu names.

I was thinking of tabs on top. One iFrame for each tab.  
Then there could be a menu named something like “External content”.  
It would also keep the main menu cleaner.

---

<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:** [July 27, 2022, 3:27pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/27 "2022-07-27T15:27:43Z")

</div>

Maybe tabbed, but I wonder what effect that might have on the useable space for the iframe, the screen is already getting a bit cluttered on smaller screens especially with narrower aspect ratios.

External Content could work I suppose for a label.  
I just added a second iframe to a module without much issue too, still using the same toolbar.

In the picture below I created 3 iframes here on 2 different modules.

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

Edit:  
I wonder if enabling/disabling menu items might be easier, maybe offer a selection of names that could be used, allowing multiple to be enabled at once if desired?

2nd Edit: might just be what I was looking for in the first place.

> **[Menu links with dynamic values](https://gorannikolovski.com/blog/menu-links-dynamic-values)**
>
> Menu link defined statically in a \*.links.menu.yml file can be altered with hook menu links discovered alter hook, but if you want to provide a dynamic value you have to use something else.

---

<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:** [July 27, 2022, 6:37pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/28 "2022-07-27T18:37:47Z")

</div>

And it works! Editable menu Titles 🤓

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/1X/aa3d826cc00e01a3532dffa5779cd183bba24e39.png)  
Figuring out the Icons would be nice now 🤔

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [July 27, 2022, 8:42pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/29 "2022-07-27T20:42:01Z")

</div>

Great. It was really easy then 😇

The more I think about it, a NodeRed dashbard interacting with FarmOS will be quite useful in several cases. Not only for IOT.

---

<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:** [July 27, 2022, 8:55pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/30 "2022-07-27T20:55:18Z")

</div>

> [@pat](#):
>
> Great. It was really easy then 😇

It’s all easy if you know how…

> [@pat](#):
>
> The more I think about it, a NodeRed dashbard interacting with FarmOS will be quite useful in several cases. Not only for IOT.

Absolutely, everything from handling CSV files, connecting with other API’s to an alternative to quick forms.

---

<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:** [July 28, 2022, 9:08am UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/31 "2022-07-28T09:08:31Z")

</div>

After spending some time re-branding the Grafana Module to a Node-Red module it looks increasingly like a generic iframes module would be more appropriate.

I’ve made it so multiple iframes can be added with and option to re-label and enable/disable. At the moment its just 2 but 3 or 4 wouldn’t be any more difficult.

There is still only one iframe field per asset, not sure if there is much point increasing that.

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

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [July 28, 2022, 9:12am UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/32 "2022-07-28T09:12:32Z")

</div>

Great work!

Not sure what you mean by one iframe field pr asset tho.  
But it seems pretty perfect as far as I can see.

---

<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:** [July 28, 2022, 9:26am UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/33 "2022-07-28T09:26:38Z")

</div>

@SirSundays Grafana module adds an iframe to the menu bar but also the option to embed individual iframes for each asset, so a graph relevant to that particular asset.

So, if for instance I wanted to associate a temperature graph from my upstairs to cow 345 🤣 I can. (There is probably better uses for that too! )

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

I think it’s a pretty cool feature, with lots of potential.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [July 28, 2022, 11:43am UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/34 "2022-07-28T11:43:40Z")

</div>

> [@Farmer-Ed](#):
>
> So, if for instance I wanted to associate a temperature graph from my upstairs to cow 345 🤣 I can.

🤣

Ok. I get it. Cool feature indeed.

I really have to make some time and get my Pi up and running with Node-Red now… 😋  
I’m running it on an ubuntu laptop at the moment from a snap install. Works fine, but I had trouble installing custom nodes. Seems like it’s not the recomended way of installing.

If we get this module available for hosted FarmOS too, it would really rock.  
That would provide a manageble and powerful environment.  
And hopefully a lot of useful ideas will evolve

---

<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:** [July 29, 2022, 1:53pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/35 "2022-07-29T13:53:39Z")

</div>

Repo for rebranded Generic iframe module.

> **[GitHub - Farmer-Eds-Shed/farm\_iframe: This module provides a basic...](https://github.com/Farmer-Eds-Shed/farm_iframe)**
>
> This module provides a basic integration of a Node Red instance into farmOS. - GitHub - Farmer-Eds-Shed/farm\_iframe: This module provides a basic integration of a Node Red instance into farmOS.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [July 29, 2022, 2:03pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/36 "2022-07-29T14:03:21Z")

</div>

> [@Farmer-Ed](#):
>
> Repo for rebranded Generic iframe module.

Nice.  
@mstenta I would love to try out this on my hosted instance.

---

<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:** [July 29, 2022, 3:45pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/37 "2022-07-29T15:45:44Z")

</div>

@Farmer-Ed quick review of the `farm_iframe` module:

> <https://github.com/Farmer-Eds-Shed/farm_iframe/blob/main/config/schema/farm_iframe.schema.yml>

This only describes `iframe_1_url`, but there is also an `iframe_2_url`.

I wonder if it would make more sense to use a `sequence` type (aka indexed array) rather than hard-coding each. Then it could be scalable to more than 2 (even if your config form only starts with support for 2).

> **[Configuration schema/metadata](https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-schemametadata#s-defining-a-new-schema)**
>
> Drupal 8 includes support for a Kwalify inspired schema/metadata language for configuration YAML files. Kwalify itself is written in Ruby and we needed slight adjustments in the format, so not all of the details of Kwalify are directly applicable,...

Also, if your config form saves the config, then you don’t need to create anything in your `config/install` directory. Leave it up to the user to create that through the form, rather than installing with 2 defaults (which both currently pull in `https://eolab.de/`). Then it would be starting blank.

> **[farm\_iframe/templates at main · Farmer-Eds-Shed/farm\_iframe](https://github.com/Farmer-Eds-Shed/farm_iframe/tree/main/templates)**
>
> main/templates

Do you need all these templates? It seems that one generic one would suffice.

> <https://github.com/Farmer-Eds-Shed/farm_iframe/blob/main/farm_iframe.routing.yml>

Ideally there would just be one route with a parameter. See [https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/using-parameters-in-routes](https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/using-parameters-in-routes)

> <https://github.com/Farmer-Eds-Shed/farm_iframe/blob/main/farm_iframe.managed_role_permissions.yml>

This is unnecessary. farmOS already grants the `access toolbar` permission to managed roles: [farmOS/farm\_ui\_menu.managed\_role\_permissions.yml at 04bf771d91cde8276b67090d2b97c4e4558332b9 · farmOS/farmOS · GitHub](https://github.com/farmOS/farmOS/blob/04bf771d91cde8276b67090d2b97c4e4558332b9/modules/core/ui/menu/farm_ui_menu.managed_role_permissions.yml)

Menu items can be defined dynamically in a “deriver” class, which would make this more flexible. We do that in a few places in farmOS that you can use for reference (search for `extends MenuLinkDefault` in the farmOS code). See [Dynamic menu links in Drupal 8 with plugin derivatives | Web Omelette](https://www.webomelette.com/dynamic-menu-links-drupal-8-plugin-derivatives)

> <https://github.com/Farmer-Eds-Shed/farm_iframe/blob/main/src/Plugin/Field/FieldType/IframeItem.php>

I don’t think this needs it’s own `FieldType`, or `FieldWidget`. It’s just a textfield. The `FieldFormatter` could target the existing text field type. I guess… maybe there’s some value in keeping them separate.

I see there is some prior work on this in Drupal contrib already as well:

> **[Iframe](https://www.drupal.org/project/iframe)**
>
> Branch 8.x-1.x old branch (old templates, only bugfixes, deprecated) Branch 8.x-2.x we are extending the module using twig templates and fixing settings of field-general, field-instance, field-display (current stable branch) A custom field, which...

> **[Simple iframe](https://www.drupal.org/project/simple_iframe)**
>
> This module provides a new field type for displaying iframes. The field provides only the most basic settings for an iframe display and nothing else: src, width and height. If you are looking to set other attributes for the iframe you should check...

Haven’t tested those, but maybe duplicating efforts?

The module will need a `composer.json` in order to pull it into Farmier too.

Sorry for the deluge - hope that 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:** [July 29, 2022, 4:18pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/38 "2022-07-29T16:18:24Z")

</div>

> [@mstenta](#):
>
> Sorry for the deluge - hope that helps! 🙂

Thats OK, @mstenta and thanks for taking the time, I was just sharing the repo that I’m working from and aware that “some” tidying may be in order 🙃. But I will absolutely take all of the above on board.

---

<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:** [August 6, 2022, 7:43am UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/39 "2022-08-06T07:43:23Z")

</div>

@pat, I’m still working on this, but going to try and redesign it a bit, using the provided advice above and a bit more researching to make the options more dynamic.

@mstenta are you happy for modules with iframes to be included in hosted Farmier instances? Any security concerns etc. before I spend too much time/effort 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:** [August 6, 2022, 7:19pm UTC](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287/40 "2022-08-06T19:19:04Z")

</div>

@Farmer-Ed There are some security considerations allowing iframes, yes. But I wouldn’t be opposed to enabling this module for a few folks who I trust, who are experimenting with advanced stuff like this.

I’d like to read up a bit more on iframe security considerations before making it available more widely. This SO post has a good overview (for future reference): [html - Why are iframes considered dangerous and a security risk? - Stack Overflow](https://stackoverflow.com/questions/7289139/why-are-iframes-considered-dangerous-and-a-security-risk)

In the case of farmOS, and embedding iframe into the farmOS UI, I think the primary risk is exposing other users to malicious URLs embedded in iframes. That can be mitigated by only allowing high-level users access to add URLs to iframes, but something to think about more deeply… especially if we ever foresee farmOS pages being made visible to the public.

[Previous page](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287.md?page=1)

[Next page](https://farmos.discourse.group/t/view-home-assistant-in-farmos/1287.md?page=3)
