{"id":16732559,"url":"https://github.com/antonmi/fire_alarm","last_synced_at":"2025-08-24T01:08:48.503Z","repository":{"id":241281648,"uuid":"804783528","full_name":"antonmi/fire_alarm","owner":"antonmi","description":"An example problem solved with Strom","archived":false,"fork":false,"pushed_at":"2024-06-09T16:20:53.000Z","size":29,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T10:12:24.086Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonmi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-23T09:02:59.000Z","updated_at":"2024-12-22T15:19:46.000Z","dependencies_parsed_at":"2025-02-17T04:31:58.186Z","dependency_job_id":null,"html_url":"https://github.com/antonmi/fire_alarm","commit_stats":null,"previous_names":["antonmi/fire_alarm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmi%2Ffire_alarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmi%2Ffire_alarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmi%2Ffire_alarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmi%2Ffire_alarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonmi","download_url":"https://codeload.github.com/antonmi/fire_alarm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208666,"owners_count":21065203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T23:45:36.779Z","updated_at":"2025-04-10T11:26:51.727Z","avatar_url":"https://github.com/antonmi.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FireAlarm\n\n**An example problem solved with Strom**\n\nStrom is [here](https://github.com/antonmi/Strom)\n\n## The problem\n\nWe are implementing a fire-alarm logic for a storage of goods.\n\nThe storage has many rooms (let's say 100). Each room has 3 sensors:\n\n- Temperature sensor\n- Humidity sensor\n- Smoke detector\n\nEach sensor produces event every 100ms (it may vary).\n\nThe program reports the status of the storage every second.\n\nOn the room level the logic is following:\n1. If the temperature exceeds 50C and the same time the humidity exceeds 90% the program produces the `:warning` event for the room.\n2. If smoke is detected the program produces the `:alarm` event for the room.\n3. If everything is ok the program reports the `:ok` event.\n\nOn the storage level the logic is:\n1. If everything ok, the `{:ok, []}` event is generated.\n2. If there are warnings in rooms, the `{:warning, [:room_x, :room_y]}` is produced\n3. If there are alarms in rooms, the `{:alarm, [:room_x, :room_y]}` is produced.\n4. If there are more than 3 rooms with the `:alarm` event, then the `{:siren, [:room_x, :room_y]}` event is produced.\n5. Extra task. Sensors may stop working. We need an additional `maintenance` stream which report malfunctions, \nsmth like `{:maintenance, {:roomx_x, [:smoke, :temperature]}}`. \n\nAnd there is a priority in events, the `:siren` has the highest priority, `:ok` - the lowest.\nIt means, if there is any event with the high priority, then only this event is generated.\n\nIn terms of streams and flow one can formulate the problem in the following way:\n\nInput: The flow of `3 * room_number` streams:\n```elixir\n%{\n  room_1_temperature: Stream.t([{:temperature, integer()}]),\n  room_1_humidity: Stream.t([{:humidity, integer()}),\n  room_1_smoke: Stream.t([{:smoke, boolean()}),\n  ...\n}\n```\n\nOutput:\n```elixir\n%{\n  status: [{:ok, []} | {:warning, [room()]} | {:alarm, [room()]} | {:siren, [room()]} \n}\n```\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonmi%2Ffire_alarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonmi%2Ffire_alarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonmi%2Ffire_alarm/lists"}