Floorplan integration with AppDaemon

I’m aware there is ongoing development to bring HASS, AppDaemon and later Floorplan more tightly together but I’m wondering if there is currently a way to fire off AppDaemon code from Floorplan?
What I mean is I click a floorplan entity and this calls a service that I can listen to in an AppDaemon app. All my automation is handled in AD and I don’t want to go back to yaml too much.
For now I know things must be done via the floorplan.yaml (an AD app to fun floorplan would be supreme later on!) but its what I can put into the ‘action’ part that would hook me into AD that I’m not sure on. I guess I could make yet more HASS template sensors and listen to them or perhaps go via the restful api but maybe I’m missing something obvious that avoids more overhead like this.

Currently i’m doing this which is fine for basic scenes but not to hook into my AD scene manager:
- name: Buttons
entities:
- scene.livingroom_bright
- scene.power_off
action:
service: turn_on

Thoughts?
I haven’t yet migrated to the v3 AD branch if that makes a difference.

I would one day like to add Floorplan as a widget in HADashboard, but that will be a lot of work.

For now, you can work around it like this:

  1. Write a HASS script to fire an event
  2. Listen for that event in AppDaemon
  3. Use Floorplan to activate the script.

Yes I can imagine its a huge amount of work (I’m a dev so know the drill!). Look forward to the progress and maybe I can assist at some point.

Thanks for the tip, very useful will give it a go!

besides writing a script you can always use any entity you like to start AD actions.
i mostly use input_booleans for that, for instance to run an app from an alexa command.

Yes I had considered that but feel like it’s more sensor overload since i’ll need one input_boolean per floorplan button. What I want is an event that just passes the button id through to AD without loading HASS up with 10s or maybe more of sensors (my floorplans will eventually contain a lot of buttons I think!).
So far I’ve done this:

floorplan.yaml:

name: Floorplan buttons
entities:
  - floorplan_btn.livingroom_bright
  - floorplan_btn.livingroom_green
action:
  domain: script
  service: floorplan_button_handler
   data:
     entity_id: "{{ entity_id }}"

script.yaml:

floorplan_button_handler:
  sequence:
    - event: floorplan_button_pressed
      event_data:
        entity_id: "{{ entity_id }}"

And then listen in my AD floorplan manager app:
self.listen_event(self.button_pressed, "floorplan_button_pressed")

Problem is this won’t work as event_data does not parse the entity_id. It needs to be event_data_template which currently does not exist. However it looks like this was an approved pull request this week so should work on the next HASS release. Info: Fire Event with data_template
Also I’m not sure if the entity_id will get properly passed from the floorplan.yaml to the script yet as it seems like again it should be data_template here.

do the entities you have there exist in HA?
then you can just listen for their change like:
self.listen_state(self.button_pressed,“floorplan_btn”)

No they don’t exist in HA - they just exist on my floorplan svg file as button entities with those ids.
I want to avoid the overhead of declaring more entities in HA since I know I’ll be adding and changing quite a few buttons to the UI and want this kind of process:

  • Add button graphic and set the id
  • Add entity to floorplan.yaml section that fires the event
  • Add condition to my floorplan manager AD app to direct the pressed event to required function.

To add HA entities means this:

  • Add button graphic and set the id
  • Add entity to floorplan.yaml section that sets an input_boolean entity to true.
  • Declare a new input_boolean entity
  • Exclude this entity from recorder logging, log book and history views in HA.
  • Add condition to my floorplan manager AD app to direct the pressed event to required function.
  • Get AD app to set input_boolean entity back to false.

I like the reusable solution and to me the action of clicking a button should raise an event rather than set a value in a register (i.e. an entity).
Also the more helper entities there are in HA the more difficult it is to find things in the big list of entities. And I feel there is a performance issue too, especially in the UI that already freezes up quite a bit.

if the floorplan fires an event in HA with the right settings there is no problem.
then AD can work with it.

for that nothing has to change on AD in my eyes.

i have no idea how floorplan works with HA.
i thought that the floorplan just changes states from HA entities. like the dashboard does.

In floorplan you build an svg file and assign ids to objects in it. So I place a text object then assign the id ‘sensor.temperature_outside’ to it. Then set it in the floorplan yaml file and then the state data is shown on the floorplan.
But it does not directly change entity states - you can click the entity’s graphic item then it pops up with HA’s standard panel (light control, switch, state history etc) but that is cumbersome to switch a light on or off - you want a single click on the floorplan.
So raising events is the answer, which AD is well suited for. It’s just getting the entity id through that event process that isn’t yet working… yet.