Llama / Tasker / Locale

Apps like the ones mentioned above allow to execute actions based on external events. Those events may well be the connection to a WLAN, the entering of some area. Those events are pretty useful if combined with an FHEM instance. This is why andFHEM provides an external interface to those apps.

Sending commands

AndFHEM provides a UI for sending commands to FHEM. Just look for an andFHEM plugin in your favourite location aware switching app.(AndFHEM 2.1.4+)

Example: Llama
  1. Open up Llama, click the rules tab and click on the plus icon to create a new rule.
  2. Add a new event by clicking on the respective button.
  3. Select Locale-Plugin as event type.
  4. Select andFHEM command.
  5. Enter the command you want to send to FHEM.
  6. Select the connection you want to use.
  7. Click save and enter the rest of your rule, i.e. conditions, ...

Triggering actions based on device states

You can trigger actions based on device states by adding the Device State Locale Plugin. You need to select a device and enter a desired device state. If the device state is found to match the desired state, the condition is met and an action is triggered. This plugin only works using Locale and Tasker.

Switching connections

Using a Locale Plugin you can switch to another AndFHEM connection. This can be used to select a connection based on an available WLAN connection or a network cell. (AndFHEM 2.7.0+)

Receiving device state change broadcasts

Tasker allows to receive Intents from external applications and trigger events based on the contents (see Tasker Documentation for details, AndFHEM 2.7.0+).

Broadcasts are only sent if GCM is enabled. The broadcast intents contain the following information:

Broadcast-Aktion li.klass.fhem.constants.Actions.EXT_DEVICE_STATE_NOTIFY
ACTION deviceStateChange
DEVICENAME The name of the changed device, i.e. "mat_halogen"
STATE_NAME The name of the changed state. This is always uppercase and usually equals to "STATE".
STATE_VALUE The actual value, i.e. "on".

Programmatic APIs

AndFHEM can be partially controlled using intents from external applications:

Start andFHEM via URL scheme

AndFHEM can be started from your local web browser when providing a link in a distinct format. Whenever a URL starts with fhem://, andFHEM will try to interprete the content:

From 5.7.7 onwards

https://andfhem.klass.li/app/room/bathroom Opens a room called "bathroom"
https://andfhem.klass.li/app/device/light Opens a device called "light"
https://andfhem.klass.li/app/allDevices Shows the all devices list
https://andfhem.klass.li/app/roomList Shows the list of all rooms
https://andfhem.klass.li/app/favorites Shows all favorites
https://andfhem.klass.li/app/conversion Shows the conversion view
https://andfhem.klass.li/app/sendCommand Shows the command sending view
https://andfhem.klass.li/app/execute?cmd=set%20mat_halogen%20on Switches a device called mat_halogen to on (%20 is the escape sequence for space)

Up to version 5.7.6

fhem://room=bathroom Opens a room called "bathroom"
fhem://device=light Opens a device called "light"
fhem://all_devices Shows the all devices list
fhem://room_list Shows the list of all rooms
fhem://favorites Shows all favorites
fhem://cmd=set%20mat_halogen%20on Switches a device called mat_halogen to on (%20 is the escape sequence for space)
fhem://set%20mat_halogen%20on Deprecated: Old functionality to switch devices. Do not used that one