Action from function

Hello,

I am trying to make my floorplan and it is going well. The image attached is from the actual floorplan I am using.

Right now, when I tap the room, the lights toggle. When I tap a room’s sensor (green circles), it navigates to a different page of the dashboard showing the sensor plots. When I tap a room’s TV (red shape), it navigates to a different page of the dashboard showing the TV’s remote. And when I tap a room’s camera (blue rectangle), it navigates to a different page of the dashboard showing the camera feed.

I want to tap on a room and either toggle the lights (ha action), or view its sensors (navigate to different page) or view its cameras (navigate to different page) or control its TVs (navigate to different page), depending on the state selected in the bottom-right. The state selector I managed to make using helper variables centrally in home assistant. But to make the tap action work I need to retrieve the action from a function (I guess) which I am trying to find out how to do (unsuccessfully). I cannot even manage to have a floorplan function called from the “action” part of the rule. For some reason the function is not called.

Thank you in advance

@exetico Do you think this is possible?

To simplify this, you’re trying to execute the ha-floorplan service functions, but state-dependent?

Where if there information stored about “what action to use”? Do you update a entity in Home Assistant, or locally in your browser? Or are you simply toggle a element within the SVG, and are trying to use that as the “selector parameter”?

Without having the eyes directly in the code, I could see the “execute” solution to be extended; but the hard part could be to secure the relation between a tap-press and the related element.

You’re searching for something like this, right?

  1. Tapping the svg element
  2. Now using the execute
  3. Allow the execute function to trigger ha-floorplan logics like more-info

Also, could I ask you to submit a feature request and include your requirements there? I’ll not promise anything, but It’s nice to have it submitted as a feature request and have the discussion there, too :slight_smile: .

1 Like

This is a very, very good solution if I can run services like homeassistant.toggle and actions like navigate within execute. Do you think this is possible? If yes, then I can definitely handle it (and anything else I can think of) this way. Thank you!

I’ll need to take a look at the code. Let’s start with the feature request, and I’ll see that I can do in the next period of time.

1 Like

Feature request done! I’ve referenced this. Thank you very much!

1 Like

I came late here. There is a simple solution to this problem without any execute function trick but using simple svg layers.

  • one layer by state of the selector
  • within each layer, create for each room a transparent room shape with device references
  • when you select a new selector state, make all layers hidden and the selected one visible.
    Like this you exposed to user selected kind of actions directly on the floorplan simply by displaying the corresponding layer.

Similar example:

- entity: select.myselector
  state_action:
  - service: floorplan.class_set
    service_data:
      class: "layer-hidden"
      elements:
      - frame.lights
      - frame.camera
      - frame.sensors
      - frame.tv
  - service: floorplan.class_set
    service_data:
      class: "layer-visible"
      element: 'frame.${entity.state}'

note: select.myselector with one value from lights/camera/sensors/tv